Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What steps are needed to stream RTSP from FFmpeg?

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?

like image 281
user1767754 Avatar asked Nov 18 '14 16:11

user1767754


People also ask

How do I stream RTSP?

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.

How do I livestream with FFmpeg?

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 does RTSP stream work?

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.


2 Answers

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.

like image 94
grzebyk Avatar answered Sep 23 '22 04:09

grzebyk


FWIW, I was able to setup a local RTSP server for testing purposes using simple-rtsp-server and ffmpeg following these steps:

  1. Create a configuration file for the RTSP server called rtsp-simple-server.yml with this single line:
    protocols: [tcp] 
  2. Start the RTSP server as a Docker container:
    $ docker run --rm -it -v $PWD/rtsp-simple-server.yml:/rtsp-simple-server.yml -p 8554:8554 aler9/rtsp-simple-server 
  3. Use ffmpeg to stream a video file (looping forever) to the 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.

like image 31
Rob van der Leek Avatar answered Sep 23 '22 04:09

Rob van der Leek