TransWikia.com

Streaming RTSP with ffmpeg?

Super User Asked by Candy on November 22, 2021

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.

One Answer

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.

Answered by Rob van der Leek on November 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP