Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#7180 closed defect (invalid)

Encoding to H.265 produces washed out colors

Reported by: Martin M. Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I have a H.264 encoded video and want to re-encode it to H.265. The resulting colors are washed out, i.e. blacks become lighter. Probably something to do with the color range? I tried VLC 2.2.6 and MPC-HC 1.7.13 in Windows 10 1709.

> ffmpeg -i input.mp4 -c:v libx265 -an output.mp4
ffmpeg version N-90908-g0807a77160 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 18.100 / 56. 18.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.1.100
  Duration: 00:00:07.69, start: 0.000000, bitrate: 9074 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080, 9063 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: mp3 (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
[swscaler @ 000001fad3877740] deprecated pixel format used, make sure you did set range correctly
x265 [info]: HEVC encoder version 2.7+336-07defe235cde
x265 [info]: build info [Windows][GCC 7.3.0][64 bit] 8bit+10bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-28.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 rskip signhide tmvp strong-intra-smoothing
x265 [info]: tools: lslices=6 deblock sao
Output #0, mp4, to 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.13.100
    Stream #0:0(eng): Video: hevc (libx265) (hev1 / 0x31766568), yuv420p, 1920x1080, q=2-31, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.19.100 libx265
frame=  191 fps=6.3 q=-0.0 Lsize=    1578kB time=00:00:07.52 bitrate=1719.5kbits/s speed=0.249x
video:1573kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.327104%
x265 [info]: frame I:      1, Avg QP:28.32  kb/s: 4202.60
x265 [info]: frame P:     44, Avg QP:27.46  kb/s: 2913.61
x265 [info]: frame B:    146, Avg QP:31.75  kb/s: 1299.09
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 2.2% 2.2% 4.4% 51.1% 40.0%

encoded 191 frames in 30.17s (6.33 fps), 1686.22 kb/s, Avg QP:30.74
> ffprobe -v verbose input.mp4
ffprobe version N-90908-g0807a77160 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 18.100 / 56. 18.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[h264 @ 000001f046b0f740] Reinit context to 1920x1088, pix_fmt: yuvj420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.1.100
  Duration: 00:00:07.69, start: 0.000000, bitrate: 9074 kb/s
    Stream #0:0(eng): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuvj420p(pc, left), 1920x1080 (1920x1088), 9063 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: mp3 (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
> ffprobe -v verbose output.mp4
ffprobe version N-90908-g0807a77160 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 18.100 / 56. 18.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.13.100
  Duration: 00:00:07.64, start: 0.000000, bitrate: 1692 kb/s
    Stream #0:0(eng): Video: hevc (Main), 1 reference frame (hev1 / 0x31766568), yuv420p(tv, progressive), 1920x1080, 1687 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler

Change History (10)

comment:1 by Carl Eugen Hoyos, 7 years ago

Is the issue also reproducible with ffplay?
Is the issue also reproducible if you re-encode the output file to h.264?
Please provide an input file.

in reply to:  1 ; comment:2 by Martin M., 7 years ago

Is the issue also reproducible with ffplay?

ffplay plays input.mp4 with the same washed out colors of output.mp4.

Is the issue also reproducible if you re-encode the output file to h.264?

Yes, h.264->h.265->h.264 shows same results as only encoding to h.265.

I'm now thinking that it could be a player problem, but what I don't understand is why input.mp4 has normal colors in VLC/MPC-HC but not in output.mp4. Although... now I'm starting to think that the washed out colors might be the normal ones and VLC/MPC-HC are reading something wrong in input.mp4 that somehow ffmpeg fixes...? I don't know anymore.

Please provide an input file.

Following the instructions on wiki:WikiStart I uploaded it to the VideoLAN File Uploader, with description "input.mp4" file for ffmpeg ticket #7180, called ticket_7180_input.mp4 and has 19,707,503 bytes. I hope that works for you. If not, please tell me and I'll find another way.

in reply to:  2 comment:3 by Carl Eugen Hoyos, 7 years ago

Replying to martinml:

Is the issue also reproducible with ffplay?

ffplay plays input.mp4 with the same washed out colors of output.mp4.

Do I understand correctly that if there is a bug then it is not related to H.265 encoding but to the decoding of your input sample?

comment:4 by Carl Eugen Hoyos, 7 years ago

I forgot: How did you create the input sample?

in reply to:  4 comment:5 by Martin M., 7 years ago

Replying to cehoyos:

Do I understand correctly that if there is a bug then it is not related to H.265 encoding but to the decoding of your input sample?

My initial guess was something to do with H.265 because if I reencoded the file from H.264 to H.264 the colors didn't change. However, a bug related to the decoding also might make sense. But I'm afraid I don't have the knowledge to answer that question, I'm sorry.

Replying to cehoyos:

I forgot: How did you create the input sample?

I just removed the audio because it was not relevant and saved some size: ffmpeg -i input.mp4 -c:v copy -an. I don't have info about the creation of the original input.mp4, it seemingly was created with ffmpeg but I don't know more about it. Before that, it originally came from a DSLR camera, probably a Canon EOS 7D.

comment:6 by Carl Eugen Hoyos, 7 years ago

Please provide the original file, if there is a bug, it is related to reading the original file and cannot be fixed by changing the way the remuxed file is read.

comment:7 by Carl Eugen Hoyos, 7 years ago

To shorten this discussion a little:
What colour do you think is the dress of the lady with the multi-coloured (white, gray, red) sport-shoes supposed to be? Gray or black?
What colour is the right "under-sleeve" of the man with the laptop and the white "over-shirt" supposed to be? Green or black-green?
Looking at the red car on the right and the red (Hello Kitty?) logo on the left and the green logo in the middle of the screen, I suspect that the "washed out" colours are actually correct.
And please look at the faces!

I'll attach two png files: Is washed.png what you see after re-encoding with FFmpeg and is dark.png what you originally expected?

comment:9 by Martin M., 7 years ago

Resolution: invalid
Status: newclosed

I asked for the original file from the camera and played it on mpv and ffplay. Both colors were identical to washed.png, while MPC-HC and VLC showed it like dark.png. So it was a subjective thing on my part and 'washed out' colors have to be the good ones, like you suspected.

It was a player issue with the original file then! Thank you very much for your time and helping triaging this. I'll mark the ticket as invalid I guess :)

comment:10 by Carl Eugen Hoyos, 7 years ago

Thank you for the confirmation!
(I found some pages explaining that the Canon records in full range which is what the j in yuvj420p stands for and which is a little unusual for both H.264 and HEVC - but specified.)

Note: See TracTickets for help on using tickets.