6

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

これもmp4コンテナとフォーマットに変換する必要があります。

Impossible to convert between the formats supported by the filter 'in' and the filter 'auto_scaler_0'

ffmpeg -I test.flv test.mp4 のような OSX コマンドから学習しようとしています。

iOS への移植が実現可能かどうか、すべての異なるシナリオで機能するかどうか、

要約すれば

--- ビデオが h264 になり、オーディオが swf コーデックになる iOS デバイスで flv を mp4 に変換する最善の方法は何ですか?

4

1 に答える 1

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);
     }];
}
于 2018-08-13T07:27:25.103 に答える