使用ffmpeg将Mp4转换为HLS [英] Mp4 to HLS using ffmpeg

查看:2988
本文介绍了使用ffmpeg将Mp4转换为HLS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iOS应用中的ffmpeg将本地.mp4视频转换为HLS。我使用pod集成了ffmpeg包装器并生成了所有分段的.ts文件和m3u8文件,但是.m3u8播放列表文件中没有列出一些.ts文件段,如下所示。它总是列出最后5个视频片段。

I'm trying to convert a local .mp4 video to HLS using ffmpeg in an iOS app. I have integrated the ffmpeg wrapper using pods and generated all the segmented .ts files and the m3u8 file, but some of the .ts file segments are not listed in the .m3u8 playlist file as shown below. It is always listing the last 5 video segments.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:13
#EXTINF:2,
out13.ts
#EXTINF:1,
out14.ts
#EXTINF:2,
out15.ts
#EXTINF:2,
out16.ts
#EXTINF:1,
out17.ts
#EXT-X-ENDLIST

我使用以下代码生成HLS。

I used the following codes to generate the HLS.

    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);
    }];

还有其他方法吗?

推荐答案

最后我通过使用以下代码在 FFOutputFile.m 中设置hls大小来修复此问题。

At last I fixed this issue by setting the hls size in the FFOutputFile.m using the following code.

av_opt_set_int(formatContext->priv_data, "hls_list_size", list_size, 0);

这篇关于使用ffmpeg将Mp4转换为HLS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆