Files
Obsidian-Main/-20.01. Programming/FFMPEG/Profiles & levels.md

43 lines
3.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- [H.264 profiles and levels](https://blog.mediacoderhq.com/h264-profiles-and-levels/)
H.264 有四種畫質級別,分別是`baseline`, `extended`, `main`, `high`
- baseline profile基本畫質。支援I/P 幀只支援無交錯Progressive和CAVLC
- extended profile進階畫質。支援I/P/B/SP/SI 幀只支援無交錯Progressive和CAVLC(用的少)
- main profile主流畫質。提供I/P/B 幀支援無交錯Progressive和交錯Interlaced也支援CAVLC 和CABAC 的支援
- high profile高階畫質。在main profile 的基礎上增加了8x8 內部預測、自訂量化、無損視訊編碼和更多的YUV 格式
H.264 baseline profile、extended profile 和 main profile 都是針對`8位`樣本資料、4:2:0 格式(YUV) 的視訊序列。在相同配置情況下high profileHP可以比main profileMP 降低10% 的碼率)
- `profile`: 規定了一個演算法特徵和限制的子集任何遵守某個profile 的解碼器都應該支援與其對應的子集是對視訊壓縮_特性的描述_CABAC、顏色採樣數等
- `level`: 規定了一組對標準中語法成員syntax element所採用的各種參數值的限制對_視頻本身特性的描述_(fps (幀率)、碼率、分辨率)
> 總的來說就是profile 越高表示採用了越高級的壓縮特性level 越高,表示影片的幀率、碼率、解析度越高
## profile
![[Pasted image 20231225164349.png]]
- Baseline Profile (BP):主要用於計算資源有限的低成本應用程序,此設定檔廣泛用於視訊會議和行動應用程式。
- Main Profile (MP)最初打算作為廣播和儲存應用程式的主流消費者個人資料當為這些應用程式開發High profile 時,此設定檔的重要性逐漸消失。
- Extended Profile (XP):旨在作為串流視訊設定文件,此設定檔具有相對較高的壓縮能力和一些額外的技巧,以提高資料遺失和伺服器串流切換的穩健性。
- High Profile (HiP)廣播和光碟儲存應用程式的主要設定文件特別是高清電視應用程式例如HD DVD 和藍光光碟採用的設定檔)。
- High 10 Profile (Hi10P) 超越當今的主流消費產品功能此配置文件建立在High Profile 之上—— 增加了對解碼圖像精度的每個樣本高達10 位的支援。
- High 4:2:2 Profile (Hi422P)主要針對使用隔行視頻的專業應用程序此配置文件建立在High 10 Profile 之上—— 增加了對4:2:2 色度子採樣格式的支持同時使用多達10 位元每個解碼影像精度的樣本。
- High 4:4:4 Predictive Profile (Hi444PP)此設定檔建立在高4:2:2 設定檔之上- 支援高達4:4:4 色度取樣每個取樣高達14 位,此外還支援高效率無損區域編碼並將每張圖片編碼為三個獨立的顏色平面。
## Level
![[Pasted image 20231225164413.png]]
level 的計算方法:
例如解析度: `1920x1080`, 60fps 的 H.264 碼流是哪個 level 呢?
H.264 的 marco block 大小為 `16×16` in H.264, 每frame的 marco block 的個數為**解析度除以16**。
- `max-fs = ceil( width / 16.0 ) * ceil( height / 16.0 )`
計算得8100
每秒 marco block 數量為每幀 marco block 數乘以幀率.
- max-mbps =max-fs * 參考幀率(60)
計算得486000
![[Pasted image 20231225164717.png]]
因此對比表上的數據 `1920x1080@60fps`level 應該選擇`4.2`