hevc_nvenc 详细分析1

压缩

ffmpeg.exe -y -i D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\test_jpg\%05d.jpg -vcodec hevc_nvenc D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\output5.mkv

frame=  819 fps= 73 q=26.0 Lsize=    8178kB time=00:00:32.72 bitrate=2047.5kbits/s speed= 2.9x
video:8172kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.081658%

解压缩

ffmpeg.exe -y -i D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\output5.mkv -vcodec mjpeg D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\test_jpg_by_video\%05d.jpg

frame=  819 fps=103 q=24.8 Lsize=N/A time=00:00:32.76 bitrate=N/A speed=4.11x
video:8978kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

avr_psnr = 35.419837477543155 db

hevc详细参数

-preset

        x265有10个预定义的—预设选项,可以优化编码速度(每秒编码帧数)和压缩效率(比特流中每比特的质量)之间的平衡。越快,是真越多,越慢,数据的质量越高。每一个option的详细参数表如(https://x265.readthedocs.io/en/default/presets.html#presets)

  1. ultrafast
  2. superfast
  3. veryfast
  4. faster
  5. fast
  6. medium (default)
  7. slow
  8. slower
  9. veryslow
  10. placebo

ultrafast编码速度最快,但压缩率低,生成的文件更大,placebo则正好相反。x264所取的默认值为medium。参考了维基百科,需要说明的是,preset预设决定了编码过程的速度 - 以压缩效率为代价。换句话说,如果选择ultrafast,编码过程将快速运行,但与medium相比,文件大小会更大。视觉质量将是相同的。

--profile, 

中文一直不知道怎么翻译,貌似是档次。为了提供不同应用之间的兼容互通,HEVC/H265 定义了不同的编码 Profile 档次、Level 水平、Tier 等级。profile 规定了码流中使用了哪些编码工具和算法

强制执行指定配置文件的要求,确保输出流可由支持该配置文件的解码器解码。如果为编码器选择的编译选项不能支持指定的配置文件,则可以中止编码(高位深度编码器将无法输出符合Main或MainStillPicture的比特流)。

x265支持以下配置文件。

8位配置文件:

* main, main-intra, mainstillpicture (or msp for short)
* main444-8, main444-intra, main444-stillpicture

请参阅下面有关发送内部和静止图像配置文件的注释。

10位配置文件:

* main10, main10-intra
* main422-10, main422-10-intra
* main444-10, main444-10-intra

12位配置文件:

* main12, main12-intra
* main422-12, main422-12-intra
* main444-12, main444-12-intra

hevc_nvenc 详细分析1_第1张图片

从wiki上,看到了HEVC两个版本 的

Feature support in some of the video profiles [13]
Feature Version 1 Version 2
 Main  Main 10 Main 12 Main
4:2:2 10
Main
4:2:2 12
Main
4:4:4
Main
4:4:4 10
Main
4:4:4 12
Main
4:4:4 16
Intra
Bit depth 8 8 to 10 8 to 12 8 to 10 8 to 12 8 8 to 10 8 to 12 8 to 16

Chroma sampling formats(色度

采样格式)

4:2:0 4:2:0 4:2:0 4:2:0/
4:2:2
4:2:0/
4:2:2
4:2:0/
4:2:2/
4:4:4
4:2:0/
4:2:2/
4:4:4
4:2:0/
4:2:2/
4:4:4
4:2:0/
4:2:2/
4:4:4
4:0:0 (Monochrome)(黑白) No No Yes Yes Yes Yes Yes Yes Yes

High precision weighted prediction

(高精度加权预测)

No No Yes Yes Yes Yes Yes Yes Yes
Chroma QP offset list(色度偏移表) No No Yes Yes Yes Yes Yes Yes Yes

Cross-component prediction

(跨组件预测)

No No No No No Yes Yes Yes Yes
Intra smoothing disabling(内部平滑禁用) No No No No No Yes Yes Yes Yes

Persistent Rice adaptation

(稳固的 Rice adaptation)

No No No No No Yes Yes Yes Yes

RDPCM implicit/explicit

(RDPCM显示或隐式)

No No No No No Yes Yes Yes Yes
Transform skip block sizes larger than 4x4 (Transform skip 块大小大于4*4) No No No No No Yes Yes Yes Yes
Transform skip context/rotation(Transform skip 上下文或旋转) No No No No No Yes Yes Yes Yes
Extended precision processing(额外的精密步骤) No No No No No No No No Yes
  • 高精度加权预测:使用增加的加权预测精度,这提高了在高比特深度处淡化视频场景(fading video scenes,淡入淡出)的编码效率。
  • Cross-component prediction, using prediction between the chroma/luma components to improve coding efficiency.The reduction in bit rate can be up to 7% for YCbCr 4:4:4 video and up to 26% for RGB video.RGB video has a larger reduction in bit rate due to the greater correlation between the components.
  • Persistent Rice adaptation, using a Rice coding parameter derivation for entropy coding( 熵编码) that has memory that persists across transform coefficient(共同作用的的) sub-block(子块) boundaries.
  • RDPCM,对残差进行DPCM处理,利用周围临近残差值预测当前残差。
  • transform skip 技术。在人造序列(如动画片、游戏视频 等)中,图像呈平缓区域无变化、边界区域剧烈变化的趋势,预测之后的残差与 自然图像有明显的区别。这些残差数量较少,但值很大。经过变换,这些残差会 形成大量的高频信息,导致出现大量冗余。transform skip 技术在编码端决定是否 进行变换,在上述现象发生时不进行变换,从而使得人造序列的压缩率得到了极 大地提升。

-hp -hq

'hp'='高性能'(快速)
'hq'='高品质'(慢)

 

 

Tiers and levels

HEVC定义了两种tier: Main and High, and thirteen levels. levels are sets of constraints(约束) for a bitstream.The Main tier is a lower tier than the High tier. The tiers were made to deal with applications that differ in terms of (根据...) their maximum bit rate.The Main tier was designed for most applications while the High tier was designed for very demanding(要求很高的) applications. 

兼容性上:A decoder that conforms to a given tier/level is required to be capable of decoding all bitstreams that are encoded for that tier/level and for all lower tiers/levels.

tier 和 level还应该注意的是:For levels below level 4 only the Main tier is allowed. 

Tiers and levels with maximum property values(属性值)
Level Max luma (亮度)sample rate
(samples/s)
Max luma picture size(最大亮度图像尺寸)
(samples)
Max bit rate for Main
and Main 10 profiles (kbit/s)[A]

Example picture resolution @
highest frame rate(最高帧率)[B]
(MaxDpbSize——解码图片缓冲区中的最大图片数[C])

 

More/Fewer examples

Main tier High tier
1 552,960 36,864 128

128×[email protected] (6)

176×[email protected] (6)
2 3,686,400 122,880 1,500

176×[email protected] (16)

352×[email protected] (6)
2.1 7,372,800 245,760 3,000

352×[email protected] (12)

640×[email protected] (6)
3 16,588,800 552,960 6,000

640×[email protected] (12)
720×[email protected] (8)

960×[email protected] (6)
3.1 33,177,600 983,040 10,000

720×[email protected] (12)
960×[email protected] (8)

1280×[email protected] (6)
4 66,846,720 2,228,224 12,000 30,000

1,280×[email protected] (12)
1,920×1,[email protected] (6)

2,048×1,[email protected] (6)
4.1 133,693,440 20,000 50,000

1,280×[email protected] (12)
1,920×1,[email protected] (6)

2,048×1,[email protected] (6)
5 267,386,880 8,912,896 25,000 100,000

1,920×1,[email protected] (16) 
3,840×2,[email protected] (6)

4,096×2,[email protected] (6)
5.1 534,773,760 40,000 160,000

1,920×1,[email protected] (16) 
3,840×2,[email protected] (6)

4,096×2,[email protected] (6)
5.2 1,069,547,520 60,000 240,000

1,920×1,[email protected] (16) 
3,840×2,[email protected] (6)

4,096×2,[email protected] (6)
6 1,069,547,520 35,651,584 60,000 240,000

3,840×2,[email protected] (16) 
7,680×4,[email protected] (6)

8,192×4,[email protected] (6)
6.1 2,139,095,040 120,000 480,000

3,840×2,[email protected] (16) 
7,680×4,[email protected] (6)

8,192×4,[email protected] (6)
6.2 4,278,190,080 240,000 800,000

3,840×2,[email protected] (16) 
7,680×4,[email protected] (6)

8,192×4,[email protected] (6)

A The maximum bit rate of the profile is based on the combination of bit depth, chroma sampling, and the type of profile. For bit depth, the maximum bit rate increases by 1.5× for 12-bit profiles and 2× for 16-bit profiles. For chroma sampling the maximum bit rate increases by 1.5× for 4:2:2 profiles and 2× for 4:4:4 profiles. For the Intra profiles the maximum bit rate increases by 2×.

B The maximum frame rate supported by HEVC is 300 fps.

C The MaxDpbSize is the maximum number of pictures in the decoded picture buffer.

 

如何在ffmpeg中使用带有nvenc的CRF编码?

https://superuser.com/questions/1236275/how-can-i-use-crf-encoding-with-nvenc-in-ffmpeg/1236387

 

 

qmin 整数(编码,视频

设置最小视频量化比例(VBR)。必须包含在-1和69之间,默认值为2。

qmax 整数(编码,视频

设置最大视频量化器比例(VBR)。必须包含在-1和1024之间,默认值为31。

https://ffmpeg.org/ffmpeg-codecs.html#Codec-Options

!!!! 注意:qmin与qmax 必须同时设置,不然没用。

-qscale 

        对于有损编码,它控制图像质量,从0到100。对于无损编码,这控制了压缩更多内容所花费的精力和时间。默认值是75。越低质量越好。但是注意,他可能被h264的某些参数覆盖。比如 h264中的crf 参数。

-cq

恒定质量(CQ)模式(如x264编码器中的CRF),它将确保每个帧获得应该达到某个(感知)质量等级的比特数,而不是而不是强制流具有平均比特率。这样可以提高整体质量。如果您不关心文件大小,这应该是您选择的方法。

    -crf(nvenc里没这个参数, cq类似)

CRF标度的范围是0-51,其中0是无损的,23是默认值,51是最差的质量。较低的值通常会导致更高的质量,主观的理智范围是17-28。考虑17或18在视觉上无损或几乎如此; 它应该与输入看起来相同或几乎相同,但它在技术上并不是无损的。

范围是指数级的,因此增加CRF值+6会导致大约一半的比特率/文件大小,而-6会导致大约两倍的比特率。

选择仍然提供可接受质量的最高CRF值。如果输出看起来不错,那么尝试更高的值。如果看起来不好,请选择较低的值。

 

色度格式

参考:

https://blog.csdn.net/ternence_hsu/article/details/73176810

http://www.strongene.com/cn/proOverview/HEVCTrans&Quantization%20.pdf

2-Pass Average Bitrate (2-Pass ABR)

Allowing the encoder to do two passes (or more) makes it possible for it to estimate what’s ahead in time. It can calculate the cost of encoding a frame in the first pass and then, in the second pass, more efficiently use the bits available. This ensures that the output quality is the best under a certain bitrate constraint.

这是为流式传输编码文件的最简单方法。有两点需要注意:你不知道最终的质量是什么,所以你必须做一些测试,以确保你的比特率实际上足够高,可以用于某些复杂的内容。此模式的另一个缺点是可能存在比特率的本地峰值,这意味着您可能发送超过客户端可以接收的峰值。

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(ffmpeg)