Press "Enter" to skip to content

Posts published in “Photography”

Apple ProRes 实战分析 | 码率 | 压缩比 | 信噪比

ProRes是苹果推出的一组有损视频编码格式,经常用作视频剪辑时候的中间编码。现在也有不少相机提供机内录制ProRes的选项。

ProRes优点有

  • All-Intra/帧内编码(每一帧都是独立压缩)
  • 编解码效率高(使用硬件加速的情况下)
  • 全线支持10bit 422(也有444和4444的选项)
  • 可变码率(”简单”的画面压缩比高)

当然一切都是有代价的,All-Intra就意味着在相同画质的情况下,码率会比LongGOP帧间编码(H.265 / HEVC)高不少。好在ProRes提供了一些预设来满足不同的画质/码率需求,码率从高到低分别是:

  • HQ (High Qaulity) 高画质
  • ST (Standard) 标准
  • LT (Light) 轻量级
  • Proxy 代理

接下来我们就来一起看下不同预设在不同场景下的表现。

测试环境和方法:由于ProRes是All-Intra的,所以拿照片和视频得到的结论是一样的,为了方便起见我就都用单张照片来进行测试。

照片是RAW转16bit TIFF,3840×2160,再用ffmpeg压缩成ProRes 30fps,编码器使用的是Mac上的硬件编码器prores_videotoolbox,默认参数。硬件编码器的画质肯定不如CPU编码,但速度要快上好几个数量级。

首先出场的是最难压缩的东西:噪声,来测试一下ProRes码率的上限和画质的下限。

Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 941.82 5.04 13.86
ST 647.12 7.33 13.07
LT 373.77 12.70 12.71
PROXY 143.35 33.11 12.69

首先我们看到的是PSNR惨不忍睹,就算HQ的码率高达942Mbps,信噪比也不到14,信噪比随着码率下降而下降,不过不到1dB。

接下来看一下风光照,一般光圈比较小,场景中有大量的纹理细节。

Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 872.01 5.44 41.67
ST 570.42 8.32 38.96
LT 394.29 12.04 36.36
PROXY 175.28 27.08 31.72

这个时候就很明显的看到各档拉出了明显的差距,信噪比从最高的HQ的近42dB,慢慢降低到Proxy的32dB。但就算全屏观看(不放大),Proxy的画质也相当能打了。30dB是”高画质”底线。

再看另一张,无论是码率还是信噪比都惊人的接近。

Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 882.20 5.38 41.47
ST 568.93 8.34 39.06
LT 398.37 11.91 36.25
PROXY 178.90 26.53 30.82

之前的强度太强了,我们来一个easy case。有大量平滑色块和很强的背景虚化的照片,这种就属于比较容易压缩的。

Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 749.11 6.34 48.48
ST 555.70 8.54 47.95
LT 386.50 12.28 47.27
PROXY 93.45 50.79 45.73

对于简单场景,连Proxy都拿到了近46dB的PSNR,拉不开差距,而且各档码率都下降了不少。

人像

接着我们来看几张人像,结果介于风光和简单场景之间。

Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 852.40 5.57 43.33
ST 568.61 8.35 42.58
LT 372.84 12.73 41.47
PROXY 157.54 30.13 39.78
Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 886.42 5.35 39.72
ST 553.79 8.57 39.55
LT 350.24 13.55 39.24
PROXY 188.87 25.13 38.58
Profile Bitrate (Mbps) Compression Ratio PSNR
HQ 850.07 5.58 34.12
ST 537.04 8.84 34.06
LT 392.76 12.08 34.00
PROXY 160.87 29.50 33.77

不知道为什么对于一些人像照片来说,各个档位拉不开差距。还用什么HQ,直接Proxy得了。

总结

Profile 4K 30fps
Bitrate (Mbps)
4K 60fps
Bitrate (Mbps)
Compression Ratio Avg
PSNR
HQ 880.00 1760.00 5.39 40.06
ST 570.00 1140.00 8.33 38.84
LT 400.00 800.00 11.87 37.46
PROXY 180.00 360.00 26.37 34.94

ProRes HQ/ST虽然画质不错,但仅有5-8的压缩比做为录制编码来说码率太高了,不太实用,要知道NRAW压缩比也在5左右。ProRes LT压缩比为12:1左右,4K30 “仅需” 400Mbps,在码率和画质上取得一个不错的平衡点。但4K 60码率就翻倍了达到800Mbps。这也算是All-intra的一个弊端了,码率和帧率成正比, 即便是ProRes LT 4K 120fps也要1600Mbps。Proxy可以提供30:1的压缩比,4K 60也就360Mbps,都和H.265差不多了,平均35的PSNR估计是要比H.265低一些, 不过对于一般的情况来说也够用了。希望相机厂商能提供更多的ProRes编码选项,其实也就是几组参数的事情。个人希望加一个Proxy的高码率版,压缩比20:1左右,4K 60 475Mbps左右,V60的SD就行了,那就非常Nice了。

想当年,JPEG以8:1~12:1的压缩比傲视群雄,我的第一台单反D90就能拍摄720p的MJPEG,同样也是All-Intra,720p超过25Mbps的码率(压缩比13.5:1) 在当时来说高的吓人。但仅从画质上来讲,ProRes系列并没有比(目前最好的)MJPEG好多少。毕竟帧内压缩是有极限的,个人感觉40:1 – 50:1估计到头了。AI超分+帧生成或许是以后的发展方向,码率降到1/16不是梦。

Nikon Z8/Z9 HLG Deepdive | HLG 详解 VS N-LOG

网上关于HLG的资料相对来说还是比较匮乏的,更别说是针对Nikon Z系列了。之前做过一期简单的HLG直出视频,但是没人感兴趣…

首先HLG是一条用于交付的Gamma曲线,向下兼容SDR内容,这也就注定了它的上限比较低,这也是为什么大部分人对它不感兴趣的原因(另一个原因是它是HDR)。HLG的动态范围(尤其高光)比不过N-LOG,更别说Slog3了。暗部表现则比其他LOG曲线要好一些。它最大的优点就是所见即所得,不需要LUT还原,也(基本)不需要向右曝光,特别适合HDR直出。不过如果你只做SDR的话,还是选N-LOG吧。只是2025年了,拍N-LOG/NRAW获得12+档动态范围,然后再压缩到8档,我只能说历史的包袱太沉重了。可以参见:再谈苹果XDR显示器与HDR之殇

响应曲线

我在Z8上实测响应曲线,测试方法:调整曝光,记录不同曝光值下中灰的IRE,并和理论值做对比。为了统一起见,我将中灰(Stop 0)都曝光到36%。Note: HLG中灰的理论值应该是38%,不过差别不大,大概0.2档左右。结果实测N-LOG的时候,同样用了95 (37.2%)的斑马线,最后得到的曝光是38%,不管了,差不多就行了。

Z8 HLG实测曲线和理论曲线在[-7, +3]的范围内贴合的非常不错。实测的HLG底噪大约是3%,。两者在高光部分差别比较大,HLG中灰以上一档就开始变成对数曲线,和Stops应该是线性关系,但实测下来,Nikon对+3档以上的高光做了一些保护,曲线非常平滑,因此也比理论多了1档的高光,中灰以上5.3档才会完全过曝。 但比起N-LOG还是差了一档多。另外HLG模式下,IRE最大值不是100,而是97左右,斑马线需要设置在245才会有效果。

N-LOG的曲线大致上贴合的还是不错的。noise floor,13%左右。-7档开始就贴着了。只有在+1档到+2档的附近有点波动。高光部分的斜率还是太大了,竟然比理论值还大一些。中灰以上6档就过曝了。只比HLG好了不到1档。

名义ISO

众所周知,N-LOG的基础ISO是800,第二档则是ISO 4000。HLG的基础ISO是400,第二档是ISO 2000。无论是N-LOG还是HLG,它们的ISO都是名义ISO,或者说等效ISO。在相同照度下,我使用相同的参数(1/400s F/4 ISO800)拍摄灰卡,N-LOG和HLG的IRE是36%左右,SDR则为52%。三者还原之后中灰的亮度大体上相同(SDR稍微亮了一点),证实了”名义”ISO。但实际上传感器使用的ISO是多少呢?其实都是ISO 100左右,如何证明呢?拍摄同样的白卡,记录刚刚过曝时的曝光参数。
N-LOG: 1/30s F/4 ISO 800
HLG: 1/30s F/4 ISO 400
SDR: 1/30s F/4 ISO 80 (NL profile, Active D-lighting off)
进光量相同,传感器同时过曝了,表明实际ISO是相同的。
等效ISO也可以这么理解:
N-LOG拍摄时欠曝3档,后期还原时把中灰提亮3档,以起到保护高光的目的。
HLG拍摄时欠曝2档,后期还原时把中灰提亮2档,以起到保护高光的目的。
这也就是为什么按照标准曝光(将中灰曝到36% IRE),N-LOG暗部噪点爆炸,需要使用向右曝光的原因之一。
HLG则相当于找了一个平衡点,欠曝2档,等效于使用ISO 400拍视频,对于全画幅来说勉强可以接受吧。

HLG quality 设置

由于是面向直出的交付曲线,只有H.265编码支持HLG。虽然Nikon贴心的提供了HLG质量选项,但这里有个坑,在默认的设置下,相机是会对HLG的画面进行锐化的,导致使用超级锐的Z卡扣镜头时会产生过度锐化的情况。需要将Quick Sharp设置成-1才能获得未锐化的画面。有需要的话,也可以将对比度和饱和度也降低一些,推荐-1。

不同Quick Sharp模式下的波形图

调整对比度

调整饱和度

Why SDR looks so good on Apple’s XDR display that even shadows HDR?

Apple released their Apple Sillicon based Macbook Pro in October 26, 2021 which includes a new MicroLED display which they call XDR with a peak brightness of 1600 nits. Three years later, it’s still one of the best display for both SDR and HDR content consuming and creation. However, SDR content looks so good on the new XDR displays, sometime I even think that they were HDR content. Why is that? Let us figure out together.

Presets

The new XDR display includes a few presets:

  • Apple XDR Display (P3-1600 nits)

The default one for daily usage which has a peak brightness of 1600 nits for HDR content and 500 nits for SDR / UI.

  • Apple Display (P3-500 nits)

Peek brightness of 500 nits.

  • HDR Video (P3-ST 2084)

HDR reference mode. Can not adjust the brightness which peaks at ~1000 nits for HDR content and ~100 nits for SDR content / UI.

  • HDTV Video (BT.709 – BT.1886)

SDR reference mode. Can not adjust the brightness which peaks at ~100 nits for all content and UI.

500 nits for SDR?

Apple has been using 500 nits for SDR / UI for a very long time. Wait, shouldn’t SDR be 100 nits max? Yes, in theory and in some reference modes. Morden displays have a peak brightness of 300+ nits, not to mention the latest M4 iPad Pro that has a peak brightness of 1000 nits for SDR!!! In today’s standard, 100 nits is too dark to watch even in normally lit indoor environment.

Let’s see how Apple displays SDR content in their XDR displays:

Setup: I created a video with a black square and incrased IRE value of it until it becomes white in Rec. 709 colorspace / gamma. Then used a SM208 screen luminance meter to measure the brightness of the XDR display under different presets.

Here’re curves of screen brightness v.s Rec. 709 IRE values:

After the test, I found that Apple XDR Display (P3-1600 nits) and Apple Display (P3-500 nits) have the same response curve for SDR content, so only drew one line here. They (the red curve) peaked around 450 nits, close to claimed 500 nits (my screen might be degraded a bit after two and half years), middle gray (~40% IRE) is aboud 77 nits, black (0% IRE) is 0.05 nits.

In SDR reference mode (HDTV BT.709-BT.1886 preset), the blue curve, peek brightness is 94 nits, very close to the 100 nits for SDR. Middle gray is a little bit darker at 11 nits, black (0% IRE) is all the way down to 0.02 nits!

I also plot a Gamma 2.4 curve for a 100 nits reference monitor (the yellow curve), you can see that it overlaps well with the SDR reference mode for bright part (60%+ IRE), it lays in between of two modes, its dark region (<1 IRE%) is brighter than both modes and will be even brighter on a real CRT monitor that the SDR standard was designed for.

For comparison, I also measured my BenQ PD3200U which still looks great for most of the SDR content. In sRGB mode, it peaks at 350 nits, the 1% IRE signial is clearly visible and measured at 0.91 nits, pure black is 0.34 nits, contrast ratio is just over 1000:1, no true black is the major drawback of LCD displays. XDR is brighter for the highlights and darker in the shadows.

The curve itself explains why properly graded SDR (Rec. 709) content looks so good in Apple’s XDR Displays: it tracks the gamma curve pretty well for the most part (30%+ IRE), pure white is very bright (450+ nits), and pure black is very dark (0.05 nits), the constrat ratio is around 9000:1 (13+ stops dynamic range).

What about HDR?

I did a similar test for HDR, using ITU-R BT.2100 (HLG) gamma. Here’re the results:

Let’s first look at the HDR reference mode (HDR Video P3-ST2048 preset), the yellow curve, it tracks the HLG curve very well, it’s a straight line (in log scale) after 50% IRE. HDR reference mode peaks at 881 nits (100% IRE), diffuse white 183 nits (75% IRE), both are a little bit darker than the reference values which is 1000 nits and 203 nits respectfully, middle gray is accurate though, around 26 nits (38% IRE), black is 0.02 nits! (0% IRE), It gives us a contrast ratio of ~44000:1, 15 stops+ dyanmic range.

The XDR mode (red curve) is always brighter comparing to the HDR reference mode: 2+ stops in black and deep shadows (0 ~ 10% IRE), 1+ stops (10% ~ 85% IRE) for most of the part and < 1 stops for highlights (85%+ IRE), it curved / saturated after 95% IRE, and peeked at 1450 nits! (100% IRE) , diffuse white 410 nits (75% IRE), close to white in SDR/UI (which is 450 nits), middle gray is around 68 nits (38% IRE), a little bit darker than SDR mode, black is 0.03 nits (0% IRE). It gives us a contrast ratio of ~50000:1, also 15 stops+ dyanmic range.

HLG as a backward compatible curve, I also tested the Apply Display 500 nits mode (the blue curve), it lays between XDR and HDR reference mode for the most of the part and clipped after 90% IRE with a peek brightness of 450 nits (same for SDR content), diffuse white is 219 nits (75% IRE), middle gray is 38 nits (38% IRE) and black is 0.04 nits (0% IRE).

PQ is another story

The HDR reference mode tracks the PQ curve perfectly, it’s a straight line from 0 to 1000 nits and clipped after that.

Both 1600-nits and 500-nits mode didn’t do a good job, they are one stop brighter for shadows and then gradually curved.

Conclusion

Apple’s XDR Display is fantastic, very good in SDR mode: 450+ nits peak brightness, true blacks, 13+ stops of dyanmic range put a lot of “HDR displays” to a shame. You can definitly call it HDR since 100-nits-max, 200:1 constrat ratio SDR is dead for many years. HDR content in XDR mode is also great with a peak brightness of 1450+ nits, 15+ stops dynamic range. However, highlights is only 1.7 stops brighter than UI/SDR white. Idealy, highlights should be at least 3 stops brighter than diffuse white, since people is alreay used to have 500 nits for UI/SDR white, then a 4000+ nits peak brightness display is needed. Setting diffuse white to 203 nits (recommended for HLG masted at 1000 nits), the requirement drops to 1600 nits (it’s not a coincidence), however, (diffuse) white will looks gray since it’s 1.3 stop darker than UI.

I know it’s xxx nits everywhere since human eyes are much more sensitive in luminance than in colors and a lot of “HDR” content are way over saturated!

Nikon Z8 HLG / N-Log Stops vs IRE

Recently I switched from N-RAW to H.265 / HLG for quicker HDR workflow in Final Cut Pro, basically just drop the clips in a HLG timeline and that’s it, just like the iPhone’s Dolby Vision (HLG HDR) footage.

I did some test about IRE vs stops in HLG mode and compared that to the theoretical N-Log curve.

Setup: I expouse the 18% midgray to 36% IRE in HLG mode to match that with N-Log. Adjust the exposure time first then aperture, ISO to over and under expose the midgray for IRE readings.

Note: Techincally, you should expose midgray to 38% IRE in HLG mode (ref), diffuse white will be around 75% IRE, 75%+ is for specular highlights (0~3 stops over diffuse white).

Stops vs IRE

First of all, we can see that HLG curve is more contrastive than N-Log. Highlights will be clipped after 5 stops over midgray which I think is OK for a lot of scences. N-Log retains more infornation in the highlights (if not over-exposed) up to 6.3 stops at the cost of noiser shadows. HLG has more detials in the shadow area, noise floor is about 2% at ISO 400 (12.5% for N-Log).

Another thing intresting is that the HLG curve is very steep from -1 to +3 stops but quickly saturated afterwards (non-linear anymore), highlights are compressed and will clipped around 96% IRE, making sure to set the high zebra to 245 when shooting HLG.

Base ISO for HLG and N-Log

Nikon Z8’s HLG has a “nominal” base ISO 400. Under the hood, the sensor is working at ISO 100, shadows will be boosted by 2 stops while highlights will be intact, bascially you are shooting at ISO 100 with 2 stops under to protect highlights.

N-Log has a “nominal” base ISO 800. Same as HLG, the sensor is working at ISO 100, shadows will be boosted by 3 stops while highlights will be intact, bascially you are shooting at ISO 100 with 3 stops under to protect highlights. However, you will see a lot of noise in shadow area due to insufficient light and 1.3 ~ 1.7 stops “over-exposure” is usually needed to compensate that to get clean image.

Consolution

HLG has a pretty good balance between highlights and shadows, very user friendly for HDR workflow. Unlike N-Log, there is no need to over-expose (even 1 stop under looks good to me), no camera LUT needed for restoration, zero or minimum color grading needed. Another advantage of HLG over N-Log is monitoring, most of the time you can rely on the screen/viewfinder (with zebra on) to adjust the exposure and only open the waveform if needed.

Nikon Z8/Z9 Video Format / Bitrate / Compression ratio | NRAW | ProRes | ProRes RAW | H.265

The Nikon official site didn’t provide the birate for ProRes / ProRes RAW, I did some test my self, here’re the results. I only tested fullframe (FX) in ~4K resolution.

ProRes Raw 12Bit

Resolution / FPSBitrate (Mbps)Compression Ratio
4140 x 2330 60p33501.977
4140 x 2330 50p28101.964
4140 x 2330 30p16202.044
4140 x 2330 25p13602.029
4140 x 2330 24p12802.070

ProRes Raw has a very low compression ratio of 2, which suggests that it might be lossless compressed, which takes more spaces than Nikon’s lossy N-RAW, 2.5x of the high quality and 4.5x of the normal quality!

ProRes HQ 422 10Bit

Resolution / FPSBitrate (Mbps)Compression Ratio
3840 x 2160 60p18005.273
3840 x 2160 50p15005.273
3840 x 2160 30p9105.215
3840 x 2160 25p7605.204
3840 x 2160 24p7305.201

With compression ratio of 5.2, ProRes is still 2x the size of the normal quality n-raw! Though the former one has 1.5x number of pixels to deal with (YUV422 vs Bayer).

I hope Nikon could provide more options for ProRes via firmware updates. A 10x~12x compression ratio version (ProRes LT 422) will be very useful to balance between quality and disk space.

H.265 420 10 bit

Resolution / FPSBitrate (Mbps)Compression Ratio
7680 x 4320 30p40047.461
7680 x 4320 25p40039.551
7680 x 4320 24p40037.969
3840 x 2160 120p40047.461
3840 x 2160 100p40039.551
3840 x 2160 60p34027.918
3840 x 2160 50p34023.265
3840 x 2160 30p19024.979
3840 x 2160 25p19020.816
3840 x 2160 24p19019.984

For H.265, there is no option for all-intra, and only in 420. Compression ratio is much higher given long GOP. One thing to note, that bitrate is variable depend on the content, i.e. very dark scene will have a much lower bitrate (<100Mbps for 4K60).

NRAW High Quality 12 bit

Resolution / FPSBitrate (Mbps)Compression Ratio
8256 x 4644 60p57804.555
8256 x 4644 50p48104.561
8256 x 4644 30p28904.555
8256 x 4644 25p24104.552
8256 x 4644 24p23104.559
4128 x 2322 120p38403.428
4128 x 2322 100p29003.783
4128 x 2322 60p17403.783
4128 x 2322 50p14503.783
4128 x 2322 30p8703.783
4128 x 2322 25p7303.757
4128 x 2322 24p7003.761

First of all, given 4.5 compression ratio, NRAW is definitely a lossy codec. Interesting thing is that 8K’s compression ratio is higher than 4K’s. 4.5 vs 3.7.

NRAW Normal Quality 12 bit

Resolution / FPSBitrate (Mbps)Compression Ratio
8256 x 4644 60p34707.587
8256 x 4644 50p28907.591
8256 x 4644 30p17407.565
8256 x 4644 25p14507.565
8256 x 4644 24p13907.576
4128 x 2322 120p17507.522
4128 x 2322 100p14607.513
4128 x 2322 60p8807.479
4128 x 2322 50p7307.513
4128 x 2322 30p4407.479
4128 x 2322 25p3707.412
4128 x 2322 24p3507.522

For normal quality, the compression ratio is even higher, reaching 7.5:1 which is not bad for all-intra.