我正在尝试使用gstreamer vaapi编码器将UYVY色彩空间中的RAW流编码为H264。
来源管道:
gst-launch-1.0 -e videotestsrc ! video/x-raw, format=UYVY , framerate=60/1, width=1920, height=1080 ! filesink location=raw.yuv
编码器管道:
gst-launch-1.0 -v filesrc location=raw.yuv ! videoparse format=uyvy width=1920 height=1080 framerate=60 ! vaapiencode_h264 tune=high-compression ! mpegtsmux ! filesink location=final.ts
如果我尝试将其编码为I420,则pipepline工作正常:
gst-launch-1.0 -v filesrc location=raw.yuv ! videoparse format=i420 width=1920 height=1080 framerate=60 ! vaapiencode_h264 tune=high-compression ! mpegtsmux ! filesink location=final.ts
检查时:
gst-inspect-1.0 vaapiencode_h264
我意识到UYVY没有列在video / x-raw(内存:VASurface)功能下,但它列在video / x-raw下。
video/x-raw(memory:VASurface)
format: { ENCODED, NV12, I420, YV12 }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]
interlace-mode: progressive
video/x-raw
format: { I420, YV12, YUY2, UYVY, AYUV, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, Y444, v210, v216, NV12, NV21, NV16, NV24, GRAY8, GRAY16_BE, GRAY16_LE, v308, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, AYUV64, r210, I420_10LE, I420_10BE, I422_10LE, I422_10BE, Y444_10LE, Y444_10BE, GBR, GBR_10LE, GBR_10BE, NV12_64Z32 }
我也尝试使用视频转换从UYVY色彩空间转换为I420,但无济于事。
是否可以使用gstreamer将UYVY编码为h264?
答案 0 :(得分:1)
经过多次击中和追踪后,我终于找到了视频转换的问题,结果需要一个块大小。 以下管道对我有用:
gst-launch-1.0 -v filesrc location=raw.yuv blocksize=4147200 !
videoparse format=uyvy width=1920 height=1080 framerate=60/1 !
videoconvert ! video/x-raw,format=I420,width=1920,height=1080,framerate=60/1 !
vaapiencode_h264 tune=high-compression ! mpegtsmux ! filesink location=final.ts
答案 1 :(得分:0)
使用GST_DEBUG = 2运行管道会显示警告:
vaapi gstvaapiencoder.c:591:set_context_info:我们只支持YUV:4:2:0进行编码,请尝试使用vaapipostproc转换输入格式!
所以它建议使用vaapipostproc在编码器之前转换格式,它对我有用:
gst-launch-1.0 -e videotestsrc ! video/x-raw, format=UYVY , framerate=60/1, width=1920, height=1080 ! vaapipostproc ! vaapiencode_h264 tune=high-compression ! mpegtsmux ! filesink location=final.ts