Gstreamer将摄像头视频输入保存到文件返回空文件

Gstreamer将摄像头视频输入保存到文件返回空文件,gstreamer,video-capture,gst-launch,Gstreamer,Video Capture,Gst Launch,我正试图保存摄像机的视频输入(也可以是逐帧的),我可以这样显示摄像机的输入: 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 ! appl

我正试图保存摄像机的视频输入(也可以是逐帧的),我可以这样显示摄像机的输入:

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的初学者,我无法在网上找到有用的信息,所以我无法弄清楚管道的每个部分都在做什么

编辑

使用verbose运行时,我得到以下结果:

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
“encoding=JPEG”只是在管道的那个阶段指定JPEG,但它稍后会被decodebin解码,从而生成未压缩的原始视频

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

gst-inspect-1.0 | grep enc
这也列出了音频编码器。可能您必须安装额外的gstreamer包才能获得任何或更多编码器,如gstreamer1.0-plugins-bad或gstreamer1.0-plugins-ught(此包包含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
“encoding=JPEG”只是在管道的那个阶段指定JPEG,但它稍后会被decodebin解码,从而生成未压缩的原始视频

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

gst-inspect-1.0 | grep enc
这也列出了音频编码器。可能您必须安装额外的gstreamer包才能获得任何或更多编码器,如gstreamer1.0-plugins-bad或gstreamer1.0-plugins-ught(此包包含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

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

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

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

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

您能否使用
-v
参数(详细)运行管道,并在此处共享输出<代码>gst-launch-1.0 udpsrc端口=50004!应用程序/x-rtp,编码=JPEG,有效载荷=26!rtpjpegdepay!德克宾!视频转换!阿维穆克斯!filesink location=video.avi-v/GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:src:caps=image/jpeg,帧速率=(分数)0/1,宽度=(int)640,高度=(int)480显示
rtpjpegdepay
将帧速率视为0,你确定你的来源吗?如果第一个命令显示屏幕上摄像机的输出,我能不能安全地假设我的来源是正确的?是的,在这种情况下,我们的管道有问题。这次你能再试一次吗?用
jpegdec
替换
decodebin
元素。这是不允许的。我发现:警告:错误的管道:没有元素“jpegdec”,您能否使用
-v
参数(详细)运行管道,并在此处共享输出<代码>gst-launch-1.0 udpsrc端口=50004!应用程序/x-rtp,编码=JPEG,有效载荷=26!rtpjpegdepay!德克宾!视频转换!阿维穆克斯!filesink location=video.avi-v/GstPipeline:pipeline0/GstRtpJPEGDepay:rtpjpegdepay0.GstPad:src:caps=image/jpeg,帧速率=(分数)0/1,宽度=(int)640,高度=(int)480显示
rtpjpegdepay
将帧速率视为0,你确定你的来源吗?如果第一个命令显示屏幕上摄像机的输出,我能不能安全地假设我的来源是正确的?是的,在这种情况下,我们的管道有问题。这次你能再试一次吗?用
jpegdec
替换
decodebin
元素。这是不允许的。我得到以下信息:警告:错误管道:没有元素“jpegdec”。很遗憾,我无法在此系统上安装任何内容。很遗憾,我无法在此系统上安装任何内容。