What steps are needed to stream RTSP from FFmpeg?

前端 未结 4 1094
耶瑟儿~
耶瑟儿~ 2020-12-23 18:53

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 c

4条回答
  •  执笔经年
    2020-12-23 19:22

    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.

提交回复
热议问题