请问帮助我了解如何在ffmpeg编码过程中匹配音频和视频持续时间,以将用于无限循环mpeg破折号传输(mp4box)的视频串联起来。
我的问题发生在ffmpeg编码期间:
在concat / encode处理之前,为每个视频进行音频编码和时基一致性的第一步:
ffmpeg -y -i "$f" -c copy -video_track_timescale 90k -c:a aac -b:a 384k -ar 44100 -ac 2 -shortest -af aresample=async=1 ../buffer/${NAME}_buffer.mp4
然后进行concat / encode处理,以获取封闭GOP的总持续时间(以秒为单位) 例如:减少373.5持续时间以获得372.000持续时间:
ffmpeg -f concat -safe 0 -y -i list.txt -loop 1 -i ../logo/logo.png -c:a copy -c:v libx264 -x264opts keyint=$GOP:min-keyint=$GOP:no-scenecut -bf 0 -r $FPSC -b:v 4800k -maxrate 9600k -bufsize 19200k -profile:v main -crf 22 -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10,scale=1920:1080,setsar=1" -t $TOTDUR 1080set.mp4
结果
VIDEO FORMAT CONTAINER DURATION:
372.000000
VIDEO STREAM DURATION:
372.000000
AUDIO FORMAT CONTAINER DURATION:
372.006000
我需要帮助来理解为什么音频持续时间比视频持续时间要多6毫秒以及如何解决。 我读到关于loop_stream应该有帮助吗? 非常感谢!
视频信息下方:
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2007-05-09T07:55:25.000000Z
Duration: 00:01:29.22, start: 0.000000, bitrate: 7490 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x816, 7403 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2007-05-09T07:55:25.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 94 kb/s (default)
Metadata:
creation_time : 2007-05-09T07:55:29.000000Z
handler_name : GPAC ISO Audio Handler
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2007-07-17T09:18:37.000000Z
genre : Trailer
artist : Fox
title : The Simpsons Movie
date : 2007
Duration: 00:02:17.25, start: 0.000000, bitrate: 8591 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x800, 8486 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2007-07-17T09:18:37.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 5.1, fltp, 107 kb/s (default)
Metadata:
creation_time : 2007-07-17T09:18:45.000000Z
handler_name : GPAC ISO Audio Handler
Stream #0:2: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 101x150 [SAR 72:72 DAR 101:150], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
creation_time : 2013-12-01T03:59:56.000000Z
genre : Trailer
artist : Warner Bros.
title : Gravity - 2K Trailer
encoder : HandBrake 0.9.9 2013051800
date : 2013
Duration: 00:02:27.07, start: 0.000000, bitrate: 20296 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 2048x858, 20149 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2013-12-01T03:59:56.000000Z
encoder : JVT/AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 153 kb/s (default)
Metadata:
creation_time : 2013-12-01T03:59:56.000000Z
Stream #0:2: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 102x150 [SAR 72:72 DAR 17:25], 90k tbr, 90k tbn, 90k tbc (attached pic)