Ffmpeg rtsp streaming linux

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?

ffmpeg itself can stream over RTP. Better than UDP, but you need to agree on the format, which is why RTP is usually managed via RTSP. But ffmpeg . -f rtp rtp://destination/streamID:54321 will send a continuous RTP stream to port 54321 on ‘destination’.

4 Answers 4

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 File /tmp/feed1.ffm FileMaxSize 2M ACL allow 127.0.0.1 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 

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.

Читайте также:  Узнать свою версию линукс

@user1767754 Are there any alternatives to ffserver due to it’s deprecation? Would you suggeset live555?

hello i want to stream from mobile, how can i do that. i have created ffserver and i have installed Larix broadcaster mobile app to my mobile. in which i have added url like this rtsp://:/fedd1.ffm but its not connecting

When I try the ffmpeg it just says «Connection to tcp://localhost:1234 failed: Connection refused» — any ideas? — it works with udp:// but when I do localhost:1234/feed1.ffm I see the connection refused message.

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

    Create a configuration file for the RTSP server called rtsp-simple-server.yml with this single line:

$ 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.

I’m completely blown away with how easy simple-rtsp-server is to configure, yet how powerful it is. Even includes a HLS server at no additional cost. This thing is awesome, thanks for suggesting it!

Another streaming command I’ve had good results with is piping the ffmpeg output to vlc to create a stream. If you don’t have these installed, you can add them:

sudo apt install vlc ffmpeg 

In the example I use an mpeg transport stream (ts) over http, instead of rtsp. I’ve tried both, but the http ts stream seems to work glitch-free on my playback devices.

Читайте также:  Huawei pc manager linux

I’m using a video capture HDMI>USB device that sets itself up on the video4linux2 driver as input. Piping through vlc must be CPU-friendly, because my old dual-core Pentium CPU is able to do the real-time encoding with no dropped frames. I’ve also had audio-sync issues with some of the other methods, where this method always has perfect audio-sync.

You will have to adjust the command for your device or file. If you’re using a file as input, you won’t need all that v4l2 and alsa stuff. Here’s the ffmpeg|vlc command:

ffmpeg -thread_queue_size 1024 -f video4linux2 -input_format mjpeg -i /dev/video0 -r 30 -f alsa -ac 1 -thread_queue_size 1024 -i hw:1,0 -acodec aac -vcodec libx264 -preset ultrafast -crf 18 -s hd720 -vf format=yuv420p -profile:v main -threads 0 -f mpegts -|vlc -I dummy - --sout='#std' 

For example, lets say your server PC IP is 192.168.0.10, then the stream can be played by this command:

ffplay http://192.168.0.10:8554 #or vlc http://192.168.0.10:8554 

UPDATE: Here is a command to use VLC for rtsp, instead of using the rtsp-simple-server:

ffmpeg -thread_queue_size 1024 -f video4linux2 -input_format mjpeg -video_size 1280x720 -r 30 -i /dev/video0 -f alsa -thread_queue_size 1024 -i plughw:CARD=MS2109,DEV=0 -acodec mp2 -vcodec libx264 -preset ultrafast -crf 20 -s hd720 -vf format=yuv420p -profile:v main -f mpegts -|vlc -I dummy - --sout='#rtp --sout-all --sout-keep' 

If your PC ip is 192.168.0.10, then the rtsp stream is played by this command:

Источник

Streaming RTSP with ffmpeg?

So I have been able to successfully send an RTP video stream from my server to the client on another system on the LAN and play it using ffplay. I now want to send the video on the same network using RTSP so that the client can receive the video and can have additional options like pausing the video etc. Can anyone give me a general guideline or point me to a resource that can help me in accomplishing my task? UPDATE: I have tried these commands:

ffmpeg -re -i input -f rtsp -rtsp_transport tcp rtsp://localhost:8888/live.sdp ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp 

It does start streaming the video in real-time but I don’t actually see any options to control the media stream like playback, record etc! NB: The .sdp file I am currently using for RTSP is the same as the one I used for RTP streaming.

Читайте также:  Err address unreachable linux

1 Answer 1

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

    Create a configuration file for the RTSP server called rtsp-simple-server.yml with this single line:

$ 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.

Источник

Оцените статью
Adblock
detector