[FFmpeg-user] h264 lossless grayscale

Marco Porsch m.porsch at intenta.de
Thu Apr 23 10:54:11 CEST 2015


Hi,

when encoding an 8bit grayscale video using the commandline
# ffmpeg.exe -f rawvideo -vcodec rawvideo -pix_fmt gray -s 1280x960 -r 30 -i out8.yuv -c:v libx264 -qp 0 -preset ultrafast -y out8.mkv
and decoding using
# ffmpeg.exe -i out8.mkv -f rawvideo -c:v rawvideo -pix_fmt gray -y out8_decoded.yuv
I get two bit-identical .yuv files. Correct.

When doing the same with a 16bit grayscale video using the command lines
# ffmpeg.exe -f rawvideo -vcodec rawvideo -pix_fmt gray16le -s 1280x960 -r 30 -i out16.yuv -c:v libx264 -qp 0 -preset ultrafast -y out16.mkv
# ffmpeg.exe -i out16.mkv -f rawvideo -c:v rawvideo -pix_fmt gray16le -y out16_decoded.yuv
the resulting files are not identical.

Any explanation for this behavior? Am I doing something wrong?

Best regards,
--Marco


D:\Users\Porsch\Develop\LoggingApp\tools\build\vs12\dl4log_mux>d:\Tools\ffmpeg-20150109-git-d1c6b7b-win32-shared\bin\ffm
peg.exe -f rawvideo -vcodec rawvideo -pix_fmt gray -s 1280x960 -r 30 -i out8.yuv -c:v libx264 -qp 0 -preset ultrafast -y
 out8.mkv
ffmpeg version N-68976-gd1c6b7b Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan  9 2015 02:48:53 with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth
--enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --e
nable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
 --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enabl
e-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-li
bvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-l
ibwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib

  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  6.100 /  5.  6.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[rawvideo @ 00621540] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'out8.yuv':
  Duration: 00:00:21.67, start: 0.000000, bitrate: 294911 kb/s
    Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 1280x960, 294912 kb/s, 30 tbr, 30 tbn, 30 tbc
[swscaler @ 00626060] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0093cfe0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0093cfe0] profile High 4:4:4 Predictive, level 3.2, 4:4:4 8-bit
[libx264 @ 0093cfe0] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.or
g/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1
trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0
nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0
 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to 'out8.mkv':
  Metadata:
    encoder         : Lavf56.18.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p(pc), 1280x960, q=-1--1, 30 fps, 1k tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.20.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=  650 fps=270 q=-1.0 Lsize=  214186kB time=00:00:21.66 bitrate=80981.0kbits/s
video:214180kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.002993%
[libx264 @ 0093cfe0] frame I:3     Avg QP: 0.00  size:615134
[libx264 @ 0093cfe0] frame P:647   Avg QP: 0.00  size:336127
[libx264 @ 0093cfe0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0093cfe0] mb P  I16..4:  0.2%  0.0%  0.0%  P16..4: 99.6%  0.0%  0.0%  0.0%  0.0%    skip: 0.2%
[libx264 @ 0093cfe0] coded y,u,v intra: 78.3% 0.0% 0.0% inter: 99.1% 0.0% 0.0%
[libx264 @ 0093cfe0] i16 v,h,dc,p: 26% 13% 37% 23%
[libx264 @ 0093cfe0] kb/s:80979.61


D:\Users\Porsch\Develop\LoggingApp\tools\build\vs12\dl4log_mux>d:\Tools\ffmpeg-20150109-git-d1c6b7b-win32-shared\bin\ffm
peg.exe -i out8.mkv -f rawvideo -c:v rawvideo -pix_fmt gray -y out8_decoded.yuv
ffmpeg version N-68976-gd1c6b7b Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan  9 2015 02:48:53 with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth
--enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --e
nable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
 --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enabl
e-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-li
bvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-l
ibwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib

  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  6.100 /  5.  6.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from 'out8.mkv':
  Metadata:
    ENCODER         : Lavf56.18.100
  Duration: 00:00:21.67, start: 0.000000, bitrate: 80984 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuvj444p(pc), 1280x960, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 6
0 tbc (default)
    Metadata:
      ENCODER         : Lavc56.20.100 libx264
[swscaler @ 024159e0] deprecated pixel format used, make sure you did set range correctly
Output #0, rawvideo, to 'out8_decoded.yuv':
  Metadata:
    encoder         : Lavf56.18.100
    Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 1280x960 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 30 fps, 30 tbn
, 30 tbc (default)
    Metadata:
      encoder         : Lavc56.20.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=  650 fps=355 q=0.0 Lsize=  780000kB time=00:00:21.66 bitrate=294912.0kbits/s
video:780000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%


D:\Users\Porsch\Develop\LoggingApp\tools\build\vs12\dl4log_mux>d:\Tools\ffmpeg-20150109-git-d1c6b7b-win32-shared\bin\ffm
peg.exe -f rawvideo -vcodec rawvideo -pix_fmt gray16le -s 1280x960 -r 30 -i out16.yuv -c:v libx264 -qp 0 -preset ultrafa
st -y out16.mkv
ffmpeg version N-68976-gd1c6b7b Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan  9 2015 02:48:53 with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth
--enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --e
nable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
 --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enabl
e-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-li
bvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-l
ibwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib

  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  6.100 /  5.  6.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[rawvideo @ 01cf2080] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'out16.yuv':
  Duration: 00:00:21.67, start: 0.000000, bitrate: 589823 kb/s
    Stream #0:0: Video: rawvideo (Y1[0][16] / 0x10003159), gray16le, 1280x960, 589824 kb/s, 30 tbr, 30 tbn, 30 tbc
[swscaler @ 01cf61c0] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0071d140] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0071d140] profile High 4:4:4 Predictive, level 3.2, 4:4:4 8-bit
[libx264 @ 0071d140] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.or
g/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1
trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0
nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0
 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to 'out16.mkv':
  Metadata:
    encoder         : Lavf56.18.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p(pc), 1280x960, q=-1--1, 30 fps, 1k tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.20.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=  650 fps=189 q=-1.0 Lsize=  215181kB time=00:00:21.66 bitrate=81357.1kbits/s
video:215175kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.002979%
[libx264 @ 0071d140] frame I:3     Avg QP: 0.00  size:632797
[libx264 @ 0071d140] frame P:647   Avg QP: 0.00  size:337620
[libx264 @ 0071d140] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0071d140] mb P  I16..4:  0.2%  0.0%  0.0%  P16..4: 99.8%  0.0%  0.0%  0.0%  0.0%    skip: 0.0%
[libx264 @ 0071d140] coded y,u,v intra: 78.2% 0.0% 0.0% inter: 99.9% 0.0% 0.0%
[libx264 @ 0071d140] i16 v,h,dc,p: 25% 14% 37% 24%
[libx264 @ 0071d140] kb/s:81355.77


D:\Users\Porsch\Develop\LoggingApp\tools\build\vs12\dl4log_mux>d:\Tools\ffmpeg-20150109-git-d1c6b7b-win32-shared\bin\ffm
peg.exe -i out16.mkv -f rawvideo -c:v rawvideo -pix_fmt gray16le -y out16_decoded.yuv
ffmpeg version N-68976-gd1c6b7b Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan  9 2015 02:48:53 with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth
--enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --e
nable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
 --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enabl
e-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-li
bvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-l
ibwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib

  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  6.100 /  5.  6.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from 'out16.mkv':
  Metadata:
    ENCODER         : Lavf56.18.100
  Duration: 00:00:21.67, start: 0.000000, bitrate: 81360 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuvj444p(pc), 1280x960, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 6
0 tbc (default)
    Metadata:
      ENCODER         : Lavc56.20.100 libx264
[swscaler @ 00555a00] deprecated pixel format used, make sure you did set range correctly
Output #0, rawvideo, to 'out16_decoded.yuv':
  Metadata:
    encoder         : Lavf56.18.100
    Stream #0:0: Video: rawvideo (Y1[0][16] / 0x10003159), gray16le, 1280x960 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 30 fp
s, 30 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc56.20.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=  650 fps=128 q=0.0 Lsize= 1560000kB time=00:00:21.66 bitrate=589824.0kbits/s
video:1560000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%


More information about the ffmpeg-user mailing list