audio - 使用 ffmpeg 对 AAC 音频进行转码时,下一个 pts 与前一个 pts 加上持续时间不匹配
问题描述
在我的理解中,以下陈述必须成立:
next pts = previous pts + duration
但是,我得到了这个看起来很奇怪的PTS
es列表:ffprobe
<packet codec_type="audio" ... pts="63000" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="65070" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="67140" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="69300" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="71370" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="73440" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="75510" duration="2089" duration_time="0.023211" ...>
<packet codec_type="audio" ... pts="77670" duration="2089" duration_time="0.023211" ...>
对应的PTS
差距如下。您看不到以下空白匹配2089
:
63000 <> 65070: 2070
65070 <> 67140: 2070
67140 <> 69300: 2160
69300 <> 71370: 2070
71370 <> 73440: 2070
73440 <> 75510: 2070
75510 <> 77670: 2160
我对转码没有深入的了解AAC
,所以我和一些随机的家伙交谈#ffmpeg
。按照他的说法,差距应该是一个固定值:
20:01 -!- Icedream [~icedream@hzn-b.serverkomplex.de] has quit [Quit: A lol made me boom.]
20:02 < DeHackEd> I would expect them to increment at a constant rate, since AAC (which is probably what you're using) uses fixed size
audio chunks. But that's very inconsistent
20:03 < DeHackEd> (+/- 1 pts number would be acceptable)
说实话,这是一个有问题的视频,但不是你所期望的。如果两个或多个音频数据包被塞进一个数据包中,我会听到断断续续的音频剪辑声音PES
。这个配置的特别之处在于,PTS
除了第一个之外,播放器必须猜测尾随的音频包。由于PTS
间隙不一致,玩家一定是用了错误PTS
的 es 作为尾随的,这在我看来是原因。
但是,触发点可能是什么?以下是一些您可以参考的上下文:
- 原始视频没有令人惊讶的
PTS
差距。这是我为提取所有独特间隙而定制的脚本的结果:
$ ./foo.sh ./original.flv
diff 296448 occurs at 296448 // just a first packet (=has no previous packet)
diff 24 occurs at 296472
diff 23 occurs at 296495
- 这是我用于转码的命令:
$FFMPEG -hide_banner -loglevel info -nostats \
-i $input \
-map "[out1]" -c:v libx264 -r 30 -force_key_frames "expr:gte(t, n_forced*$keyFrameInterval)" -preset veryfast -vprofile high -minrate 4.5M -maxrate 6M -bufsize 6M \
-map 0:a -c:a aac -b:a:1 128K -af "aformat=sample_rates=44100|48000:channel_layouts=stereo" \
-map 0:a -c:a aac -b:a:2 32K -af "aformat=sample_rates=44100|48000:channel_layouts=stereo" \
-f mpegts -tune zerolatency pipe:1 > \
>($FFMPEG -hide_banner -loglevel info -nostats \
-i - \
-map 0:v -c:v copy -map 0:1 -c:a copy -bsf:a aac_adtstoasc -tune zerolatency -f flv -max_muxing_queue_size 1024 ${output}_1080 \
-map 0:v -s $(width 1280 720 $orientation)x$(height 1280 720 $orientation) -c:v libx264 -r 30 -force_key_frames "expr:gte(t, n_forced*$keyFrameInterval)" -preset veryfast -vprofile high -minrate 3M -maxrate 4M -bufsize 4M -map 0:1 -c:a copy -bsf:a aac_adtstoasc -f flv -tune zerolatency -max_muxing_queue_size 1024 ${output}_720 \
...
解决方案
推荐阅读
- angular - 如何在 angular2-markdown 的降价中包含降价
- ios - 如何从传输对象的列表类型中获取数据?(RealmSwift)
- python-3.x - 根据每行中的字符串对数据进行分类
- asp.net-mvc - 更改引导程序时导航栏无法正确显示
- javascript - 如何从 firebase 检索和显示与特定用户配置文件相关的数据
- php - 我正在尝试更新一个表并从不同的表中调用另一行
- mysql - 使用另一个表记录更新一个表
- c# - .NET 异步关闭方法?
- opentracing - 使用 Jaeger 跟踪 Java 应用程序时出错
- oracle - 从多个excel文件导入数据-Oracle PL-SQL