从assert中获得视频 转换成data 写入文件 写入成功,但是视频播放不了啊

贴点我的转换代码

  • (void)videoWithUrl:(NSURL *)url withFilePath:(NSString *)filePath
    {

    [[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
    NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:filePath];
    static const NSUInteger BufferSize = 1024*1024;

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    if (url) {

        [assetLibrary assetForURL:url resultBlock:^(ALAsset *asset) {
    
            ALAssetRepresentation *rep=[asset defaultRepresentation];
    
            uint8_t *buffer = calloc(BufferSize, sizeof(*buffer));
            NSUInteger offset = 0, bytesRead = 0;
    
            do {
    
                    bytesRead = [rep getBytes:buffer fromOffset:offset length:BufferSize error:nil];
                    [handle writeData:[NSData dataWithBytesNoCopy:buffer length:bytesRead freeWhenDone:NO]];
                    offset += bytesRead;
    
            } while (bytesRead > 0);
    
            free(buffer);
    

http://www.shangxueba.com/jingyan/2912226.html