https://github.com/videolan/vlc
Revision 07d8bc705da7fbb84344340d91504840b3300674 authored by Alexandre Janniaux on 08 March 2023, 16:50:47 UTC, committed by Steve Lhomme on 14 March 2023, 09:24:17 UTC
When PCR discontinuities happens, the whole pipeline is reset and it
safely (though after a glitch) reset back to playback on what's visible
after the PCR discontinuities, and restart buffering.

However, this PCR discontinuity currently happens only when **not** in
buffering. When it happens during buffering, then:

 - either the PCR value is much bigger than expected, and buffering will
   stop sooner than expected.

    | Buffer start      Buffer end    New PCR
    | v                          v    v
    | |------.-------------------|    |
    |        ^
    | Old PCR  |----------------------|
    |             Missing buffering
    +-- Resulting buffer after PCR jump to the future.

 - or the PCR value is much smaller than expected, and the buffering is
   completely borked, the computed stream buffer duration is negative
   and it would buffer for the time of the

    | New PCR         Buffer start     Buffer  end
    | v               v                          v
    | |---------------|------.-------------------|
    |                        ^
    |                 Old PCR
    |
    |              Total buffering:
    |
    |  Buffering after the PCR jump
    | |------------------------------------------|
    |                    +
    |                 |------|
    |                 Previous additional buffering
    |
    +-- Resulting buffer after PCR jump to the past.

The second behaviour can be visible when disabling the __MAX for the
caching progress value, leading to logs like:

    [000055df326370e0] main input debug: Buffering 0%
    [000055df326370e0] main input debug: Buffering 1%
    [000055df326370e0] main input debug: Buffering 2%
    [000055df326370e0] main input debug: Buffering 3%
    [000055df326370e0] main input debug: Buffering 4%
    [000055df326370e0] main input debug: Buffering 5%
    [000055df326370e0] main input debug: Buffering 6%
    [000055df326370e0] main input debug: Buffering 7%
    [000055df326370e0] main input debug: Buffering -99%
    [000055df326370e0] main input debug: Buffering -98%
    ...

Such scenario can be created by streaming a .ts file with the option
--ts-trust-pcr on udp://127.0.0.1:1234 for instance, while running
ffmpeg with:

    ffmpeg -re -i input_file.ts -f mpegts udp://127.0.0.1:1234

During buffering, interrupt and restart the ffmpeg streaming command.
The value in --network-caching can also be increase to ensure easier
reproduction of the scenario.

Instead, if PCR is going back to the past, flush the pipeline and reset
the buffering back to zero to avoid waiting for the stream to catch-up
with the old reference, and avoid buffering more than what we requested,
which would shift the playback more from the live.

    | - Step 1:
    | New PCR         Buffer start     Buffer  end
    | v               v                          v
    | |---------------|------.-------------------|
    |                        ^
    |                 Old PCR
    |
    | - Step 2:
    |                 Previous buffering is dropped.
    |                 |------|
    | |--------------------------|
    | ^                          ^
    | New PCR                    New buffer end
    |
    |
    +-- New buffering behaviour when PCR jumps to the past.
1 parent 3ccf6ae
History
Tip revision: 07d8bc705da7fbb84344340d91504840b3300674 authored by Alexandre Janniaux on 08 March 2023, 16:50:47 UTC
input: es_out: reset buffering on PCR discontinuity
Tip revision: 07d8bc7
File Mode Size
autotools
bin
buildsystem
compat
contrib
doc
extras
include
lib
m4
modules
po
share
src
test
.gitignore -rw-r--r-- 471 bytes
.mailmap -rw-r--r-- 7.1 KB
AUTHORS -rw-r--r-- 18.7 KB
COPYING -rw-r--r-- 17.7 KB
COPYING.LIB -rw-r--r-- 25.9 KB
INSTALL -rw-r--r-- 1.4 KB
Makefile.am -rw-r--r-- 6.5 KB
NEWS -rw-r--r-- 202.7 KB
README.md -rw-r--r-- 5.6 KB
THANKS -rw-r--r-- 5.5 KB
bootstrap -rwxr-xr-x 1.8 KB
config.h.meson -rw-r--r-- 15.5 KB
configure.ac -rw-r--r-- 140.3 KB
make-alias -rwxr-xr-x 299 bytes
meson.build -rw-r--r-- 32.2 KB
meson_options.txt -rw-r--r-- 14.3 KB

README.md

back to top