Reputation: 1077
As I am trying to connect the VLC Python Bindings with ffmpeg (see Exchange data between ffmpeg and video player) I thought that making ffmpeg to output the RTSP stream to STDOUT and "catching" it with a Python script and sending over HTTP would be a good idea. So I made a tiny HTTP server using SimpleHTTPServer from which I get the STDIN from FFMpeg and "output" it to the web.
This is the syntax I am using:
ffmpeg.exe -y -i rtsp://fms30.mediadirect.ro/live/utv/utv?tcp -acodec copy -vcodec copy -f flv - | \Python27\python.exe -u stdin2http.py
This seems to work, I can access the stream but nor the video, nor audio is playing. I tried with VLC on Windows, VLC and MPlayer on Linux and no success. Simply running
ffmpeg.exe -y -i rtsp://fms30.mediadirect.ro/live/utv/utv?tcp -acodec copy -vcodec copy -f flv - | vlc.exe -
works perfectly. So the problem seems to be when I'm writing the data from stdin to the web server. What I am doing wrong?
Upvotes: 2
Views: 7633
Reputation: 13256
I played around with your stdin2http.py script. First, I was able to stream a media file (H.264 .mp4 file in my case) from a simple web server (webfsd) to VLC via HTTP. Then I tried the same thing using 'stdin2http.py < h264-file.mp4'. It didn't take.
I used the 'ngrep' utility to study the difference in the network conversations between the 2 servers. I think if you want to make this approach work, you will need to make stdin2http.py smarter and work with HTTP content ranges (which might involve a certain amount of buffering stdin data in your script in order to deal possible jumps in the stream).
Upvotes: 2