How can I get ffserver to work?
You can achieve resizing, re-encoding to mpeg2 and RTSP streaming with gstreamer, but I didn't manage to change the frame rate. If this is sufficient, here's how:
- Install gst RTSP server development package:
sudo apt-get install libgstrtspserver-0.10-dev
- Get a copy of this example launcher
- Compile it with
gcc -o test-launch $(pkg-config --cflags --libs gstreamer-0.10 gst-rtsp-server-0.10) test-launch.c
- Start streaming:
./test-launch "( filesrc location=/tmp/rtp.mp4 ! decodebin ! videoscale ! video/x-raw-yuv,width=400,height=320 ! ffenc_mpeg2video ! mpegtsmux ! rtpmp2tpay name=pay0 pt=96 )"
- Watch video:
gst-launch-0.10 rtspsrc location=rtsp://127.0.0.1:8554/test ! decodebin ! xvimagesink
A few caveats:
- to change the port, you have to add a call to
gst_rtsp_server_set_port(server, 9091);
in test-launch.c, between lines 44 and 45 - totem reads the stream, but does not display anything, not even error messages
- mplayer does not support the stream type
Related videos on Youtube
tommed
Product Director at a Software Security firm. Designed, built and deployed software in retail, telecoms, government, defence, UK police, healthcare, financial and banking sectors. Designs software using SOLID design principles.
Updated on September 17, 2022Comments
-
tommed over 1 year
I have a mp4 file which I wish to compress, resize and stream via RTSP.
My ffserver.conf file looks like this:
Port 9091 RTSPPort 5454 BindAddress 0.0.0.0 MaxHTTPConnections 2000 MaxClients 1000 MaxBandwidth 1000 CustomLog - NoDaemon
<Feed feed1.ffm> File /tmp/feed1.ffm FileMaxSize 500M </Feed>
<Stream live.mpeg> Format rtp File "/tmp/rtp.mp4" Feed feed1.ffm VideoCodec mpeg2video VideoFrameRate 15 VideoBitRate 200 VideoSize 400x320 #AudioCodec mp2 #AudioBitRate 32 #AudioChannels 2 #AudioSampleRate 22050 NoAudio #Preroll 10 ACL allow 127.0.0.1 </Stream>
<Stream stat.html> Format status # Only allow local people to get the status ACL allow localhost ACL allow 192.168.0.0 192.168.255.255 </Stream>
From what I understand, I don't need to feed in a video stream using ffmpeg as I am using the File attribute, so ffserver does the work for me?
When I try to use totem to playback the video (ffplay just times-out), I get the following error:
$ totem rtsp://127.0.0.1:5454/live.mpeg ** Message: Error: Could not read from resource. gstrtspsrc.c(4408): gst_rtspsrc_send (): /GstPlayBin2:play/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Got error response: 454 (Session Not Found).
ffserver's log looks like this:
$ ffserver -f /tmp/ffserver.conf FFserver version 0.6-4:0.6-2ubuntu6, Copyright (c) 2000-2010 the FFmpeg developers built on Oct 5 2010 22:36:53 with gcc 4.4.5 configuration: --extra-version=4:0.6-2ubuntu6 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-x11grab --enable-libdc1394 --enable-shared --disable-static WARNING: library configuration mismatch libavutil configuration: --extra-version=4:0.6-2ubuntu3 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libdirac --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-libmp3lame --enable-gpl --enable-postproc --enable-x11grab --enable-libfaad --enable-libxvid --enable-libx264 --enable-librtmp --enable-libdc1394 --enable-shared --disable-static libavcodec configuration: --extra-version=4:0.6-2ubuntu3 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libdirac --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-pthreads --enable-zlib --enable-libvpx --disable-stripping --enable-runtime-cpudetect --enable-libmp3lame --enable-gpl --enable-postproc --enable-x11grab --enable-libfaad --enable-libxvid --enable-libx264 --enable-librtmp --enable-libdc1394 --enable-shared --disable-static libavutil 50.15. 1 / 50.15. 1 libavcodec 52.72. 2 / 52.72. 2 libavformat 52.64. 2 / 52.64. 2 libavdevice 52. 2. 0 / 52. 2. 0 libavfilter 1.19. 0 / 1.19. 0 libswscale 0.11. 0 / 0.11. 0 libpostproc 51. 2. 0 / 51. 2. 0 Sun Oct 10 12:37:20 2010 FFserver started. Sun Oct 10 12:38:34 2010 127.0.0.1 - - [DESCRIBE] "rtsp://127.0.0.1:5454/live.mpeg RTSP/1.0" 200 166 Sun Oct 10 12:38:38 2010 127.0.0.1:51118 - - "PLAY live.mpeg/streamid=0 RTP/UDP" Sun Oct 10 12:38:38 2010 127.0.0.1 - - [] " RTP/UDP" 200 0 Sun Oct 10 12:38:43 2010 127.0.0.1 - - [TEARDOWN] "rtsp://127.0.0.1:5454/live.mpeg RTSP/1.0" 200 819 Sun Oct 10 12:38:43 2010 127.0.0.1:0 - - "PLAY live.mpeg/streamid=0 RTP/TCP" Sun Oct 10 12:38:43 2010 127.0.0.1 - - [] " RTP/TCP" 200 0 Sun Oct 10 12:38:54 2010 127.0.0.1 - - [PLAY] "rtsp://127.0.0.1:5454/live.mpeg RTSP/1.0" 200 621
What am I doing wrong?
-
Admin over 13 yearsURL_HERE was put in the log as my askubuntu account is new and I am not allowed to add more than a single url in my post. It can be replaced with: rtsp://127.0.0.1:5454/live.mpeg
-
Admin almost 13 yearsYour question might get a better response from the supperuser site. I recommend migrating it there.
-
-
tommed over 12 yearsThank you, I will certainly look into using gstreamer. I won't mark this as the answer yet as the original question was to get ffserver working.. hope that sounds fair! :)
-
taneli over 12 yearsI hope you get it working, one way or the other. I deliberately ignored your choice of software as it seemed to me (after some experiments) that there might be mistakes in the ffserver mpeg2 stream parameters that prohibit this from working at all. But I'd like to be shown wrong.