Skip to content

Instantly share code, notes, and snippets.

@hdsdi3g
Created January 29, 2023 22:47
Show Gist options
  • Save hdsdi3g/4bcf53a806a8288710c8640d17c4a50e to your computer and use it in GitHub Desktop.
Save hdsdi3g/4bcf53a806a8288710c8640d17c4a50e to your computer and use it in GitHub Desktop.
Live PCM over mpegts/RTP/UDP, with decoder
# Coder
ffmpeg -re -stream_loop -1 -i <source.wav> -strict -2 -c:a s302m -f rtp_mpegts "udp://127.0.0.1:1234"
# or just
ffmpeg -i <source live> -strict -2 -c:a s302m -f rtp_mpegts "udp://127.0.0.1:1234"
# Decoder
ffmpeg -strict -2 -c:a s302m -i rtp://127.0.0.1:1234 -c pcm_s16le -f wav - | ffplay -nodisp -
# or just
ffmpeg -strict -2 -c:a s302m -i rtp://127.0.0.1:1234 -c pcm_s16le -f wav <dest.wav>
# Decoder must skip a lot of frames to start to get decodable signal, so please wait about 20 sec. to start and get audio.
# Add "-fec prompeg=l=16:d=8" seems to stabilize the signal (no more "frame has invalid header" and "Error while decoding stream #0:0: Invalid data found when processing input"), used like:
ffmpeg <source> -c:a s302m -f rtp_mpegts -fec prompeg=l=16:d=8 "udp://127.0.0.1:1234"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment