为什么ffmpeg生成的视频很模糊?

为什么ffmpeg生成的视频很模糊?

我使用 ffmpeg 在 CentOS 7 中用以下命令从 1000 个图像文件制作视频(test.mp4):

ffmpeg -i frame%04d.png -vcodec libx264 -r 10 -t 100 test.mp4

ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
  configuration: --prefix=/home/sunyp/software/ffmpeg/ffmpeg-4.1.4/ffmpeg-4.1.4-install --enable-network --enable-protocols --enable-muxers --enable-shared --enable-libx264 --enable-gpl --extra-cflags=-I/home/sunyp/software/x264/install/include --extra-ldflags=-L//home/sunyp/software/x264/install/lib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, image2, from 'frame%04d.png':
  Duration: 00:00:39.88, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 640x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0xf3b8c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0xf3b8c0] profile High 4:4:4 Predictive, level 2.2, 4:4:4, 8-bit
[libx264 @ 0xf3b8c0] 264 - core 157 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=15 lookahead_threads=2 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=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 640x480, q=-1--1, 10 fps, 10240 tbn, 10 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=  162 fps=0.0 q=25.0 size=    1024kB time=00:00:10.00 bitrate= 838.9kbits/frame=  315 fps=314 q=25.0 size=    2816kB time=00:00:25.30 bitrate= 911.8kbits/frame=  400 fps=285 q=-1.0 Lsize=    4421kB time=00:00:39.70 bitrate= 912.2kbits/s dup=0 drop=597 speed=28.3x    
video:4415kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.125100%
[libx264 @ 0xf3b8c0] frame I:2     Avg QP:15.07  size: 25651
[libx264 @ 0xf3b8c0] frame P:109   Avg QP:18.77  size: 18455
[libx264 @ 0xf3b8c0] frame B:289   Avg QP:25.81  size:  8504
[libx264 @ 0xf3b8c0] consecutive B-frames:  2.5%  2.5%  3.0% 92.0%
[libx264 @ 0xf3b8c0] mb I  I16..4:  2.3% 74.7% 23.0%
[libx264 @ 0xf3b8c0] mb P  I16..4:  1.7%  1.7%  4.2%  P16..4:  3.4%  7.0% 12.1%  0.0%  0.0%    skip:70.0%
[libx264 @ 0xf3b8c0] mb B  I16..4:  0.1%  0.4%  0.4%  B16..8:  8.6%  9.1%  8.3%  direct: 2.8%  skip:70.2%  L0:39.3% L1:29.7% BI:31.0%
[libx264 @ 0xf3b8c0] 8x8 transform intra:34.9% inter:4.3%
[libx264 @ 0xf3b8c0] coded y,u,v intra: 38.0% 26.4% 28.7% inter: 15.2% 3.1% 3.3%
[libx264 @ 0xf3b8c0] i16 v,h,dc,p: 68% 22% 10%  0%
[libx264 @ 0xf3b8c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20%  8% 70%  0%  0%  0%  0%  0%  0%
[libx264 @ 0xf3b8c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 17% 26%  5%  6%  7%  7%  6%  6%
[libx264 @ 0xf3b8c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0xf3b8c0] ref P L0: 47.0% 12.6% 21.8% 18.6%
[libx264 @ 0xf3b8c0] ref B L0: 85.8% 10.6%  3.6%
[libx264 @ 0xf3b8c0] ref B L1: 95.4%  4.6%
[libx264 @ 0xf3b8c0] kb/s:904.10

使用 mplayer 播放视频时,我发现视频非常模糊(请参阅测试.mp4视频快照),在启动mplayer的终端中,出现很多错误信息:

Starting playback...
[h264 @ 0x7f53d268f880]gray chroma
[h264 @ 0x7f53d268f880]error while decoding MB 9 11, bytestream 12958
[h264 @ 0x7f53d268f880]concealing 800 DC, 800 AC, 800 MV errors in B frame
[h264 @ 0x7f53d268f880]gray chroma
[h264 @ 0x7f53d268f880]error while decoding MB 20 15, bytestream 4359
[h264 @ 0x7f53d268f880]concealing 629 DC, 629 AC, 629 MV errors in B frame
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0x7f53d2b45640]bicubic scaler, from yuv444p to yuv420p using MMXEXT
VO: [vdpau] 640x480 => 640x480 Planar YV12 
V:   0.2   3/  3 ??% ??% ??,?% 0 0                                              
[h264 @ 0x7f53d268f880]concealing 437 DC, 437 AC, 437 MV errors in P frame
V:   0.4   5/  5 ??% ??% ??,?% 0 0                                              
[h264 @ 0x7f53d268f880]left block unavailable for requested intra4x4 mode -1 at 0 10
[h264 @ 0x7f53d268f880]error while decoding MB 0 10, bytestream 14914
[h264 @ 0x7f53d268f880]concealing 849 DC, 849 AC, 849 MV errors in P frame
V:   0.8   9/  9 14%  4%  0.0% 0 0                                              
[h264 @ 0x7f53d268f880]Reference 5 >= 4
[h264 @ 0x7f53d268f880]error while decoding MB 9 21, bytestream 1725
[h264 @ 0x7f53d268f880]concealing 400 DC, 400 AC, 400 MV errors in P frame
V:   1.6  17/ 17 11%  3%  0.0% 0 0                                              
[h264 @ 0x7f53d268f880]Reference 4 >= 4
[h264 @ 0x7f53d268f880]error while decoding MB 25 9, bytestream 16009
[h264 @ 0x7f53d268f880]concealing 864 DC, 864 AC, 864 MV errors in P frame
V:   2.0  21/ 21 11%  3%  0.0% 0 0                                              
[h264 @ 0x7f53d268f880]Reference 4 >= 4
[h264 @ 0x7f53d268f880]error while decoding MB 27 9, bytestream 14898
[h264 @ 0x7f53d268f880]concealing 862 DC, 862 AC, 862 MV errors in P frame
V:   2.1  22/ 22 11%  3%  0.0% 0 0                                              
[h264 @ 0x7f53d268f880]Reference 3 >= 3
[h264 @ 0x7f53d268f880]error while decoding MB 32 12, bytestream 6095
[h264 @ 0x7f53d268f880]concealing 737 DC, 737 AC, 737 MV errors in B frame
V:   2.4  25/ 25 11%  3%  0.0% 0 0                                              
[h264 @ 0x7f53d268f880]Reference 5 >= 4
[h264 @ 0x7f53d268f880]error while decoding MB 23 7, bytestream 17057
[h264 @ 0x7f53d268f880]concealing 946 DC, 946 AC, 946 MV errors in P frame

您知道问题的原因是什么以及如何解决它吗?

相关内容