【问题标题】:Gstreamer save camera video input to file returns empty fileGstreamer将相机视频输入保存到文件返回空文件
【发布时间】:2018-10-02 15:52:40
【问题描述】:

我正在尝试保存来自相机的视频输入(也可以是逐帧),我可以像这样显示其输入:

gst-launch-1.0 udpsrc port=50004 ! application/x-rtp,encoding=JPEG,payload=26 ! rtpjpegdepay ! decodebin ! videoconvert ! autovideosink

我想以视频格式或逐帧将此视频保存到文件中。所以我尝试运行

gst-launch-1.0 udpsrc port=50004 ! application/x-rtp,encoding=JPEG,payload=26 ! rtpjpegdepay ! decodebin ! videoconvert ! avimux ! filesink location=video.avi

但是我的 video.avi 文件是空的。我究竟做错了什么?我是 GStreamer 的初学者,我在网上找不到有用的信息,所以我无法弄清楚该管道的每个部分在做什么。

编辑

详细运行我明白了:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = application/x-rtp, encoding=(string)JPEG, payload=(int)26, media=(string)video, clock-rate=(int)90000
/GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:sink: caps = application/x-rtp, encoding=(string)JPEG, payload=(int)26, media=(string)video, clock-rate=(int)90000
/GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:src: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:src: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
[INFO]  bitstreamMode 1, chromaInterleave 0, mapType 0, tiled2LinearEnable 0
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstImxVpuDecoder:imxvpudecoder0.GstPad:sink: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:sink: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:sink: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstImxVpuDecoder:imxvpudecoder0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstDecodePad:src_0.GstProxyPad:proxypad1: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)0/1

【问题讨论】:

  • 你能用-v参数(详细)运行你的管道,并在这里分享输出吗? gst-launch-1.0 udpsrc port=50004 ! application/x-rtp,encoding=JPEG,payload=26 ! rtpjpegdepay ! decodebin ! videoconvert ! avimux ! filesink location=video.avi -v
  • /GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:src: caps = image/jpeg, framerate=(fraction)0/1, width=(int)640, height=(int)480 显示 rtpjpegdepay 将帧率视为 0,您确定您的来源吗?
  • 好吧,如果第一个命令在屏幕上显示相机的输出,我可以不安全地假设我的来源是正确的吗?
  • 是的,在这种情况下,我们的管道有问题。这次你能不能再试一次,用jpegdec替换decodebin元素。
  • 不允许。我明白了:警告:错误的管道:没有元素“jpegdec”

标签: gstreamer video-capture gst-launch


【解决方案1】:

我最终可以使用以下命令写入图像流:

gst-launch-1.0 udpsrc port=50004 ! application/x-rtp,encoding=JPEG,payload=26 ! rtpjpegdepay ! matroskamux ! filesink location=video.mkv

【讨论】:

    【解决方案2】:

    "encoding=JPEG" 只是在流水线的那个阶段指定 jpeg,但稍后由 decodebin 解码,从而产生未压缩的原始视频。

    您可以检查您的 gstreamer 安装支持哪些编码器

    gst-inspect-1.0 | grep enc
    

    这也列出了音频编码器。可能您必须安装额外的 gstreamer 包才能获得任何或更多编码器,例如 gstreamer1.0-plugins-bad 或 gstreamer1.0-plugins-ugly(此包包含 x264enc)。

    然后再次尝试来自@Alper 的管道:

    gst-launch-1.0 udpsrc port=50004 ! application/x-rtp,encoding=JPEG,payload=26 ! rtpjpegdepay \
    ! decodebin ! videoconvert ! x264enc ! avimux ! filesink location=video.avi
    

    【讨论】:

    • 很遗憾,我无法在这个系统上安装任何东西。
    猜你喜欢
    • 2013-09-03
    • 2016-03-27
    • 2013-07-22
    • 1970-01-01
    • 2012-11-21
    • 1970-01-01
    • 1970-01-01
    • 2013-04-23
    • 2020-06-09
    相关资源
    最近更新 更多