Skip to content

Instantly share code, notes, and snippets.

@shinyzhu
Last active December 18, 2022 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinyzhu/1a9629377a3df29f7a86a07c3bd4fcd2 to your computer and use it in GitHub Desktop.
Save shinyzhu/1a9629377a3df29f7a86a07c3bd4fcd2 to your computer and use it in GitHub Desktop.
Live streaming forever with ffmpeg
ffconcat version 1.0
file dirtrhodes.mp3
file ddgrove.mp3
file hustle.mp3
file mapoftexas.mp3
file nothingmuch.mp3
file slowburn.mp3
file wildyou.mp3
file audiofiles.txt

Loop Live Streaming with ffmpeg

Run ffmpeg in a separate screen.

screen -S stream

Then run the streaming script.

Use Ctrl+A,D to detach the stream screen.

Then you can exit your shell.

start_stream()
{
ffmpeg \
-stream_loop -1 \
-re \
-i car.mp4 \
-re \
-f concat -i audiofiles.txt \
-c:v libx264 -preset superfast -r 24 \
-c:a aac -b:a 128k \
-strict \
-2 \
-f flv "${target_rtmp}${stream_key}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment