What steps are needed to stream RTSP from FFmpeg?
Streaming UDP is not a problem, but as I want to stream to mobile devices which can natively read RTSP streams, I couldn't find any setup which tells what exactly is needed. Do I need an RTSP streaming server like LIVE555 or can I use FFmpeg only?
My Command:
ffmpeg -i space.mp4 -vcodec libx264 -tune zerolatency -crf 18 -f rtsp -muxdelay 0.1 rtsp://192.168.1.200:1234
I get an Input/Output error.
Do I need a SDP description to use RTSP? And if yes where do I have to put it?
Step 1: Download and install VLC Player from http://www.videolan.org/vlc/. Step 2: Open VLC player and select“Open Network Stream”from the Media menu. Step 3: Type the network URL in the dialog box below, and then click Play to play the video with RTSP stream.
To start live streaming with FFmpeg, you have to download and install the software on your computer. You can choose the right installation method for your operating system from the three options above in this FFmpeg tutorial. At this point, you can also create a streaming channel on your video hosting platform.
How RTSP works. When a user or application attempts to stream video from a remote source, the client device sends an RTSP request to the server to determine the available options, such as pause, play and record. The server then returns a list of the types of requests it can accept through RTSP.
You can use FFserver to stream a video using RTSP.
Just change console syntax to something like this:
ffmpeg -i space.mp4 -vcodec libx264 -tune zerolatency -crf 18 http://localhost:1234/feed1.ffm
Create a ffserver.config
file (sample) where you declare HTTPPort
, RTSPPort
and SDP stream. Your config file could look like this (some important stuff might be missing):
HTTPPort 1234 RTSPPort 1235 <Feed feed1.ffm> File /tmp/feed1.ffm FileMaxSize 2M ACL allow 127.0.0.1 </Feed> <Stream test1.sdp> Feed feed1.ffm Format rtp Noaudio VideoCodec libx264 AVOptionVideo flags +global_header AVOptionVideo me_range 16 AVOptionVideo qdiff 4 AVOptionVideo qmin 10 AVOptionVideo qmax 51 ACL allow 192.168.0.0 192.168.255.255 </Stream>
With such setup you can watch the stream with i.e. VLC by typing:
rtsp://192.168.0.xxx:1235/test1.sdp
Here is the FFserver documentation.
FWIW, I was able to setup a local RTSP server for testing purposes using simple-rtsp-server and ffmpeg following these steps:
rtsp-simple-server.yml
with this single line: protocols: [tcp]
$ docker run --rm -it -v $PWD/rtsp-simple-server.yml:/rtsp-simple-server.yml -p 8554:8554 aler9/rtsp-simple-server
$ ffmpeg -re -stream_loop -1 -i test.mp4 -f rtsp -rtsp_transport tcp rtsp://localhost:8554/live.stream
Once you have that running you can use ffplay to view the stream:
$ ffplay -rtsp_transport tcp rtsp://localhost:8554/live.stream
Note that simple-rtsp-server can also handle UDP streams (i.s.o. TCP) but that's tricky running the server as a Docker container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With