[FFmpeg-user] Using ffmpeg to stream a playlist of videos
Gulag Kulak
gulagkulak at proton.me
Sat Sep 21 23:59:39 EEST 2024
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.
Sometimes it's [flv @ 0x7f5c10686200] Failed to update header with correct duration.
Or [flv @ 0x7f5c10686200] Failed to update header with correct filesize.
Or a whole bunch of [aost#0:1/aac @ 0x8947680] Non-monotonic DTS; previous: 82536459, current: 78988751; changing to 82536460. This may result in incorrect timestamps in the output file.
Or it starts dropping every single frame. I think it happens when it changes from a progressive to deinterlaced file or vice-versa.
How do I make ffmpeg more resilient so it can handle every kind of file thrown at it and output a continuous stream at 1920x1080 and 30fps h264 to a streaming server?
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.
Even used handbrake to try and pre-encode the video files to the same exact format, but even then ffmpeg fails in similar ways, just less often.
After re-encoding with handbrake I tried to concat the videos together with ffmpeg and ended up with a large video where the sound breaks for some parts of it and it stops being seekable in VLC after a certain timecode.
I think I'm missing some important ffmpeg flag or option. Can anyone help me figure this out?
All the best,
gk
More information about the ffmpeg-user
mailing list