[FFmpeg-user] Live Transcoding: What Causes Large Time Gaps from Input to Output

Vilnis Bicevskis vilnis.bicevskis1 at gmail.com
Fri Jan 17 09:04:08 EET 2025


On Wed, Jan 15, 2025 at 1:29 AM Greg Oliver <oliver.greg at gmail.com> wrote:

> On Tue, Jan 14, 2025 at 11:37 AM Shane Warren <shanew at innovsys.com> wrote:
> >
> > I am transcoding live multicast using hardware (decoding using nvidia
> and encoding using nvidia (h264_nvenc) and going out multicast at fixed
> framerate and constant bitrate. Normally the output is about 3-5 seconds
> behind the input.
> >
> > I have some streams that cause the output to eventually get minutes
> behind the input. I've narrowed down the input buffering being the culprit
> of holding a very large buffer of input frames in these situations.
> >
> > Here is my command:
> >
> > ffmpeg -y -threads 2 -nostats -nostdin -loglevel verbose -progress
> pipe:1 -probesize 5M -filter_threads 4 -threads 2 -re -fflags +genpts
> -fflags discardcorrupt -hwaccel_device 0 -extra_hw_frames 2
> -hwaccel_output_format cuda -hwaccel cuda -heavy_compr 1 -thread_queue_size
> 512 -i "udp://@
> 225.105.0.27:10102?fifo_size=1073440&buffer_size=2129920&timeout=800000"
> -autoscale 0 -threads 2 -filter_complex
> "[0:v:0]fps=30000/1001,yadif_cuda,scale_npp=1920:1080:interp_algo=super:format=yuv420p
> [vout]" -map "[vout]" -map "0:a:0" -map 0:d? -filter:a:0
> "aresample=async=10000,volume=1.00"  -c:a:0 aac  -threads 2 -ac:a:0 2
> -ar:a:0 48000 -b:a:0 192k -flush_packets 0 -c:v h264_nvenc -b:v 6000k
> -minrate:v 6000k -maxrate:v 6000k -bufsize:v 12000k -a53cc 1 -tune ll
> -zerolatency 1 -cbr 1 -forced-idr 1 -strict_gop 1 -threads 2 -profile:v
> high -level:v 4.2 -bf:v 0 -g:v 15  -f fifo -drop_pkts_on_overflow 1
> -attempt_recovery 0 -fifo_format mpegts -format_opts
> muxrate=6800440:pes_payload_size=1528 "udp://@225.
> >  105.0.65:10102?pkt_size=1316&bitrate=6800440&burst_bits=10528&ttl=64"
> >
> > I suspect the input stream does something odd and causes ffmpeg to
> buffer frames and it gets slowly behind. I would like to make ffmpeg drop
> frames if possible, instead of forever buffering frames and getting further
> and further out of sync.
> >
> > Is there anything anyone can recommend to force ffmpeg to stop buffering
> input frames?
>
> I imagine the stream is changing somehow.  What is the output (ffmpeg)
> when it happens?  Also, maybe try starting simple  (-preset 8) and
> then fine tuning.
>

Hi!

I would try to remove -re flag from input, so it don't buffer excess
received frames.
It may cause some other frame rate inaccuracies in output though. Maybe it
works.

Vilnis


> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-user mailing list