4

When I convert an EXR file sequence with x264 using FFmpeg and convert the colorspace from linear to SRGB (with gamma 0.45454545) I get some heavy banding issues (most visible on a dark gradient). For me it looks like it converts the video first and afterwards applies the gamma correction on 8-bit clipped video. If so is it somehow possible to convert the imagesequence from linear to srg first and then convert it into Quicktime?

Here is the ffmpeg command I use:

C:/ffmpeg.exe -y -i C:/seq_v001.%04d.exr -vf lutrgb=r=gammaval(0.45454545):g=gammaval(0.45454545):b=gammaval(0.45454545) -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 18 -r 25 C:/out.mov

Here is the output:

ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 25 2012 12:25:21 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --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
Input #0, image2, from 'C:/seq_v001.%04d.exr':
  Duration: 00:00:09.60, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: exr, rgb48le, 960x540 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0000000004d11540] using SAR=1/1
[libx264 @ 0000000004d11540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0000000004d11540] profile High, level 3.1
[libx264 @ 0000000004d11540] 264 - core 128 r2216 198a7ea - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 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=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'C:/out.mov':
  Metadata:
    encoder         : Lavf54.37.100
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 960x540 [SAR 1:1 DAR 16:9], q=-1--1, 12800 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (exr -> libx264)
Press [q] to stop, [?] for help
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
frame=   16 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    
Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
frame=   34 fps= 33 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    
Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
frame=   52 fps= 34 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    
Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
frame=   68 fps= 34 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    
Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
frame=   85 fps= 33 q=23.0 size=      47kB time=00:00:00.44 bitrate= 867.5kbits/s    
Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
frame=  104 fps= 34 q=23.0 size=      94kB time=00:00:01.20 bitrate= 640.3kbits/s    
Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
frame=  121 fps= 34 q=23.0 size=     133kB time=00:00:01.88 bitrate= 577.8kbits/s    
Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
frame=  139 fps= 34 q=23.0 size=     172kB time=00:00:02.60 bitrate= 543.4kbits/s    
Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
frame=  157 fps= 34 q=23.0 size=     213kB time=00:00:03.32 bitrate= 525.6kbits/s    
Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
frame=  175 fps= 34 q=23.0 size=     254kB time=00:00:04.04 bitrate= 516.0kbits/s    
Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
frame=  193 fps= 35 q=23.0 size=     287kB time=00:00:04.76 bitrate= 494.6kbits/s    
Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
frame=  211 fps= 35 q=23.0 size=     332kB time=00:00:05.48 bitrate= 496.4kbits/s    
Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
frame=  228 fps= 34 q=23.0 size=     421kB time=00:00:06.16 bitrate= 559.8kbits/s    
frame=  240 fps= 32 q=-1.0 Lsize=     708kB time=00:00:09.52 bitrate= 609.3kbits/s    

video:705kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.505636%
[libx264 @ 0000000004d11540] frame I:2     Avg QP:15.07  size: 18186
[libx264 @ 0000000004d11540] frame P:73    Avg QP:16.51  size:  3719
[libx264 @ 0000000004d11540] frame B:165   Avg QP:18.38  size:  2502
[libx264 @ 0000000004d11540] consecutive B-frames:  2.5%  3.3% 42.5% 51.7%
[libx264 @ 0000000004d11540] mb I  I16..4: 46.2% 33.3% 20.4%
[libx264 @ 0000000004d11540] mb P  I16..4:  6.8%  2.0%  0.6%  P16..4: 29.4% 10.5%  4.6%  0.0%  0.0%    skip:46.1%
[libx264 @ 0000000004d11540] mb B  I16..4:  1.8%  0.7%  0.2%  B16..8: 40.9%  6.5%  0.3%  direct: 1.2%  skip:48.5%  L0:52.0% L1:47.5% BI: 0.5%
[libx264 @ 0000000004d11540] 8x8 transform intra:24.7% inter:81.3%
[libx264 @ 0000000004d11540] direct mvs  spatial:93.3% temporal:6.7%
[libx264 @ 0000000004d11540] coded y,uvDC,uvAC intra: 10.7% 31.4% 24.9% inter: 2.3% 9.0% 2.9%
[libx264 @ 0000000004d11540] i16 v,h,dc,p: 83% 11%  6%  1%
[libx264 @ 0000000004d11540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9%  9% 52%  6%  4%  4%  5%  5%  5%
[libx264 @ 0000000004d11540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 11% 44%  5%  4%  3%  3%  4%  3%
[libx264 @ 0000000004d11540] i8c dc,h,v,p: 69% 15% 15%  2%
[libx264 @ 0000000004d11540] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000004d11540] ref P L0: 48.9%  0.1% 16.8% 17.0% 11.3%  5.8%
[libx264 @ 0000000004d11540] ref B L0: 57.7% 21.9% 13.9%  6.4%
[libx264 @ 0000000004d11540] ref B L1: 82.4% 17.6%
[libx264 @ 0000000004d11540] kb/s:600.61

Does someone have an idea where to start?

8
  • Please provide a sample input exr frame.
    – llogan
    Apr 22, 2014 at 17:49
  • The gamma correction should not be the issue- it is the bits reduction (truncation?) that seems to be the issue. Losing intermediate values is always a bits issue.
    – Rajib
    Apr 23, 2014 at 12:56
  • Not sure whether x264 can handle 32bit floating point- I was under the impression that it can only handle up to 10 bits- but I may be wrong.
    – Rajib
    Apr 23, 2014 at 13:04
  • @slhck I have tried with a newer version aswell and runned into the same problems do you want me to upload the output? Apr 23, 2014 at 14:58
  • @LordNeckbeard Here is a link to a similar exr file which has the same issue when converting to a quicktime: fileswap.com/dl/PRoqQIdpBg And here is the result when i put it through ffmpeg: fileswap.com/dl/2dFwqgnXnc Apr 23, 2014 at 14:59

3 Answers 3

2

Probably a bit late here, but if anyone else has the same issue.

The problem is the gamma correction is applied after the initial exr image has already been loaded. Load the exr with the gamma 2.2 for sRGB and don't gamma correct the output video. Also, quicktime is notorious for wierd gamma shifts so don't use it to play back your videos.

C:/ffmpeg.exe -y -gamma 2.2 -i C:/seq_v001.%04d.exr -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 18 -r 25 C:/out.mov
1
  • This worked for me, thank you very much.
    – ofekp
    Nov 15, 2022 at 23:09
1

Hi dont know if i got it all but did some further testing. I converted a exr with linear space and a exr with srgb space.

The linear i converted with ffmpeg into srgb with the following tag:

-vf lutrgb=r=gammaval(0.45454545):g=gammaval(0.45454545):b=gammaval(0.45454545)

and the result had the banding: enter image description here

The one which already was srgb and did not have the -vf lutrgb tag looked nice: enter image description here

Do you still think the problem is the bits reduction because both source images had exactly the same bit depth? Is there something else i should try which could lead to a solution?

@rajib Dont you think the problem is that the colorspace conversion happens after the bits reduction. And then of course the 8 bit image has not enough information left for the colorspace conversion?

If so is it somehow possible to stack different operations in a given order: 1. Dont change the input bit depth or have it higher than 8 bits 2. Do the gamma lut conversion 3. Reduce the bit depth to 8 bits

0

Possibly you should convert the 32 bit images to lower bits if you wish to use ffmpeg to save a mov file.

Else you are better off using Nuke to render to mov. Nuke is perfectly capable of rendering to mov format, and applying the gamma correction in a grade node will convert from linear space to sRGB. The bits will be also "scaled" down automatically when you save to a 10 bit or 8 bit mov.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .