【问题标题】:Gstreamer: encode a mp4 video to opus (audio track) and vp8 (video track)Gstreamer:将 mp4 视频编码为 opus(音轨)和 vp8(视频轨)
【发布时间】:2017-03-27 19:16:42
【问题描述】:

我想使用 gstreamer 启动 opus/vp8 流。 我是从下面的sn-p开始的:

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

【问题讨论】:

  • 您可能已经在 Google 上搜索过:decodebin/vaapi: ranking vaapi breaks plugging。我会尝试卸载 vaapi 库,因为看起来硬件不支持它们。或者也许找出哪些具体元素(而不是无法选择正确解码器的自动 decodebin)可以解码该 mp4。
  • 那么,我如何使用 ffmpeg 实现我的目标?

标签: gstreamer opus vp8


【解决方案1】:

实际上,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

【讨论】:

  • 我应该选择哪种格式?在第一个 sn-p 中它没有设置,但它工作正常。我的 gstreamer 管道充当 WebRTC 网关的源。
  • @pier92,我注意到视频没有被解码。更新了答案。
  • 我已经更新了我的初始答案,之后我尝试了你的答案。
猜你喜欢
  • 2018-02-05
  • 2016-05-18
  • 2012-01-14
  • 1970-01-01
  • 2016-09-02
  • 2012-10-02
  • 1970-01-01
  • 2014-10-16
  • 2011-10-07
相关资源
最近更新 更多