我读了大量的文档和文章,但仍然没有得到我期望的结果。我有一个 GOP 值可变的文件,因为它的视频中有一些闪烁。所以我使用以下命令来获取所需的 GOP 值。
ffmpeg -i Input.MXF -pix_fmt yuv420p -flags +ildct+ilme -vcodec mpeg2video -top 1 -dc 10 -intra_vlc 1 -qmin 1 -lmin 1*QP2LAMBDA -vtag xd5c -x264opts scenecut:nal-hrd=cbr:open-gop=0:pic-struct:aud:force-cfr:keyint=15:keyint_min=15 -bf 2 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -b:v 35000k -bufsize 35000k -minrate 35000k -maxrate 35000k -aspect 16:9 -r 29.97 -acodec copy -f mxf -y Output.MXF
ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mxf, from 'Input.MXF':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : adab4424-2f25-4dc7-92ff-29bd000c0000
generation_uid : adab4424-2f25-4dc7-92ff-29bd000c0001
company_name : FFmpeg
product_name : OP1a Muxer
product_version : 56.15.102
product_uid : adab4424-2f25-4dc7-92ff-29bd000c0002
material_package_umid: 0x060A2B340101010501010D00132A51BF52947134FB2A51BF0052947134FB2A00
timecode : 00:00:00:00
Duration: 00:00:09.21, start: 0.000000, bitrate: 37152 kb/s
Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 29.97 tbn, 59.94 tbc
Metadata:
file_package_umid: 0x060A2B340101010501010D00132A51BF52947134FB2A51BF0052947134FB2A01
Side data:
cpb: bitrate max/min/avg: 35000000/0/0 buffer size: 35012608 vbv_delay: N/A
Stream #0:1: Audio: pcm_s24le, 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Metadata:
file_package_umid: 0x060A2B340101010501010D00132A51BF52947134FB2A51BF0052947134FB2A01
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> mpeg2video (native))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpeg2video @ 0x5619674fb1c0] Warning vbv_delay will be set to 0xFFFF (=VBR) as the specified vbv buffer is too large for the given bitrate!
Output #0, mxf, to 'Output.MXF':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : adab4424-2f25-4dc7-92ff-29bd000c0000
generation_uid : adab4424-2f25-4dc7-92ff-29bd000c0001
company_name : FFmpeg
product_name : OP1a Muxer
product_version : 56.15.102
product_uid : adab4424-2f25-4dc7-92ff-29bd000c0002
material_package_umid: 0x060A2B340101010501010D00132A51BF52947134FB2A51BF0052947134FB2A00
timecode : 00:00:00:00
encoder : Lavf58.45.100
Stream #0:0: Video: mpeg2video (Main) (xd5c / 0x63356478), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], q=1-31, 35000 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
Metadata:
file_package_umid: 0x060A2B340101010501010D00132A51BF52947134FB2A51BF0052947134FB2A01
encoder : Lavc58.91.100 mpeg2video
Side data:
cpb: bitrate max/min/avg: 35000000/35000000/35000000 buffer size: 35000000 vbv_delay: N/A
Stream #0:1: Audio: pcm_s24le, 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Metadata:
file_package_umid: 0x060A2B340101010501010D00132A51BF52947134FB2A51BF0052947134FB2A01
frame= 276 fps= 85 q=1.3 Lsize= 41682kB time=00:00:09.17 bitrate=37212.9kbits/s speed=2.83x
video:38832kB audio:2590kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.628826%
但结果的GOP值不是N=3,M=15,而是N=3,M=12。
以下是文件 I 帧的时间码。
pkt_pts_time=0.000000
pkt_pts_time=0.500500
pkt_pts_time=1.001000
pkt_pts_time=1.501500
pkt_pts_time=2.002000
pkt_pts_time=2.502500
pkt_pts_time=2.702700
pkt_pts_time=2.802800
pkt_pts_time=2.902900
pkt_pts_time=3.403400
pkt_pts_time=3.903900
pkt_pts_time=4.404400
pkt_pts_time=4.904900
pkt_pts_time=5.405400
pkt_pts_time=5.905900
pkt_pts_time=6.406400
pkt_pts_time=6.906900
pkt_pts_time=7.407400
pkt_pts_time=7.907900
pkt_pts_time=8.408400
pkt_pts_time=8.908900
这个是结果 I 帧的时间码。
pkt_pts_time=0.000000
pkt_pts_time=0.400400
pkt_pts_time=0.800800
pkt_pts_time=1.201200
pkt_pts_time=1.601600
pkt_pts_time=2.002000
pkt_pts_time=2.402400
pkt_pts_time=2.702700
pkt_pts_time=2.902900
pkt_pts_time=3.303300
pkt_pts_time=3.703700
pkt_pts_time=4.104100
pkt_pts_time=4.504500
pkt_pts_time=4.904900
pkt_pts_time=5.305300
pkt_pts_time=5.705700
pkt_pts_time=6.106100
pkt_pts_time=6.506500
pkt_pts_time=6.906900
pkt_pts_time=7.307300
pkt_pts_time=7.707700
pkt_pts_time=8.108100
pkt_pts_time=8.508500
pkt_pts_time=8.908900
关于 FFmpeg 命令强制 GOP 为 N=3、M=15 有什么建议吗?
答案1
删除该-x264opts
选项。添加-g 15 -sc_threshold 1G -flags +cgop
。