[FFmpeg-user] ffplay AC3 playback latency

Jacob S. Moroni mail at jakemoroni.com
Mon Nov 23 17:31:26 EET 2020


Hello,

I have a data source that is providing an AC3 bitstream in real time via an
external interface. I am piping this into ffplay, which I’m using to decode it
and play it back through my soundcard for live listening. This bitstream is
coming from a video game console, so it’s important to have as little latency
as possible.

I’m running Linux with Pulseaudio. I have configured Pulseaudio such that
my sound card (sink) has a fixed 8 millisecond latency, and the incoming
bitstream coming from the external interface has under 2 milliseconds of
latency.

The command I’m using is “ffplay -fflags nobuffer -”.

Here’s the thing: normally, this works great, with no significant latency.
If I run “pactl list sink-inputs”, I see about 20 milliseconds of latency, and
the sink itself reports about 8 milliseconds. However, sometimes the
latency is large - like 400 milliseconds. I have no idea why this happens.
Killing and restarting ffplay fixes it though.

As a test, I modified SDL_AUDIO_MAX_CALLBACKS_PER_SEC to a high
value such that the resulting SDL buffer size is always 512 (the minimum).
This didn’t really help.

Any ideas where this extra buffering is coming from and how to eliminate it?

Also keep in mind that the soundcard and data source are on two separate
clock domains, so I guess I’ll need ffplay to continue performing asynchronous
sample rate conversion (assuming it does that already?).

Thanks!


More information about the ffmpeg-user mailing list