Gstreamer:将mp4视频编码为opus(音频曲目)和vp8(视频曲目)

Gstreamer:将mp4视频编码为opus(音频曲目)和vp8(视频曲目),gstreamer,opus,vp8,Gstreamer,Opus,Vp8,我想使用gstreamer启动opus/vp8流。 我从以下片段开始: #!/bin/sh gst-launch-1.0 \ audiotestsrc ! \ audioresample ! audio/x-raw,channels=1,rate=16000 ! \ opusenc bitrate=20000 ! \ rtpopuspay ! udpsink host=127.0.0.1 port=5002 \ videotestsrc ! \ vid

我想使用gstreamer启动opus/vp8流。 我从以下片段开始:

#!/bin/sh
gst-launch-1.0 \
  audiotestsrc ! \
    audioresample ! audio/x-raw,channels=1,rate=16000 ! \
    opusenc bitrate=20000 ! \
      rtpopuspay ! udpsink host=127.0.0.1 port=5002 \
  videotestsrc ! \
    video/x-raw,width=320,height=240,framerate=15/1 ! \
    videoscale ! videorate ! videoconvert ! timeoverlay ! \
    vp8enc error-resilient=1 ! \
      rtpvp8pay ! udpsink host=127.0.0.1 port=5004
在当前文件夹中,我现在有一个mp4视频:我想通过gstreamer对两个曲目进行编码来重现它

我试过:

gst-launch-1.0 filesrc location=video.mp4 ! video/x-raw,width=320,height=240,framerate=15/1 ! videoscale ! videorate ! videoconvert ! timeoverlay ! vp8enc error-resilient=1 ! rtpvp8pay ! udpsink host=127.0.0.1 port=5004
#!/bin/sh
gst-launch-1.0 \
    filesrc video.mp4 ! \
    video/x-raw,width=320,height=240,framerate=15/1 ! \
    videoscale ! videorate ! videoconvert ! timeoverlay ! \
    vp8enc error-resilient=1 ! \
      rtpvp8pay ! udpsink host=127.0.0.1 port=5004
但gst的发布向我展示了这一点:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format
Additional debug info:
gstcapsfilter.c(454): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:
Output caps are unfixed: video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)15/1, format=(string){ YV12, YUY2, UYVY, AYUV, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, Y444, v210, v216, NV12, NV21, NV16, NV61, 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, A420_10LE, A420_10BE, A422_10LE, A422_10BE, A444_10LE, A444_10BE, I420 }
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
我怎样才能解决这个问题

[编辑]:我试过:

gst-launch-1.0 filesrc location=video.mp4 ! video/x-raw,width=320,height=240,framerate=15/1 ! videoscale ! videorate ! videoconvert ! timeoverlay ! vp8enc error-resilient=1 ! rtpvp8pay ! udpsink host=127.0.0.1 port=5004
#!/bin/sh
gst-launch-1.0 \
    filesrc video.mp4 ! \
    video/x-raw,width=320,height=240,framerate=15/1 ! \
    videoscale ! videorate ! videoconvert ! timeoverlay ! \
    vp8enc error-resilient=1 ! \
      rtpvp8pay ! udpsink host=127.0.0.1 port=5004
但有以下错误:

ERROR: pipeline could not be constructed: empty pipeline not allowed.
prova.sh: 8: prova.sh: filesrc: not found
最后,我尝试了以下方法:

gst-launch-1.0 filesrc location=video.mp4 ! decodebin ! videoscale ! videorate ! videoconvert ! timeoverlay ! vp8enc error-resilient=1 ! rtpvp8pay ! udpsink host=127.0.0.1 port=5004
这是console显示的内容:

    Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
error: XDG_RUNTIME_DIR not set in the environment.
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstVaapiDecodeBin:vaapidecodebin0/GstVaapiDecode:vaapidecode: Could not initialize supporting library.
Additional debug info:
gstvideodecoder.c(2492): gst_video_decoder_change_state (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstVaapiDecodeBin:vaapidecodebin0/GstVaapiDecode:vaapidecode:
Failed to open decoder
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
error: XDG_RUNTIME_DIR not set in the environment.
Freeing pipeline ...

(gst-launch-1.0:514): GStreamer-CRITICAL **: gst_pad_send_event: assertion 'GST_IS_PAD (pad)' failed

(gst-launch-1.0:514): GStreamer-CRITICAL **: gst_object_unref: assertion 'object != NULL' failed
Caught SIGSEGV
exec gdb failed: No such file or directory
Spinning.  Please run 'gdb gst-launch-1.0 514' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

实际上,
videotestsrc
生成原始视频。但是mp4应该首先被解码,因此这应该可以工作并自动协商上限:

gst-launch-1.0 filesrc location=video.mp4!德克宾!电子秤!视频速率!视频转换!时间重叠!vp8enc错误弹性=1!rtpvp8pay!udpsink主机=127.0.0.1端口=5004

我应该选择哪种格式?在第一个代码段中,它没有设置,但工作正常。我的gstreamer管道充当WebRTC网关的源。@pier92,我注意到视频没有解码。更新了答案。我已经更新了我的初始答案,之后我尝试了你的答案。你可能已经在谷歌上搜索了这个:。我会尝试卸载vaapi libs,因为硬件似乎不支持它们。或者可以找出哪些具体元素(而不是无法选择正确解码器的自动
decodebin
)可以解码mp4。那么,我该如何使用ffmpeg实现我的目标呢?