UBUNTU 上的 VAAPI 解码不显示视频

UBUNTU 上的 VAAPI 解码不显示视频

我正在尝试使用 gstreamer vaapi 通过以太网流式传输视频并进行解码和显示。我没有遇到任何错误,只是视频没有显示。发送方使用的管道是:

gst-launch-1.0 filesrc location=video.avi or .mp4 ! decodebin ! videoconvert ! queue ! x264enc pass=qual quantizer=15 ! queue ! udpsink host=239.0.0.1 port=9001 async=false

其结果是:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...

在接收器上:

GST_VAAPI_ALL_DRIVERS=1 gst-launch-1.0 udpsrc caps = "video/mpegts, systemstream=(boolean)true,packetsize=(int)188" address="239.0.0.1" port=9001 ! queue ! tsdemux ! queue ! vaapih264dec ! videoconvert ! xvimagesink sync=false tried also with glimagesink , vaapisink no result.

结果如下:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
/GstPipeline:pipeline0/GstVaapiDecodeBin:vaapidecodebin0/GstQueue:vaapi-queue: max-size-time = 0
/GstPipeline:pipeline0/GstVaapiDecodeBin:vaapidecodebin0/GstQueue:vaapi-queue: max-size-buffers = 0
/GstPipeline:pipeline0/GstVaapiDecodeBin:vaapidecodebin0/GstQueue:vaapi-queue: max-size-bytes = 0
Got context from element 'vaapipostproc0': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
Got context from element 'vaapipostproc0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";
/GstPipeline:pipeline0/GstUDPSrc:udpsrc0.GstPad:src: caps = video/mpegts, systemstream=(boolean)true, packetsize=(int)188
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = video/mpegts, systemstream=(boolean)true, packetsize=(int)188
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = video/mpegts, systemstream=(boolean)true, packetsize=(int)188
/GstPipeline:pipeline0/GstTSDemux:tsdemux0.GstPad:sink: caps = video/mpegts, systemstream=(boolean)true, packetsize=(int)188
Setting pipeline to PLAYING ...
New clock: GstSystemClock

如果我因为没有显示视频而遗漏了什么,请告诉我。

答案1

你可能在发送数据包之前遗漏了 rtp 负载udpsink

尝试类似

gst-launch-1.0 filesrc location=video.avi or .mp4 ! decodebin ! videoconvert ! queue ! x264enc pass=qual quantizer=15 ! queue ! rtph264pay ! udpsink host=239.0.0.1 port=9001 async=false

然后,在接收方:

GST_VAAPI_ALL_DRIVERS=1 gst-launch-1.0 udpsrc caps = "video/mpegts, systemstream=(boolean)true,packetsize=(int)188" address="239.0.0.1" port=9001 ! queue ! rtph264depay ! h264parse ! tsdemux ! queue ! vaapih264dec ! videoconvert ! xvimagesink sync=false

答案2

只需阅读有关tsdemux元素的信息,它用于解复用 MPEG 流,并创建源端的 MPEG 流,您必须使用将 h264 编码流复用为 MPEG 传输流格式mpegtsmux

因此,源管道看起来如下

gst-launch-1.0 filesrc location=video.avi or .mp4 ! decodebin ! videoconvert ! queue ! x264enc pass=qual quantizer=15 ! mpegtsmux ! queue ! udpsink host=239.0.0.1 port=9001 async=false

然后你可以在接收端对其进行解复用

GST_VAAPI_ALL_DRIVERS=1 gst-launch-1.0 udpsrc caps = "video/mpegts, systemstream=(boolean)true,packetsize=(int)188" address="239.0.0.1" port=9001 ! queue ! tsdemux ! queue ! vaapih264dec ! videoconvert ! xvimagesink sync=false

或者你可以决定创建 RTP 流而不是 JPEG 传输流,然后执行此操作

gst-launch-1.0 filesrc location=video.avi or .mp4 ! decodebin ! videoconvert ! queue ! x264enc pass=qual quantizer=15 ! rtph264pay ! queue ! udpsink host=239.0.0.1 port=9001 async=false

接收方:

GST_VAAPI_ALL_DRIVERS=1 gst-launch-1.0 udpsrc port=9001 ! application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, payload=96!  queue ! rtph264depay ! vaapih264dec ! videoconvert ! xvimagesink sync=false

相关内容