【问题标题】:hls live streaming using ffmpeg in iOS在 iOS 中使用 ffmpeg 进行 hls 直播
【发布时间】:2015-05-28 16:46:40
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: ios objective-c ffmpeg http-live-streaming


    【解决方案1】:

    如果你想从 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
    
         }];
    

    【讨论】:

    • 嘿阿比,谢谢哥们,你的解决方案刚刚奏效。您对直播(广播模式)有什么建议吗?我实施的方法是否正确?我正在考虑将 .ts 文件发送到服务器,然后服务器将其进一步发送到其他设备,或者可能是要访问的实时 url,你是什么 cmets ?我想在视频质量和减少延迟方面采用最佳方法。
    • 我建议在服务器端进行分段,因为它比在客户端更不容易头疼。您还需要以不同的比特率制作多个播放列表文件。这样,客户端将根据测量的网络比特率切换到最合适的变体。
    • @Abhi :我在 FFMpegWrapper 类中没有找到带有 SEGMENT_DURATION 的上述函数。而不是我找到了这个: - (void) convertInputPath:(NSString*)inputPath outputPath:(NSString*)outputPath options:(NSDictionary*)options progressBlock:(FFmpegWrapperProgressBlock)progressBlock completionBlock:(FFmpegWrapperCompletionBlock)completionBlock;我已经使用 pod 集成了这个包装类。是否有任何方法可以使用该方法指定段持续时间?
    • 哦,是的。我的错,这是我的库的分叉版本...github.com/Abhijit-Kayande/FFmpegWrapper
    • 输入路径可以是rtsp链接吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 1970-01-01
    • 1970-01-01
    • 2012-07-23
    • 2015-01-25
    相关资源
    最近更新 更多