Encoding gstreamer无法将UYVY编码为h264

Encoding gstreamer无法将UYVY编码为h264,encoding,gstreamer,Encoding,Gstreamer,我正在尝试使用gstreamer vaapi编码器将UYVY颜色空间中的原始流编码为H264 来源管道: gst-launch-1.0-e videotestsrc!视频/x-raw,格式=UYVY,帧速率=60/1,宽度=1920,高度=1080!filesink location=raw.yuv 编码器管道: gst-launch-1.0-v filesrc location=raw.yuv!视频解析格式=uyvy宽度=1920高度=1080帧速率=60!VAAPINCODE_h264 tu

我正在尝试使用gstreamer vaapi编码器将UYVY颜色空间中的原始流编码为H264

来源管道:

gst-launch-1.0-e videotestsrc!视频/x-raw,格式=UYVY,帧速率=60/1,宽度=1920,高度=1080!filesink location=raw.yuv

编码器管道:

gst-launch-1.0-v filesrc location=raw.yuv!视频解析格式=uyvy宽度=1920高度=1080帧速率=60!VAAPINCODE_h264 tune=高压缩!mpegtsmux!filesink location=final.ts

如果我尝试将其编码为I420,pipepline工作正常:

gst-launch-1.0-v filesrc location=raw.yuv!视频解析格式=i420宽度=1920高度=1080帧速率=60!VAAPINCODE_h264 tune=高压缩!mpegtsmux!filesink location=final.ts

检查时:
gst-inspect-1.0 VAAPINCODE_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 }
我还尝试使用videoconvert将UYVY颜色空间转换为I420,但没有成功


是否可以使用gstreamer将UYVY编码为h264?

使用GST\u DEBUG=2运行管道会显示警告:

vaapi gstvaapiencoder.c:591:set_context_info:我们只支持YUV:4:2:0进行编码,请尝试使用VAAPIPostroc转换输入格式

因此,建议在编码器之前使用VaapippostProc转换格式,这对我很有用:

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
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

经过多次尝试,我终于找到了videoconvert的问题所在,结果发现它需要一个块大小。 以下管道对我有效:

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
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

你和videoconvert的管道是什么?这本应该奏效的。用一条管道工作吗?使用videotestsrc并直接链接到编码器?videoconvert管道:gst-launch-1.0-v filesrc location=raw.yuv blocksize=1920000!视频/x-raw,格式=UYVY,宽度=1920,高度=1080,帧速率=15/1!视频转换!视频/x-raw,格式=I420,宽度=1920,高度=1080,帧速率=15/1!VAAPINCODE_h264 tune=高压缩!mpegtsmux!filesink location=final.ts错误:/GstPipeline:pipeline0/GstVideoConvert:videoconvert0:内部GStreamer错误:代码未实现。请在提交错误。此外,单个管道也会失败。使用的管道:gst-launch-1.0-e videotestsrc!视频/x-raw,格式=UYVY,帧速率=60/1,宽度=1920,高度=1080!VAAPINCODE_h264 tune=高压缩!mpegtsmux!filesink location=final.ts错误:错误:来自元素/GstPipeline:pipeline0/GstVaapiEncodeH264-0:GStreamer错误:协商问题。非常感谢您的帮助。你的管道不适合我。GST_DEBUG=2 GST-launch-1.0-e videotestsrc!视频/x-raw,格式=UYVY,帧速率=25/1,宽度=1920,高度=1080!瓦皮布洛克!VAAPINCODE_h264 tune=高压缩!mpegtsmux!filesink location=final.ts错误:vaapi../../../../../gst libs/gst/vaapi/gstvaapiencoder.c:467:检查\u视频\u信息:无效帧率(0/1)我正在运行gstreamer的git master,可能这是已解决但尚未发布的问题。您可以尝试更新的版本或git master吗?