使用 ffmpeg 将 Exr 文件序列转换为 mov

使用 ffmpeg 将 Exr 文件序列转换为 mov

当我使用 FFmpeg 转换带有 x264 的 EXR 文件序列并将颜色空间从线性转换为 SRGB(伽马值为 0.45454545)时,我遇到了一些严重的带状问题(在深色渐变上最明显)。对我来说,它看起来像是先转换视频,然后在 8 位剪辑视频上应用伽马校正。如果是这样,是否可以先将图像序列从线性转换为 srg,然后再将其转换为 Quicktime?

这是我使用的 ffmpeg 命令:

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

输出如下:

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

有人知道从哪里开始吗?

答案1

可能有点晚了,但如果其他人有同样的问题。

问题是,在初始 exr 图像加载后才应用伽马校正。使用 sRGB 的伽马 2.2 加载 exr,不要对输出视频进行伽马校正。此外,Quicktime 因奇怪的伽马偏移而臭名昭著,因此不要使用它来播放视频。

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

答案2

嗨,我不知道我是否已经全部搞定,但做了一些进一步的测试。我转换了一个具有线性空间的 exr 和一个具有 srgb 空间的 exr。

我使用 ffmpeg 将线性转换为 srgb,并带有以下标签:

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

结果出现了这样的条带: 在此处输入图片描述

已经是 srgb 并且没有 -vf lutrgb 标签的那个看起来不错: 在此处输入图片描述

您是否仍认为问题出在比特减少上,因为两个源图像的比特深度完全相同?我是否应该尝试其他方法来解决?

@rajib 你不觉得问题在于色彩空间转换发生在位数减少之后吗?那么 8 位图像当然没有足够的信息用于色彩空间转换?

如果是这样,是否有可能以给定的顺序堆叠不同的操作:1.不要改变输入位深度或使其高于 8 位 2.进行伽马 lut 转换 3.将位深度降低到 8 位

答案3

如果您希望ffmpeg保存 mov 文件,则可能需要将 32 位图像转换为较低位。

否则,您最好使用Nuke渲染为 mov。Nuke 完全能够渲染为 mov 格式,并且在等级节点中应用伽马校正将从线性空间转换为 sRGB。当您保存为 10 位或 8 位时,位也会自动“缩小” mov

相关内容