由图像制作的视频只能在 VLC 中播放,不能在其他播放器中播放

由图像制作的视频只能在 VLC 中播放,不能在其他播放器中播放

在我的文件夹中,有一堆 13MP bmp 图像,分别名为 0001.bmp、0002.bmp……我从命令行运行以下命令。

裁剪图像至 4K

ffmpeg -i %4d.bmp -vf "crop=3840:2160:184:240" croped%4d.bmp

缩放图像

ffmpeg -i croped%4d.bmp -vf scale=1920:1080 scaled%4d.bmp

将图像压缩为视频

ffmpeg -r 25 -i scaled%4d.bmp -c:v libx264 -b:v 25000k -minrate 25000k -r 25 -s 1920x1080 -c:v libx264 -qp 20 -preset medium output.mp4

但制作的视频只能在VLC中播放,其他播放器都无法播放。

有更多 ffmpeg 经验的人能指出我哪里犯了错误吗?

这是最后一条命令后的 ffmpeg 控制台输出:

ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 25 2012 12:21:26 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enab
le-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libop
encore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libop
enjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52.  9.100 / 52.  9.100
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.102 /  3. 23.102
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
[image2 @ 0202f180] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, image2, from 'scaled%4d.bmp': Duration: 00:00:04.96, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: bmp, bgr24, 1920x1080, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 037792c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 037792c0] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 @ 037792c0] 264 - core 128 r2216 198a7ea - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - ht
tp://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subm
e=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=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 in
terlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 wei
ghtb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=
20 ip_ratio=1.40 pb_ratio=1.30 aq=0
Output #0, mp4, to 'video.mp4':
  Metadata:    encoder         : Lavf54.37.100
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv444p, 1920x1080, q=-1--1, 25000 kb/s, 1280 0 tbn, 25 tbc
Stream mapping:    Stream #0:0 -> #0:0 (bmp -> libx264)
frame=  124 fps=2.9 q=-1.0 Lsize=   42311kB time=00:00:04.88 bitrate=71027.1kbits/s
video:42309kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.005367%
[libx264 @ 037792c0] frame I:1     Avg QP:17.00  size:579142
[libx264 @ 037792c0] frame P:93    Avg QP:20.00  size:375357
[libx264 @ 037792c0] frame B:30    Avg QP:22.00  size:261208
[libx264 @ 037792c0] consecutive B-frames: 51.6% 48.4%  0.0%  0.0%
[libx264 @ 037792c0] mb I  I16..4:  3.5% 77.5% 19.0%
[libx264 @ 037792c0] mb P  I16..4:  2.6% 47.2% 11.4%  P16..4: 10.3% 16.7% 11.7%  0.0%  0.0%    skip: 0.1%
[libx264 @ 037792c0] mb B  I16..4:  2.0% 34.1%  3.8%  B16..8: 20.3% 13.7%  6.3%  direct:19.0%  skip: 0.9%
L0:39.1% L1:20.8% BI:40.1%
[libx264 @ 037792c0] 8x8 transform intra:78.6% inter:63.5%
[libx264 @ 037792c0] coded y,u,v intra: 99.6% 72.4% 80.8% inter: 91.1% 65.5% 75.5%
[libx264 @ 037792c0] i16 v,h,dc,p:  7%  7% 54% 32%
[libx264 @ 037792c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 17% 32%  5%  6%  6%  8%  6% 10%
[libx264 @ 037792c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9% 12% 23%  9% 10%  8% 11%  7% 10%
[libx264 @ 037792c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 037792c0] ref P L0: 31.1% 12.4% 30.4% 26.0%
[libx264 @ 037792c0] ref B L0: 58.7% 41.3%
[libx264 @ 037792c0] kb/s:69876.70

谢谢!

答案1

当您从 BMP、JPG 或 PNG 文件转换时,ffmpeg将尝试保留尽可能多的细节并使用最匹配的色彩空间对视频进行编码。生成的文件使用yuv444p 非子采样色彩空间。JPG 使用yuv422p。许多播放器无法播放这种格式的视频,例如 Windows Media Player、QuickTime 等。

要获得非基于 FFmpeg 的播放器支持的视频,请使用此命令,其中最重要的是选项-pix_fmt yuv420p

请注意,为了简洁起见,我删除了您的其他选项。

ffmpeg … -i scaled%4d.bmp -c:v libx264 … -pix_fmt yuv420p output.mp4

顺便说一句,你的ffmpeg有点旧了。请更新至新版本。最近的版本警告您色彩空间为 YUV 4:4:4,不兼容的播放器可能无法显示视频甚至崩溃。

相关内容