在 iOS 中使用 ffmpeg 进行 hls 直播

hls live streaming using ffmpeg in iOS

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

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

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

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

如果你想从 iPhone 创建 .ts 文件,你将需要 FFmpegWrapper 库然后这样做,

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

    FFmpegWrapper *wrapper = [[FFmpegWrapper alloc] init];
    [wrapper convertInputPath:inputPath outputPath:outputPath 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

     }];