Saturday 16 November 2019

ffmpeg - Video produced from images only plays in VLC but no other players


Within my folder with bunch of 13MP bmp images named 0001.bmp, 0002.bmp,... I run the following commands from command line.


Crop images to 4K


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

Scale images


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

Compress images to video


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

But the produced video can only be played in VLC, every other player fails.


Can anyone with more experience in ffmpeg suggest where I'm making a mistake?


This is the ffmpeg console output after the last command:


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

Thanks!



Answer



When you convert from BMP, JPG or PNG files, ffmpeg will try to preserve as much detail as possible and encode the video with the best matching color space. Your resulting file uses the yuv444p non-subsampled colorspace. JPGs use yuv422p. Many players cannot show video in this format, such as Windows Media Player, QuickTime and others.


To get a video supported in non-FFmpeg-based players, use this command, with the most important thing being the -pix_fmt yuv420p option.


Note that I removed your other options for the sake of brevity.


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

By the way, your ffmpeg is rather old. Please update to a new version. Recent versions warn you of the color space being YUV 4:4:4 and that incompatible players might not show the video or even crash.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...