在iOS上以编程方式将flv转换为mp4

Ami*_*k12 6 flv ffmpeg converter streaming-flv-video ios

在我们的iOS应用程序中,我们将收到flv**(Container)**文件,其中包含视频和音频流

Input #0, flv, from 'test.flv':

  Metadata:
    streamName      : flvLiveStream
    encoder         : Lavf55.12.100
  Duration: 00:00:48.00, start: 66064.401000, bitrate: 632 kb/s
    Stream #0:0, 41, 1/1000: **Video: h264 (Baseline)**, 1 reference frame, yuv420p(progressive, left), 1280x720, 0/1, 15 fps, 1k tbr, 1k tbn
    Stream #0:1, 14, 1/1000: **Audio: pcm_alaw,** 8000 Hz, mono, s16, 64 kb/s
Run Code Online (Sandbox Code Playgroud)

这需要转换为mp4容器和格式,我正在尝试使用ffmpeg,我相信只有这样,使用transcoding.c文件,但在这个阶段失败

Impossible to convert between the formats supported by the filter 'in' and the filter 'auto_scaler_0'
Run Code Online (Sandbox Code Playgroud)

我试图从像ffmpeg -I test.flv test.mp4这样的OSX命令中学习,

移植到iOS是可行的,它可以在所有不同的场景中工作,

综上所述

---在iOS设备上将flv转换为mp4的最佳方法是什么?视频将在h264中,音频将在swf编解码器中?

Tm *_*ani 1

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"MyVideo.mp4"];
NSURL *outputURL = [NSURL fileURLWithPath:filePath];

[self convertVideoToLowQuailtyWithInputURL:localUrl outputURL:outputURL handler:^(AVAssetExportSession *exportSession)
{
    if (exportSession.status == AVAssetExportSessionStatusCompleted) {
        // Video conversation completed
    }          
}];

- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL handler:(void (^)(AVAssetExportSession*))handler {
    [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetPassthrough];
    exportSession.outputURL = outputURL;
    exportSession.outputFileType = AVFileTypeMPEG4;
    [exportSession exportAsynchronouslyWithCompletionHandler:^(void) {
         handler(exportSession);
     }];
}
Run Code Online (Sandbox Code Playgroud)