-
Notifications
You must be signed in to change notification settings - Fork 5
Description
A long-standing known issue that I've experienced is video & audio gradually becoming further out of sync over the duration of a stream. The longer the stream, the worse it is by the end. I've found this is less of an issue on faster hardware, but still exists.
Recently, I've been testing renice(8)-ing fauxstream, sndiod, and ffmpeg processes upon starting my stream to ensure they have the highest priority, e.g. renice -n -20 <pid>. Of course, this must be done as the superuser, which I don't want to run fauxstream itself as. Per the manual:
Users other than the superuser may only alter the priority of processes they own, and can only monotonically increase their “nice value” within the range 0 to
PRIO_MAX(20), which prevents overriding administrative fiats. The superuser may alter the priority of any process and set the priority to any value in the rangePRIO_MIN(-20) toPRIO_MAX.
This may help, but @rfht did some testing in a stream yesterday -- which I unfortunately missed -- and mentioned the following in #openbsd-gaming on Libera.chat:
it looks like using -max_interleave_delta 50000 helps with keeping things in sync
Per the FFmpeg Formats Documentation:
max_interleave_delta integer (output)
Set maximum buffering duration for interleaving. The duration is expressed in microseconds, and defaults to 10000000 (10 seconds).
To ensure all the streams are interleaved correctly, libavformat will wait until it has at least one packet for each stream before actually writing any packets to the output file. When some streams are "sparse" (i.e. there are large gaps between successive packets), this can result in excessive buffering.
This field specifies the maximum difference between the timestamps of the first and the last packet in the muxing queue, above which libavformat will output a packet regardless of whether it has queued a packet for all the streams.
If set to 0, libavformat will continue buffering packets until it has a packet for each stream, regardless of the maximum timestamp difference between the buffered packets.
So, I'll definitely give that a try too on my next stream.