Search code examples
ffmpegstreaminglivertp

FFmpeg RTP streaming error


I want to broadcast a video file via FFmpeg, but I get this error:

Only one stream supported in the RTP muxer

I get that error when I write this:

ffmpeg.exe -i SomeVideo.mp4 -f rtp rtp://127.0.0.1:11111

I don't know what's wrong.


Solution

  • Your ffmpeg command creates two streams, one for video, one for audio. Do this instead:

    ffmpeg -re -i SomeVideo.mp4 -vcodec copy -an -f rtp rtp://127.0.0.1:11111 -vn -acodec copy -f rtp rtp://127.0.0.1:11112

    Port 11111 then has video without audio (-an).

    Port 11112 then has audio without video (-vn).

    Read each stream with, e.g., ffplay rtp://127.0.0.1:11112.

    (Part of this comes from advice at http://lucabe72.blogspot.com/2010/04/rtp-streaming-with-ffmpeg.html .)

    Edit 2021/08

    The command should be ffmpeg -re -i SomeVideo.mp4 -vcodec copy -an -f rtp rtp://127.0.0.1:11111 -vn -acodec copy -f rtp rtp://127.0.0.1:11113

    • 11111 => video RTP
    • 11112 => video RTCP implicitly
    • 11113 => audio RTP
    • 11114 => audio RTCP implicitly

    Because RTCP port will be set to the RTP port + 1 automatically, or you’d get the bind failed error while playing.

    https://ffmpeg.org/ffmpeg-protocols.html#rtp