video: Add support for H.264/H.265 encoding
This is the initial version of virgl video encoding, which currently supports H.264 and H.265.
For the changes to mesa, please refer to mesa/mesa!18831 (merged)
Example of H.264 with ffmpeg
$ LIBVA_DRIVER_NAME=virtio_gpu ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -s 176x144 -i AUD_MW_E.yuv -vf format=nv12,hwupload -c:v h264_vaapi AUD_MW_E.ffmpeg.h264
[rawvideo @ 0x55a742de0d80] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'AUD_MW_E.yuv':
Duration: 00:00:04.00, start: 0.000000, bitrate: 7603 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144, 7603 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
[h264_vaapi @ 0x55a742de6b00] No quality level set; using default (20).
[h264_vaapi @ 0x55a742de6b00] Driver does not support some wanted packed headers (wanted 0xd, found 0).
Output #0, h264, to 'AUD_MW_E.ffmpeg.h264':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (High), vaapi_vld(tv, progressive), 176x144, q=2-31, 25 fps, 25 tbn
Metadata:
encoder : Lavc58.134.100 h264_vaapi
frame= 100 fps=0.0 q=-0.0 Lsize= 244kB time=00:00:04.00 bitrate= 499.0kbits/s speed=12.3x
video:244kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
$
$ ffprobe -hide_banner -i AUD_MW_E.ffmpeg.h264
Input #0, h264, from 'AUD_MW_E.ffmpeg.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 176x144, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Example of H.265 with ffmpeg
$ LIBVA_DRIVER_NAME=virtio_gpu ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -s 176x144 -i AUD_MW_E.yuv -vf format=nv12,hwupload -c:v hevc_vaapi AUD_MW_E.ffmpeg.h265
[rawvideo @ 0x565383213d80] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'AUD_MW_E.yuv':
Duration: 00:00:04.00, start: 0.000000, bitrate: 7603 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144, 7603 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (hevc_vaapi))
Press [q] to stop, [?] for help
[hevc_vaapi @ 0x565383219b00] No quality level set; using default (25).
[hevc_vaapi @ 0x565383219b00] Driver does not support some wanted packed headers (wanted 0xd, found 0x1).
Output #0, hevc, to 'AUD_MW_E.ffmpeg.h265':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: hevc (Main), vaapi_vld(tv, progressive), 176x144, q=2-31, 25 fps, 25 tbn
Metadata:
encoder : Lavc58.134.100 hevc_vaapi
frame= 100 fps=0.0 q=-0.0 Lsize= 129kB time=00:00:04.00 bitrate= 264.6kbits/s speed=7.91x
video:129kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
$
$ ffprobe -hide_banner -i AUD_MW_E.ffmpeg.h265
Input #0, hevc, from 'AUD_MW_E.ffmpeg.h265':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: hevc (Main), yuv420p(tv), 192x144, 25 fps, 25 tbr, 1200k tbn, 25 tbc
Video files
Others
- Host: Intel i5-9500, AMD Radeon RX550
- Guest: virtio-gpu
Signed-off-by: Jiang Feng jiangfeng@kylinos.cn
Edited by Feng Jiang