Gstreamer:将mp4视频编码为opus(音轨)和vp8(视频轨道)

时间:2017-03-27 09:22:35

标签: 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 ! \
    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

但gst-launch告诉我这个:

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

我该如何解决这个问题?

[编辑]:我试过了:

#!/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

这就是控制台显示的内容:

    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.

1 个答案:

答案 0 :(得分:0)

实际上,videotestsrc会生成原始视频。但是mp4应该首先被解码,所以这应该工作并自动协商上限: 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