Reputation: 3620
I've got the following docker that streams out some sample sine wav via UDP port 1234:
from ubuntu
RUN apt update
RUN apt install -y ffmpeg
EXPOSE 1234/udp
CMD ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://localhost:1234
I run the container using:
docker run -p 127.0.0.1:1234:1234/udp xxxx
Now I try to open VLC and play that stream from my host machine using the stream URL rtp://@:1234 as instructed by VLC. It plays nothing. Silence. However, if I run the same ffmpeg cmd from the host machine, it works and I can hear the sample.
Any ideas what's going on?
Upvotes: 2
Views: 2089
Reputation: 3620
Found the problem. I guess I misunderstood RTP. ffmpeg is expected to send the RTP packets to a "server" (peer, actually) outside the container (i.e. my host machine). It was not "serving" the sample audio like an RTSP server...
So I don't need to expose any ports. The problem was the rtp url on the container side - it should target the host machine's IP:
ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://$HOST_MACHINE_IP:1234
And its the VLC app that is actually the peer. Once I do it, VLC can receive the stream - no problem.
Upvotes: 4