ffmpeg 没有制作正确的视频尺寸

ffmpeg 没有制作正确的视频尺寸

我一直试图将一堆 .png 文件合并成一个 mp4。.png 文件都是 1920x1080,但我的输出文件总是较小,即 1920x1072。我在这里犯了什么愚蠢的错误?

ffmpeg -stream_loop 50 -framerate 60 -i 'camera_1_%02d.png' camera_1.mp4

(是的,我想循环播放 50 次)

输出如下。顺便说一句,可能是 Windows 在其属性页面上错误地报告了尺寸(右键单击资源管理器,详细信息)。

ffmpeg version 2021-02-02-git-2367affc2c-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 64.100 / 56. 64.100
  libavcodec     58.120.100 / 58.120.100
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7.101.100 /  7.101.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, image2, from 'camera_1_%02d.png':
  Duration: 00:00:00.58, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 1920x1080 [SAR 3780:3780 DAR 16:9], 60 fps, 60 tbr, 60 tbn, 60 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000001b238971880] using SAR=1/1
[libx264 @ 000001b238971880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001b238971880] profile High 4:4:4 Predictive, level 4.2, 4:4:4, 8-bit
[libx264 @ 000001b238971880] 264 - core 161 r3043 59c0609 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=34 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=5000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'camera_1.mp4':
  Metadata:
    encoder         : Lavf58.65.101
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv444p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 5000 kb/s, 60 fps, 15360 tbn
    Metadata:
      encoder         : Lavc58.120.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/5000000 buffer size: 0 vbv_delay: N/A
frame= 1785 fps=100 q=-1.0 Lsize=   18121kB time=00:00:29.70 bitrate=4998.2kbits/s speed=1.67x
video:18099kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.121715%
[libx264 @ 000001b238971880] frame I:8     Avg QP:14.48  size:398208
[libx264 @ 000001b238971880] frame P:450   Avg QP:17.16  size: 21973
[libx264 @ 000001b238971880] frame B:1327  Avg QP:24.51  size:  4114
[libx264 @ 000001b238971880] consecutive B-frames:  0.8%  0.1%  0.0% 99.0%
[libx264 @ 000001b238971880] mb I  I16..4: 12.9% 44.6% 42.5%
[libx264 @ 000001b238971880] mb P  I16..4:  0.4%  1.7%  0.7%  P16..4: 12.2%  5.3%  3.4%  0.0%  0.0%    skip:76.2%
[libx264 @ 000001b238971880] mb B  I16..4:  0.0%  0.1%  0.0%  B16..8:  8.4%  1.7%  0.5%  direct: 0.6%  skip:88.6%  L0:35.4% L1:46.9% BI:17.7%
[libx264 @ 000001b238971880] final ratefactor: 15.92
[libx264 @ 000001b238971880] 8x8 transform intra:55.0% inter:65.4%
[libx264 @ 000001b238971880] coded y,u,v intra: 69.3% 40.7% 37.9% inter: 3.9% 0.9% 0.9%
[libx264 @ 000001b238971880] i16 v,h,dc,p: 18% 20% 13% 49%
[libx264 @ 000001b238971880] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 20% 19%  8%  5%  5%  9% 10%  8%
[libx264 @ 000001b238971880] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 23% 11%  7%  6%  6% 15%  8%  6%
[libx264 @ 000001b238971880] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001b238971880] ref P L0: 57.4% 11.2% 20.2% 11.3%
[libx264 @ 000001b238971880] ref B L0: 90.2%  7.4%  2.4%
[libx264 @ 000001b238971880] ref B L1: 96.4%  3.6%
[libx264 @ 000001b238971880] kb/s:4983.60

答案1

添加-vf format=yuv420p

ffmpeg -stream_loop 50 -framerate 60 -i 'camera_1_%02d.png' -vf format=yuv420p camera_1.mp4

这将使用兼容的色度二次采样。通常ffmpeg会尝试保留尽可能多的颜色信息,但大多数播放器/设备(包括 Windows 资源管理器)只能正确处理 YUV 4:2:0。

相关内容