OGeek|极客世界-中国程序员成长平台

标题: ios - 在 iOS 中使用 ffmpeg 进行 hls 直播 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 14:49
标题: ios - 在 iOS 中使用 ffmpeg 进行 hls 直播

我是 ffmpeg 的新手,我正在尝试创建直播应用 (HLS),我想要直播而不是 VOD。

我可以通过终端使用 ffmpeg 并从 m4v 创建 .ts 文件,但我不知道如何在 iPhone 中实现相同的功能。

我的做法是在 iPhone 端创建 .ts 文件,然后发送到服务器。

我不确定这种方法是否正确,如果正确,我如何创建 .ts 文件,否则正确的方法是什么?



Best Answer-推荐答案


如果您想从 iPhone 创建 .ts 文件,您需要 FFmpegWrapper图书馆,然后这样做,

NSString *outputPath = [documentDirectoryPath stringByAppendingPathComponent"out.m3u8"];

    FFmpegWrapper *wrapper = [[FFmpegWrapper alloc] init];
    [wrapper convertInputPath:inputPath outputPathutputPath segmentDuration:SEGMENT_DURATION options:nil progressBlock:
     ^(NSUInteger bytesRead, uint64_t totalBytesRead, uint64_t totalBytesExpectedToRead) {

         //Do loading here


     } completionBlock:^(BOOL success, NSError *error) {

         // Do whatever after it is complete

     }];

关于ios - 在 iOS 中使用 ffmpeg 进行 hls 直播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29248469/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4