[FFmpeg-user] [FFmpeg-devel] ffplay buffer
cus at passwd.hu
Sat Aug 29 16:43:12 CEST 2015
On Fri, 28 Aug 2015, Dan Gordon wrote:
> I’m working on a frame accurate stream switch. My current iteration is
> using vapoursynth to serve frames to ffplay. I have the vapoursynth
> script set up to take a keyboard input and then change to stream without
> skipping forward to the next iframe. There is a 500 ms delay between the
> keyboard action and the video switching. The good news is that it is
> frame accurate, the bad news is that 500 ms is a LONG delay. My initial
> assumption was that ffplay had a buffer in place but I dropped the
> MIN_FRAMES to 5 from 25 and the delay is still present (and still at
> ~500 ms).
> I know this isn’t a vapoursynth forum but I’m trying to eliminate ffplay
> as the source of the delay. When ffplay is receiving data from a
> yuv4mpegpipe with MIN_FRAMES set to 5, how much of a delay is there
> between receiving the frames and displaying them? What are the
> EXTERNAL_CLOCK_MIN_FRAMES AND EXTERNAL_CLOCK_MAX_FRAMES for?
> here’s my command
> vspipe -y4m script.vpy - | ffplay pipe: -sync video
This thread is more suitable to ffmpeg-user, so I replied there.
Anyway, based on what you wrote, I guess you want to minimalize latency,
but buffer sizes is only part of that. Probably the initial stream probing
is the main factor in the latency you experience (ffplay only starts
playing the source after probing it, and this will cause a delay), so
consider decreasing probesize.
If you use the -sync ext mode, and hack ffplay to use realtime mode for
pipe input (check is_realtime function in the code), then ffplay will
increase/decrease clock speed based on buffer fullness, and
EXTERNAL_CLOCK_MIN_FRAMES and EXTERNAL_CLOCK_MAX_FRAMES controls when to
increase or decrease the clock speed in this case. This can be used to
minimalize latency, because even if initially there is plenty of data
in the buffers because of probing, after a few minutes ffplay will catch
up thanks to the increased master clock.
This may or may not be suitable for your needs... Probably you will never
achieve 0 frame latency, because ffplay has a buffer on the decoded frame
level as well, see VIDEO_PICTURE_QUEUE_SIZE.
More information about the ffmpeg-user