FFmpeg:从相同的输入视频生成的M3U8播放列表的MD5哈希值具有不同的片段持续时间(在应用视频过滤器之后)不匹配 [英] FFmpeg: MD5 hash of M3U8 playlists generated from same input video with different segment durations (after applying video filter) don't match

查看:630
本文介绍了FFmpeg:从相同的输入视频生成的M3U8播放列表的MD5哈希值具有不同的片段持续时间(在应用视频过滤器之后)不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是一些我用来将MP4格式的视频转换并转换为的命令M3U8 播放列表.

Here are a few commands I am using to convert and transize a video in MP4 format to a M3U8 playlist.

对于给定的输入视频(MP4格式),生成片段持续时间为30秒的多个视频片段.

For a given input video (MP4 format), generate multiple video segments with segment duration 30 seconds.

ffmpeg -loglevel error -i input.mp4 -dn -sn -an -c:v copy -bsf:v h264_mp4toannexb -copyts -start_at_zero -f segment -segment_time 30 30%03d.mp4 -dn -sn -vn -c:a copy audio.aac

在每个片段上应用视频过滤器(在本例中为缩放),并将其转换为M3U8格式.

Apply a video filter (in this case scaling) on each segment and convert it to a M3U8 format.

ls 30*.mp4 | parallel 'ffmpeg -loglevel error -i {} -vf scale=-2:144 -hls_list_size 0 {}.m3u8'

file 'segment-name.m3u8'

for f in 30*.m3u8; do echo "file '$f'" >> list.txt; done

使用concat多路分配器,将所有片段文件(格式为M3U8)和音频组合在一起,以获得一个指向最后一个m3u8播放列表,该播放列表指向持续时间为10秒的片段.

Using concat demuxer, combine all segment files (which are in M3U8 format) and the audio to get one final m3u8 playlist pointing to segments with duration of 10 seconds.

ffmpeg -loglevel error -f concat -i list.txt -i audio.aac -c copy -hls_list_size 0 -hls_time 10 output_30.m3u8


我可以将第一步中的片段持续时间从30秒更改为60秒,并使用以下命令比较在两种情况下生成的最终M3U8播放列表的MD5哈希值:


I can change the segment duration in the first step from 30 seconds to 60 seconds, and compare the MD5 hash of the final M3U8 playlist generated in both the cases using this command:

ffmpeg -loglevel error -i <input m3u8 playlist> -f md5 -

输出文件的MD5哈希不同,即output_30.m3u8output_60.m3u8的视频流不相同.

The MD5 hash of the output files differ, i.e., video streams of output_30.m3u8 and output_60.m3u8 are not the same.

有人可以详细说明吗?

(我希望MD5哈希值是相同的)

推荐答案

在第二步中添加-crf 0(这意味着无损编码),将得到相同的校验和.

Adding -crf 0 (which implies lossless encoding) in the second step, gives the same checksums.

在有损编码的情况下,据我到目前为止所了解的,由于线程(使用更多线程会导致质量不同)和有损编解码器的影响,分段编码必然与普通编码不同.即使使用--stitchable(x264参数)和--threads 1(FFmpeg输出选项)之类的选项,校验和也有所不同.

In case of lossy encoding, from what I have learnt so far, segmented encodes are bound to be different from normal encodes due to threads (quality differs as more threads are used) and lossy codec. Even with options such as --stitchable (x264 parameter) and --threads 1 (FFmpeg output option), the checksum differs.

这篇关于FFmpeg:从相同的输入视频生成的M3U8播放列表的MD5哈希值具有不同的片段持续时间(在应用视频过滤器之后)不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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