【问题标题】:How to convert .mp4 file to .ts using ffmpeg in iOS如何在 iOS 中使用 ffmpeg 将 .mp4 文件转换为 .ts
【发布时间】:2014-11-17 06:52:30
【问题描述】:

我想以编程方式将.mp4 文件转换为.ts 文件。我搜索并发现我可以使用ffmpeg 库,这是我以前从未使用过的。

我也成功地将这个库导入到我的项目中,但我无法弄清楚如何将.mp4 文件转换为.ts。我查看了一下,发现命令如下:

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

但是如何在我的 iOS 项目中使用它呢?任何帮助表示赞赏。

【问题讨论】:

  • 您需要 API 文档:ffmpeg.org/doxygen/trunk/index.html
  • 你好,Wain,我检查了这个文档,但我没有得到任何对我有帮助的东西。还有什么我应该检查的吗?
  • here

标签: ios objective-c video ffmpeg


【解决方案1】:

在您的班级中添加ffmpeg 库。我更喜欢在 cocoapods 中使用 ffmpeg 包装类。

pod 'FFmpegWrapper', '~> 1.0'

安装pod并使用以下代码将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 : 可以保存 .ts 文件的 NSDocumentDirectory 路径

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-14
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多