Skip to content

Commit

Permalink
demux: add a back buffer and the ability to seek into it
Browse files Browse the repository at this point in the history
This improves upon the previous commit, and partially rewrites it (and
other code). It does:

- disable the seeking within cache by default, and add an option to
  control it
- mess with the buffer estimation reporting code, which will most likely
  lead to funny regressions even if the new features are not enabled
- add a back buffer to the packet cache
- enhance the seek code so you can seek into the back buffer
- unnecessarily change a bunch of other stuff for no reason
- fuck up everything and vomit ponies and rainbows

This should actually be pretty usable. One thing we should add are some
properties to report the proper buffer state. Then the OSC could show a
nice buffer range. Also configuration of the buffers could be made
simpler. Once this has been tested enough, it can be enabled by default,
and might replace the stream cache's byte ringbuffer.

In addition it may or may not be possible to keep other buffer ranges
when seeking outside of the current range, but that would be much more
complex.
  • Loading branch information
wm4 committed Oct 21, 2017
1 parent 83c9f16 commit 719a435
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 157 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes.rst
Expand Up @@ -45,6 +45,7 @@ Interface changes
audio output drivers for quite a while (coreaudio used to provide it)
- deprecate --videotoolbox-format (use --hwdec-image-format, which affects
most other hwaccels)
- remove deprecated --demuxer-max-packets
--- mpv 0.27.0 ---
- drop previously deprecated --field-dominance option
- drop previously deprecated "osd" command
Expand Down
30 changes: 25 additions & 5 deletions DOCS/man/options.rst
Expand Up @@ -2839,11 +2839,31 @@ Demuxer

See ``--list-options`` for defaults and value range.

``--demuxer-max-packets=<packets>``
Quite similar ``--demuxer-max-bytes=<bytes>``. Deprecated, because the
other option does basically the same job. Since mpv 0.25.0, the code
tries to account for per-packet overhead, which is why this option becomes
rather pointless.
``--demuxer-max-back-bytes=<value>``
This controls how much past data the demuxer is allowed to preserve. This
is useful only if the ``--demuxer-seekable-cache`` option is enabled.
Unlike the forward cache, there is no control how many seconds are actually
cached - it will simply use as much memory this option allows. Setting this
option to 0 will strictly disable any back buffer.

Keep in mind that other buffers in the player (like decoders) will cause the
demuxer to cache "future" frames in the back buffer, which can skew the
impression about how much data the backbuffer contains.

See ``--list-options`` for defaults and value range.

``--demuxer-seekable-cache=<yes|no>``
This controls whether seeking can use the demuxer cache (default: no). If
enabled, short seek offsets will not trigger a low level demuxer seek
(which means for example that slow network round trips or FFmpeg seek bugs
can be avoided). If a seek cannot happen within the cached range, a low
level seek will be triggered. Seeking outside of the cache will always
discard the full cache.

Keep in mind that some events can flush the cache or force a low level
seek anyway, such as switching tracks, or attmepting to seek before the
start or after the end of the file. This option is experimental - thus
disabled, and bugs are to be expected.

``--demuxer-thread=<yes|no>``
Run the demuxer in a separate thread, and let it prefetch a certain amount
Expand Down

0 comments on commit 719a435

Please sign in to comment.