如何将mjpeg文件作为rtsp进行流式传输 [英] How can I stream mjpeg file as rtsp

查看:585
本文介绍了如何将mjpeg文件作为rtsp进行流式传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个mjpeg视频,从网络摄像头获取并存储到* .avi文件中,仍然编码为mjpeg。

We have an mjpeg video, obtained from the webcam and stored into *.avi file, still encoded as mjpeg.

我们需要将这个文件重新输入为rtsp(并保留mjpeg,即没有解码)。目标是模拟视频从处理视频的软件获取的网络摄像头。该文件可以打开vlc / ffplay没有任何问题。 ffmpeg的行为就像流式传输一样,但是,ffplay / vlc无法打开此流。

We need to restream this file as rtsp (and stil preserve the mjpeg there, i.e. no decoding). The goal is to emulate the webcam this video was obtained from for the software that processes the video. The file can be open with vlc/ffplay with no problems. The ffmpeg behaves like it is streaming it, however, ffplay/vlc can't open this stream.

如果使用gstreamer,我们尝试流式传输。

We tried to stream if with gstreamer.

1)我们为gstreamer管道没有免费的rtsp sink元素。那么,是否有一个免费的类似的rtspsink启动这个管道gst-launch?我们只需要投射,所以我们不需要像rtspsink那样的高级元素。

1) we fount no free rtsp sink element for gstreamer pipeline. So, is there a free analogue for rtspsink to launch this pipeline with gst-launch? we need and only cast, so we don't need so advanced element as rtspsink is.

2)我们还试图构建自己的简单的rtsp服务器,如 http://weeklybuild.com/2013/01/creating-an- rtsp-stream-with-gstreamer /

2) we also tried to build own simple rtsp server as described in http://weeklybuild.com/2013/01/creating-an-rtsp-stream-with-gstreamer/

将videotestsrc替换为filesrc;但我们应该在那里使用什么样的元素?仅使用filesrc的用法没有帮助;我们得到同样的问题,就像我们用ffmpeg流。但是,如果我们不要解码/编码,只需要传输文件(重现网络摄像头实际做的事情),那么我们需要什么样的条形码。

replacing videotestsrc with filesrc; but what kind of elements we should use there? usage of an only filesrc doesn't help; we get the same problem as if we stream with ffmpeg. But what kind of lements we need there, if we dont' wan to decode/encode it, just to stream the file (to reproduce the thing what the webcam actually does).

 $ ffplay rtsp://127.0.0.1:8554/test -loglevel debug
 avplay version 0.8.5-6:0.8.5-1, Copyright (c) 2003-2012 the Libav developers
 built on Jan 13 2013 12:05:48 with gcc 4.7.2
 configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.5-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
 avutil      configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
 avcodec     configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
 avformat    configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
 swscale     configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
postproc    configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-            postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil    51. 22. 1 / 51. 22. 1
libavcodec   53. 35. 0 / 53. 35. 0
libavformat  53. 21. 1 / 53. 21. 0
libavdevice  53.  2. 0 / 53.  2. 0
libavfilter   2. 15. 0 /  2. 15. 0
libswscale    2.  1. 0 /  2.  1. 0
libpostproc  52.  0. 0 / 52.  0. 0
[rtsp @ 0x7f558c0008c0] method DESCRIBE failed: 503 Service Unavailable
[rtsp @ 0x7f558c0008c0] CSeq: 2
 Server: GStreamer RTSP server
 Date: Thu, 22 Aug 2013 07:49:30 GMT

 rtsp://127.0.0.1:8554/test: Invalid data found when processing input

一切都好我尝试像示例中构建的gstreamer服务器,即使用videotestsrc

And everything is okay when I try gstreamer server built as in example, i.e. using videotestsrc

推荐答案

只使用filesrc元素不起作用,因为它不提供适当的上限,其中描述其生成的缓冲区的内容。您需要使用的实际元素取决于容器和编解码器。如果例如容器是avi,视频编解码器是mjpeg,你需要这样一个管道:

Using only a filesrc element doesn't work because it doesn't provide appropriate caps which desribe the contents of the buffers it generates. The actual elements you need to use depend on the container and codec. If e.g. the container is avi and the video codec is mjpeg, you would need such a pipeline:

filesrc location=video.avi ! avidemux ! jpegdec ! x264enc ! rtph264pay name=pay0 pt=96

还有一个通用元素decodebin2,它检测容器和编解码器自动:

There is also a universal element decodebin2, which detects the container and the codec automatically:

filesrc location=video.avi ! decodebin2 ! x264enc ! rtph264pay name=pay0 pt=96

这篇关于如何将mjpeg文件作为rtsp进行流式传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆