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

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

问题描述

我正在尝试在 iOS 应用程序中使用 ffmpeg 将本地 .mp4 视频转换为 HLS.我已经使用 pod 集成了 ffmpeg 包装器并生成了所有分段的 .ts 文件和 m3u8 文件,但如下所示,某些 .ts 文件段未在 .m3u8 播放列表文件中列出.它总是列出最后 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);
    }];

有没有其他方法可以做到这一点?

Is there any other methods to do this?

推荐答案

最后我通过使用以下代码在 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天全站免登陆