So, first of all, yes, ffmpeg can stream audio and video over RTP. And, as far as I know, there are no major issues with this feature... You just need to know how to do it.
Let's see... The simplest command line you can use to generate an RTP session composed by an audio stream and a video stream is:
Analysing this command line:
ffmpeg -re -i input.mpg -vcodec copy -an -f rtp rtp://224.10.20.30:20000 -vn -acodec copy -f rtp rtp://224.10.20.30:30000 -newaudio
- "-re" is needed to stream the audio and the video at the correct rate (instead of streaming as fast as possible)
- "input.mpg" is the input file, to be streamed
- this example just streams the audio and the video tracks without re-encoding them... Hence, "-vcodec copy" and "-acodec copy"
- we need one output for the video, and one for the audio. Hence, the first output has "-an" (no audio), the second output has "-vn" (no video), and there is a "-newaudio" at the end (add the audio track to the second output)
- the output format has to be RTP. Hence, "-f rtp"
- the output protocol, has to be RPT, hence, the output file names are "rtp://
: "
After you start the ffmpeg program, it will print something like
[...]
Stream #0.1 -> #1.0
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 52.61.0
m=video 20000 RTP/AVP 32
c=IN IP4 224.10.20.30
b=AS:104857
m=audio 30000 RTP/AVP 14
c=IN IP4 224.10.20.30
b=AS:64
[...]
You need to copy the SDP description (starting with "v=0") in a .sdp file, that you will use to play the stream with vlc, ffplay, mplayer, or your favorite video player.
That's it!!!
More details will probably come in the future...
hey thanks for the lovely post.can ffmpeg take input from two streams of RTP(one for audio and video) and then transrate and give the output to two streams as given in the above sample
ReplyDeleteHi-
DeleteI sued the following command.
/usr/local/ffmpeg/bin/ffmpeg -re -i school.mp4 -vcodec copy -an -f rtp rtp://23.20.152.99:7010 -vn -acodec copy -f rtp rtp://23.20.152.99:7012 -newaudio
Where "23.20.152.99" is Darwin server.
But I get the following error when I tried to execute the ffmpeg command.
Missing argument for option 'newaudio'
I appreciate your help.
Thanks,
Sasi
replace with -map 0
Deletehello, ffmpeg can trans rate stream 2mb to 1mb
ReplyDeleteHello.
ReplyDeleteI´m getting only the audio from my stream opening a .SDP with VLC.
I´m using Windows.
Any help?
guys can anyone tell me how to play ffmpeg stream in vlcj
ReplyDelete