4

I want to convert a .mp4 file into a .ts file programmatically. I searched and found out that I can use ffmpeg library for that, which I have never used before.

I have also successfully imported this library to my project, but I am not able to figure out how I can convert .mp4 file into .ts. I looked it over 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.

3
  • You need API documentation: ffmpeg.org/doxygen/trunk/index.html Commented Sep 23, 2014 at 6:58
  • 1
    Hello Wain, i checked this documentation but i didn't get any thing which helps me. Is there any thing else that i should check for this? Commented Sep 23, 2014 at 7:53
  • See here. Commented Sep 30, 2014 at 1:21

1 Answer 1

2

Add ffmpeg library in your class. I prefer to use the ffmpeg wrapper class in cocoapods.

pod 'FFmpegWrapper', '~> 1.0'

Install the pod and use the following codes to convert the mp4 file to 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 : bundle path for the mp4 video file outputFilePath : NSDocumentDirectory path in which you can save the .ts files

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.