[FFmpeg-user] Using ffmpeg to stream a playlist of videos

Oliver Fromme oliver at fromme.com
Sun Sep 22 19:16:56 EEST 2024


Gulag Kulak via ffmpeg-user wrote:
 > Hi!
 >
 > I'm trying to use ffmpeg to stream a playlist of video files that are
 > all in very different formats, sizes, and aspect ratios.
 >
 > The problem is that often when the video changes I get a spinning
 > wheel of death on the target streaming sites and some kinda error in
 > the ffmpeg output.
 >[...]
 > This is the command I'm using:
 > 
 > ffmpeg -stream_loop -1 -re -f concat -i playlist.txt -threads 4 -c:v libx264 -preset ultrafast \
 > -b:v 2000k -maxrate 2000k -g 30 -c:a aac -b:a 128k -strict -2 -fflags +genpts+discardcorrupt \
 > -async 1 -map 0 -r 30 -s 1920x1080 -bufsize 6000k -flags +cgop -fflags +igndts \
 > -f tee -rtsp_transport tcp -max_delay 1000 \
 > "[f=flv:onfail=ignore]rtmp://xxxxxxxxxxxxxxx.com/live/xxxxxxxxxxxxxxx|[f=flv:onfail=ignore]rtmp://xxxxxxxxxxxxxxx.com/live/xxxxxxxxxxxxxxx"
 >
 > And it's not working. ffmpeg just fails in a variety of ways. I've
 > spent two days trying to figure this out.

I'm afraid the "concat" demuxer does not work the way you want.
Quote from the documentation of the concat demuxer:  "All files must
have the same streams (same codecs, same time base, etc.)."

As far as I'm aware of, there is no easy way to handle files with
different streams, codecs, resolution, aspect ratio etc. within a
single invocation of FFmpeg.

If your playlist is static, the easiest way is probably to transcode
all files so they have the same properties, then you can use concat
to stream those.

Best regards
 -- Oliver


More information about the ffmpeg-user mailing list