[FFmpeg-user] h264 videos are darker

Totte Karlsson totte.karlsson at alleninstitute.org
Fri Feb 14 00:44:54 EET 2020


Hello,

Regarding h264 videos being dark:

> Please test current FFmpeg git head, remove hide_banner from your command line
> and provide the command line together with the complete, uncut console output.
> 
> The output option “r 30” is unneeded and to answer your question: The semantic of
> “gray” is not fixed in the multimedia domain (but that shouldn’t rule out a bug, see
> above).
> 
 
I have removed the r 30 as suggested and downloaded the latest ffmpeg binaries from https://ffmpeg.zeranoe.com/builds/

The ffmpeg command and its output is shown below.

Again, using the gray -pix_fmt results in videos being slightly 'darker' than the original. This can be seen on image areas that are going from having light and dark-to-black areas, like a rock wall for example. I am using VLC for viewing, but also checked with MPlayer, observing the same.

As the input data is 8bit, just giving the intensity of each pixel, I tried other ffmpeg's -pix_fmt's being 8bit. If I use any of the 'bayer' ones;
bayer_bggr8
bayer_rggb8
bayer_gbrg8
bayer_grbg8

the result seem much better. In fact, I can't see any difference in the resulting video from using any of those formats, and no difference among them either.

Question is, for someone (like me), with little video compression experience, would using one of the "bayer" pixel formats be considered common practice, or reasonable, for a 8bit input video stream? Reason I'm asking is because the resulting videos will be analyzed by machine learning algorithms and so we can't easily change parameters later on, as we are about to create a large data training set.
 
Here is the command and output:

ffmpeg.exe -y -vcodec rawvideo -f rawvideo -r 23 -s 658x492 -pix_fmt gray -i \\.\pipe\DEV_000F315BEBB8 -c:v libx264 -crf 23 x:\videos\Box_1_2020T140206.avi

 ffmpeg version git-2020-02-11-f15007a Copyright (c) 2000-2020 the FFmpeg developers
   built with gcc 9.2.1 (GCC) 20200122
   configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
   libavutil      56. 39.100 / 56. 39.100
   libavcodec     58. 68.102 / 58. 68.102
   libavformat    58. 38.100 / 58. 38.100
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 75.100 /  7. 75.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
 
 Input #0, rawvideo, from '\\.\pipe\DEV_000F315BEBB8':
   Duration: N/A, start: 0.000000, bitrate: 59567 kb/s
     Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 658x492, 59567 kb/s, 23 tbr, 23 tbn, 23 tbc
 Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
 Press [q] to stop, [?] for help
 [libx264 @ 00000111ed67f740] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
 [libx264 @ 00000111ed67f740] profile High, level 3.0, 4:0:0, 8-bit
 Output #0, avi, to 'x:\videos\Box_1_2020T140206.avi':
   Metadata:
     ISFT            : Lavf58.38.100
     Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), gray, 658x492, q=-1--1, 23 fps, 23 tbn, 23 tbc
     Metadata:
       encoder         : Lavc58.68.102 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   15 fps=0.0 q=0.0 size=       6kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   27 fps= 26 q=0.0 size=       6kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   39 fps= 25 q=0.0 size=       6kB time=00:00:00.00 bitrate=N/A speed=   0x    


More information about the ffmpeg-user mailing list