Streaming in ffmpeg using RTP

39,403

Assume that the IP of the client is 10.0.0.2

Code to run on server side

ffmpeg -re -thread_queue_size 4 -i source_video_file.mp4 -strict 2 -vcodec copy -an -f rtp rtp://10.0.0.2:6005 -acodec copy -vn -sdp_file saved_sdp_file -f rtp rtp://10.0.0.2:7005

After running this code, an SDP file should be generated named saved_sdp_file. This should be transferred to the client, which needs it to receive the stream

Code to run on client side

ffmpeg -protocol_whitelist "file,rtp,udp" -i saved_sdp_file -strict 2 saved_video_file.mp4

Share:
39,403

Related videos on Youtube

xavier666
Author by

xavier666

Updated on September 18, 2022

Comments

  • xavier666
    xavier666 over 1 year

    Scenario

    I'm trying to stream a video between 2 hosts using RTP. I have previously solved this problem using VLC using the following 2 commands

    Server Side

    cvlc video_file.mp4 --sout "#transcode{vcodec=h264, acodec=mpga, ab=128, channels=2, samplerate=44100}: duplicate{dst=rtp{dst=10.X.X.X, port=5004, mux=ts}}" --run-time 40 vlc://quit

    Client Side

    cvlc rtp://@:5004 --sout "#transcode{vcodec=h264, acodec=mpga, ab=128, channels=2, samplerate=44100}: std{access=file, mux=mp4, dst=downloaded.mp4}" --run-time 40 vlc://quit

    Requirement

    Now I want to achieve the same but with FFMPEG. What would be the equivalent command?

    Work done till now

    Server Side

    ffmpeg -re -i video_file.mp4 -vcodec libx264 -an -f rtp rtp://10.X.X.X:5004 -vn -acodec libtwolame -f rtp rtp://10.X.X.X:5005

    Client Side

    ffmpeg -i rtp://10.X.X.X:5004 -vcodec libx264 -an -i rtp://10.5.19.244:5005 -acodec libtwolame -vn -t 00:00:35 downloaded.mp4

    However, I cannot record the received stream this way.

  • user1747134
    user1747134 almost 5 years
    The client side gives me an error: Unrecognized option '2'.