'How to stream RTP Audio on the internet with ffmpeg?

I have found a solution to transcode a live MP3 stream to RTP in real time:

ffmpeg -re -i "http://<mp3-live-stream>" -acodec mp3 -ab 192k -ac 2 -f rtp rtp://127.0.0.1:1234

If I now open the rtp://127.0.0.1:1234address with ffplay or VLC, it works perfect. This was tested on localhost.

If I put this on a remote server and try to listen to the stream over the internet, I don't get a connection. Unfortunately I'm not very familiar with the RTP protocol and don't know if I need a server component for this.

Goal: Make the RTP stream public over the internet.



Solution 1:[1]

Using the localhost address (127.0.0.1) will only allow playback on the same machine, so in your ffmpeg command use the actual IP address of the receiving machine (or its WAN router). Then you may have to open ports 1234 & 1235 on any firewall on the sending host, and similarly use port forwarding for 1234 & 1235 on any firewall (e.g. in the local router) to the receiving machine's IP. On the receiving machine, instead of 127.0.0.1 use its actual LAN IP. Note that rebroadcasting copyrighted material publicly is illegal without proper licensing.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1