Stream from MP4 file over RTSP with ffserver
Solution 1
If you are looking for alternatives live555 (http://www.live555.com/ ) and darwin servers are good options. I have used them both and the behave well while streaming from file.
In the above case you can even try debugging by analyzing core dump. By looking at the logs I think server is crashing even before receiving a play command. So it may be a small hick-up somewhere
Solution 2
Only 4 years later...
You can't stream mp4 videos using FFserver because it contains global metadata in the file header - making random stream access impossible. [source]
Possible alternative:
// convert awesome.mp4 to awesome.flv
$ ffmpeg -i awesome.mp4 -c:v libx264 -ar 22050 -crf 28 awesome.flv
For more on FFmpeg... go to blog.
sirlion
Updated on June 04, 2022Comments
-
sirlion almost 2 years
I'm trying to stream a mp4 file over RTSP using ffserver with no luck so far. I just want to stream directly from the file, without feeding from ffmpeg (no transcoding involved). But I've made it work with mpg video.
Here is my ffserver config file:
Port 8090 BindAddress 0.0.0.0 MaxHTTPConnections 2000 MaxClients 1000 MaxBandwidth 500000 CustomLog - NoDaemon RTSPPort 7654 RTSPBindAddress 0.0.0.0 <Stream test1-rtsp> Format rtp File "/home/g/video_streaming/sample3-mpeg2.mpg" </Stream> <Stream test2-rtsp> Format rtp File "/home/g/video.mp4" </Stream>
When I launch ffserver, everything seems fine based on the log output:
$ ./dev/ffmpeg/ffserver -f ffserver-sample.conf ffserver version N-45673-gd0c27e8 Copyright (c) 2000-2012 the FFmpeg developers built on Oct 18 2012 10:36:52 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: libavutil 51. 76.100 / 51. 76.100 libavcodec 54. 66.100 / 54. 66.100 libavformat 54. 33.100 / 54. 33.100 libavdevice 54. 3.100 / 54. 3.100 libavfilter 3. 19.103 / 3. 19.103 libswscale 2. 1.101 / 2. 1.101 libswresample 0. 16.100 / 0. 16.100 Thu Oct 18 11:54:22 2012 Opening file '/home/g/video.mp4' Thu Oct 18 11:54:22 2012 Opening file '/home/g/video.mp4' Thu Oct 18 11:54:23 2012 Opening file '/home/g/video_streaming/sample3-mpeg2.mpg' Thu Oct 18 11:54:23 2012 [mpeg @ 0x1dae3c0]max_analyze_duration 5000000 reached at 5005000 Thu Oct 18 11:54:23 2012 Opening file '/home/g/video_streaming/sample3-mpeg2.mpg' Thu Oct 18 11:54:23 2012 [mpeg @ 0x1dae3c0]max_analyze_duration 5000000 reached at 5005000 Thu Oct 18 11:54:23 2012 FFserver started.
Finally, if I run ffplay in order to test the server, everything works fine for the mpg file, but not for the mp4:
$ ffplay rtsp://192.168.1.99:7654/test2-rtsp ffplay version N-45656-g916352f Copyright (c) 2003-2012 the FFmpeg developers built on Oct 17 2012 16:14:14 with gcc 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5.1) configuration: libavutil 51. 76.100 / 51. 76.100 libavcodec 54. 66.100 / 54. 66.100 libavformat 54. 33.100 / 54. 33.100 libavdevice 54. 3.100 / 54. 3.100 libavfilter 3. 19.103 / 3. 19.103 libswscale 2. 1.101 / 2. 1.101 libswresample 0. 16.100 / 0. 16.100 rtsp://192.168.1.99:7654/test2-rtsp: Invalid data found when processing input Server's output: Thu Oct 18 11:57:51 2012 FFserver started. Thu Oct 18 11:58:01 2012 192.168.1.101 - - [DESCRIBE] "rtsp://192.168.1.99:7654/test2-rtsp RTSP/1.0" 200 167 Segmentation fault (core dumped)
I don't really know what I could be missing. I've just read in the official doc that streaming from a file is kind of broken. Since I don't really know if that's up to date, I decided to give it a try here.
Any help or suggestions? Alternatives?