How to convert a .mp4 file to .ts using ffmpeg in iOS

I want to programmatically convert a file .mp4to a file .ts. I searched and found out that I can use the ffmpeg library that I have never used before.

I also successfully imported this library into my project, but I cannot figure out how I can convert the file .mp4to .ts. I looked through it and I found commands like:

ffmpeg -i file.mp4 -acodec libfaac -vcodec libx264 -an -map 0 -f segment -segment_time 10 -segment_list test.m3u8 -segment_format mpegts -vbsf h264_mp4toannexb -flags -global_header stream%05d.ts

But how can I use this in my iOS project? Any help is appreciated.

+4
source share
1 answer

ffmpeg. ffmpeg cocoapods.

pod 'FFmpegWrapper', '~> 1.0'

mp4 ts.

FFmpegWrapper *wrapper = [[FFmpegWrapper alloc] init];
[wrapper convertInputPath:inputFilePath outputPath:outputFilePath options:nil progressBlock:^(NSUInteger bytesRead, uint64_t totalBytesRead, uint64_t totalBytesExpectedToRead) {
    } completionBlock:^(BOOL success, NSError *error) {
        success?NSLog(@"Success...."):NSLog(@"Error : %@",error.localizedDescription);
    }];

inputFilePath: mp4 outputFilePath: NSDocumentDirectory, .ts

+2

All Articles