[FFmpeg-user] Question about delay when displaying selected keyframes

Sachin Bhat sachinbhat694 at gmail.com
Tue Jul 2 18:20:54 EEST 2024


Hi,

I have an input ts file that is at 30 fps, and a GOP of 10. I am trying to
display keyframes at a specific time interval by sending a keyframe plus
duplicates to a HW decoder until the next desired keyframe appears. .I am
using duplication because the HW decoder does not handle very low
framerates well, and I have been led to believe that the duplicate frames
are just copies of the keyframe, so they do not contribute greatly to
bandwidth usage after transcoding.  As a result, I get the illusion of a
low framerate video while actually producing a 30fps stream.

The command I am using to send a keyframe every 10 seconds (every 30th
keyframe):
ffmpeg -re -i test-src-30fps.ts -vf "select='eq(pict_type, I)',
select='not(mod(n,30))'" -vsync cfr -c:v libx264 -f mpegts
udp://{decoder_ip}:{decoder_port}

However, when I run this command, the nth keyframe is only displayed once
the n+1 keyframe is reached. For example, the output log says: frame = 1
fps=0.1 q=0.0 size=0kB time=00:00:00.00 bitrate=N/A for a certain amount of
time, then frame=301 fps=27 q=29.0 size=58kb time=00:00:07.33 bitrate =
65.2 kb/s dup = 301 speed = 0.85x. As a result every keyframe ends up being
displayed at a large delay to when it appears in the actual input stream.
The delay increases if I increase the interval for my desired keyframes. On
the decoder side I can see that the output is 30fps.

Can someone explain why this is happening, and if there is a way to have a
fixed delay regardless of how often I want to select a keyframe?

Thanks,
Sachin


More information about the ffmpeg-user mailing list