# 關於Youtube VP9/H264在intel HD530上硬解的那件事
###### tags: `技術文`
# 實驗設備
- 筆電 i5-6200U ~~(Intel HD530)~~ Intel 530 + Nvdia 930M
- 桌電 i7-6700 (Intel 520)
# youtube codecs
查看youtube影片所使用的編碼格式: `statistics->codecs:VP9`
![](https://i.imgur.com/2QE8Guk.jpg)
chrome flags無法更動,固YOUTUBE維持VP9輸出
>[name=dalecur...@chromium.org ][time=Jul 7 2015][color=orange]["Given the presence of the h264ify extension and recent performance numbers for vp9, it doesn't make sense to implement this.""](https://bugs.chromium.org/p/chromium/issues/detail?id=459407)
可裝`h264ify`套件讓chrome儘量用h.264
# hardware encode/decode support
硬體編/解碼仰賴獨立電路或CUDA,各家GPU支援程度:
- [NVIDIA Decoder](https://developer.nvidia.com/video-encode-decode-gpu-support-matrix)
- [Intel HD530](https://en.wikichip.org/wiki/intel/hd_graphics/530)
- [AMD](https://en.wikipedia.org/wiki/Unified_Video_Decoder)
Support|H264|H265|VP9
---|---|---|---
Intel HD530|O|O|O
Geforce 930M|O|X|X
> Geforce 930M based on 840
買筆電+NVDIA獨顯當羊
:::info
發哥[Dimensity 1000](https://i.mediatek.com/mediatek-5g)支援硬解ㄛ
:::
# software/browser support
- VLC相關設定
- 視訊->output:自動
![](https://i.imgur.com/3mOh2CA.png)
- 編解碼器->VM-API(with/without DRM)
![](https://i.imgur.com/yNncHM5.png)
- Browser:除了硬體支援外,在瀏覽器使用硬解需要瀏覽器也支持
- Microsoft edge
- 目前所知能硬解VP9唯一瀏覽器
- chrome
- `chrome://gpu/` 查看相關資訊
```text
Graphics Feature Status
Canvas: Hardware accelerated
Flash: Hardware accelerated
Flash Stage3D: Hardware accelerated
Flash Stage3D Baseline profile: Hardware accelerated
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
Out-of-process Rasterization: Disabled
OpenGL: Enabled
Hardware Protected Video Decode: Unavailable**
Rasterization: Software only. Hardware acceleration disabled
Skia Renderer: Enabled
Video Decode: Unavailable
Vulkan: Disabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
Problems Detected
Accelerated video decode is unavailable on Linux: 137247, 1032907
Disabled Features: accelerated_video_decode**
Protected video decoding with swap chain is for Windows and Intel only
Disabled Features: protected_video_decode**
真蚌
```
# 取得影片
使用`youtube-dl`查詢影片資訊
```bash
~$ youtube-dl -F https://www.youtube.com/watch?v=ftlvreFtA2A
[youtube] ftlvreFtA2A: Downloading webpage
[info] Available formats for ftlvreFtA2A:
format code extension resolution note
249 webm audio only tiny 56k , opus @ 50k (48000Hz), 20.09MiB
250 webm audio only tiny 75k , opus @ 70k (48000Hz), 26.61MiB
140 m4a audio only tiny 131k , m4a_dash container, mp4a.40.2@128k (44100Hz), 52.22MiB
251 webm audio only tiny 144k , opus @160k (48000Hz), 52.26MiB
394 mp4 256x144 144p 86k , av01.0.00M.08, 30fps, video only, 27.83MiB
160 mp4 256x144 144p 106k , avc1.4d400c, 30fps, video only, 17.08MiB
278 webm 256x144 144p 112k , webm container, vp9, 30fps, video only, 36.31MiB
395 mp4 426x240 240p 198k , av01.0.00M.08, 30fps, video only, 55.32MiB
133 mp4 426x240 240p 243k , avc1.4d4015, 30fps, video only, 37.24MiB
242 webm 426x240 240p 244k , vp9, 30fps, video only, 70.93MiB
396 mp4 640x360 360p 369k , av01.0.01M.08, 30fps, video only, 110.67MiB
243 webm 640x360 360p 427k , vp9, 30fps, video only, 145.22MiB
134 mp4 640x360 360p 697k , avc1.4d401e, 30fps, video only, 134.15MiB
397 mp4 854x480 480p 710k , av01.0.04M.08, 30fps, video only, 210.85MiB
244 webm 854x480 480p 798k , vp9, 30fps, video only, 274.02MiB
135 mp4 854x480 480p 1347k , avc1.4d401f, 30fps, video only, 327.02MiB
398 mp4 1280x720 720p 1388k , av01.0.05M.08, 30fps, video only, 433.65MiB
247 webm 1280x720 720p 1601k , vp9, 30fps, video only, 589.98MiB
399 mp4 1920x1080 1080p 2491k , av01.0.08M.08, 30fps, video only, 752.58MiB
136 mp4 1280x720 720p 2716k , avc1.4d401f, 30fps, video only, 785.16MiB
248 webm 1920x1080 1080p 3023k , vp9, 30fps, video only, 1.03GiB
137 mp4 1920x1080 1080p 5114k , avc1.640028, 30fps, video only, 1.50GiB
400 mp4 2560x1440 1440p 8714k , av01.0.12M.08, 30fps, video only, 2.48GiB
271 webm 2560x1440 1440p 9247k , vp9, 30fps, video only, 3.37GiB
401 mp4 3840x2160 2160p 17495k , av01.0.12M.08, 30fps, video only, 5.13GiB
313 webm 3840x2160 2160p 18496k , vp9, 30fps, video only, 7.04GiB
18 mp4 640x360 360p 654k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 268.98MiB
22 mp4 1280x720 720p 2036k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz) (best)
```
每行標明封裝格式、解析度、編碼,例如這行
`401 mp4 3840x2160 2160p 17495k , av01.0.12M.08, 30fps, video only, 5.13GiB`
- `mp4`是封裝格式
- `av01`是編碼
- `3840x2160` 是解析度
有幾種不同的封裝格式
- avc1 (H.264)
- av01
> *[It was developed as a successor to VP9](https://en.wikipedia.org/wiki/AV1)*
> 未來取代vp9
- vp9
選定格式後使用`-f` 下載影片
```bash
~$ youtube-dl -f 137+140 https://www.youtube.com/watch?v=ftlvreFtA2A
```
# 實驗
有用內顯硬解用`intel_gpu_top`能看到video使用率
```
intel-gpu-top - 350/ 350 MHz; 95% RC6; 0.04 Watts; 145 irqs/s
IMC reads: 842 MiB/s
IMC writes: 77 MiB/s
ENGINE BUSY MI_SEMA MI_WAIT
Render/3D/0 1.18% |▍ | 0% 0%
Blitter/0 0.00% | | 0% 0%
Video/0 0.00% | | 0% 0%
VideoEnhance/0 0.00% | | 0% 0%
```
video format|Intel HD530 Video Engine Usage
---|---
1080p, avc1.640028, 30fps| 20~30%