FFmpeg command: stream generated raw video over RTSP

13,431

You have to define your output streaming source at end of the command. You need to define your ffmpeg command all elements to match with the streaming format.For example if you are streaming over UDP you can use command similar to this.

ffmpeg -i (your input) -r 10 -vcodec mpeg4 -f mpegts udp://127.0.0.1:1234

You can test UDP stream using VLC or ffplay player. However if you want to stream over RTSP, easiest solution would be to use a media server such as Wowza or Red5. Red5 is an open source media server and it is bit confusing for beginners. Wowza is a paid media server but provides better documentation and support service. If you are using RTMP protocol you can use command similar to this.

ffmpeg -i (your input) -r 10 -vcodec libx264 -pix_fmt yuv420p -f flv "rtmp://(IpAddress):(portnumber)/live/myStream flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=myApplication pubUser=myRTMP connection pubPasswd=password"

Also you can use ffserver (Ffmpeg media server) for RTMP. But it is only available for Linux operating systems.

Share:
13,431

Related videos on Youtube

Jan Discart
Author by

Jan Discart

Updated on June 04, 2022

Comments

  • Jan Discart
    Jan Discart almost 2 years

    I'm looking into using FFmpeg for streaming an output generated by an application to another system in the same network. However, I find the list of commands a little daunting and hard to understand. So I hope I can ask your help in the matter.

    My current usecase: I have a Unity application which has a separate output stream of video and using a plugin I'm able to save that output to a videofile. The command used is to save this to file is:

    ffmpeg -y -f rawvideo -vcodec rawvideo -pixel_format rgba -colorspace bt709 -video_size 1280x720 -framerate 30 -loglevel warning -i - -pix_fmt yuv444p -preset ultrafast -crf 0 test.mp4
    

    The output format and such are already correct, but I'd like to stream this output directly over a network now, preferably using RTSP. Using the command below, where I replaced the test.mp4 at the end with udp://127.0.0.1:23000 to test streaming over UDP, but this returns an IOException in Unity.

    Any help in guiding me in the right direction is greatly appreciated. Thanks in advance!

    • the kamilz
      the kamilz about 6 years
      it is never good idea to stream raw files over network, I guess when you used mp4 file, ffmpeg probably encodes the output, in case of UDP (or rtp or rtps) you should explicitly tell the ffmpeg to encode stream before output. And for streaming mostly yuv420 used as pixel format and most of codecs expect this (like mpeg2, mpeg4 avc.)
    • Jan Discart
      Jan Discart about 6 years
      @thekamilz Thanks for your comment. The input is raw video, and I believe the arguments given relate to the input. But are you saying that there are additional arguments missing for the output that defines the encoding and format? I am aware that it's not ideal to send raw video over a netwrok though, so additional optimisations are certainly welcome.