Command line video player
Go to file
wm4 7fad173cfd demux, demux_edl: add extension for tracks sourced from separate streams
This commit adds an extension to mpv EDL, which basically allows you to
do the same as --audio-file, --external-file, etc. in a single EDL file.

This is a relatively quick & dirty implementation. The dirty part lies
in the fact that several shortcuts are taken. For example, struct
timeline now forms a singly linked list, which is really weird, but also
means the other timeline using demuxers (cue, mkv) don't need to be
touched. Also, memory management becomes even worse (weird object
ownership rules that are just fragile WTFs). There are some other
dubious small changes, mostly related to the weird representation of
separate streams.

demux_timeline.c contains the actual implementation of the separate
stream handling. For the most part, most things that used to be on the
top level are now in struct virtual_source, of which one for each
separate stream exists. This is basically like running multiple
demux_edl.c in parallel. Some changes could strictly speaking be split
into a separate commit, such as the stream_map type change.

Mostly untested. Seems to work for the intended purpose. Potential for
regressions for other timeline uses (like ordered chapters) is probably
low. One thing which could definitely break and which I didn't test is
the pseudo-DASH fragmented EDL code, of which ytdl can trigger various
forms in obscure situations. (Uh why don't we have a test suite.)

Background:

The intention is to use this for the ytdl wrapper. A certain streaming
site from a particularly brain damaged and plain evil Silicon Valley
company usually provides streams as separate audio and video streams.
The ytdl wrapper simply does use audio-add (i.e. adding it as external
track, like with --audio-file), which works mostly fine. Unfortunately,
mpv manages caching completely separately for external files. This has
the following potential problems:

1. Seek ranges are rendered incorrectly. They always use the "main"
stream, in this case the video stream. E.g. clicking into a cached range
on the OSC could trigger a low level seek if the audio stream is
actually not cached at the target position.

2. The stream cache bloats unnecessarily. Each stream may allocate the
full configured maximum cache size, which is not what the user intends
to do. Cached ranges are not pruned the same way, which creates disjoint
cache ranges, which only use memory and won't help with fast seeking or
playback.

3. mpv will try to aggressively read from both streams. This is done
from different threads, with no regard which stream is more important.
So it might happen that one stream starves the other one, especially if
they have different bitrates.

4. Every stream will use a separate thread, which is an unnecessary
waste of system resources.

In theory, the following solutions are available (this commit works
towards D):

A. Centrally manage reading and caching of all streams. A single thread
would do all I/O, and decide from which stream it should read next. As
long as the total TCP/socket buffering is not too high, this should be
effective to avoid starvation issues. This can also manage the cached
ranges better. It would also get rid of the quite useless additional
demuxer threads. This solution is conceptually simple, but requires
refactoring the entire demuxer middle layer.

B. Attempt to coordinate the demuxer threads. This would maintain a
shared cache and readahead state to solve the mentioned problems
explicitly. While this sounds simple and like an incremental change,
it's probably hard to implement, creates more messy special cases,
solution A. seems just a better and simpler variant of this. (On the
other hand, A. requires refactoring more code.)

C. Render an intersection of the seek ranges across all streams. This
fixes only problem 1.

D. Merge all streams in a dedicated wrapper demuxer. The general demuxer
layer remains unchanged, and reading from separate streams is handled as
special case. This effectively achieves the same as A. In particular,
caching is simply handled by the usual demuxer cache layer, which sees
the wrapper demuxer as a single stream of interleaved packets. One
implementation variant of this is to reuse the EDL infrastructure, which
this commit does.

All in all, solution A would be preferable, because it's cleaner and
works for all external streams in general.

Some previous commit tried to prepare for implementing solution A. This
could still happen. But it could take years until this is finally
seriously started and finished. In any case, this commit doesn't block
or complicate such attempts, which is also why it's the way to go.

It's worth mentioning that original mplayer handles external files by
creating a wrapper demuxer. This is like a less ideal mixture of A. and
D. (The similarity with A. is that extending the mplayer approach to be
fully dynamic and without certain disadvantages caused by the wrapper
would end up with A. anyway. The similarity with D. is that due to the
wrapper, no higher level code needs to be changed.)
2019-09-19 20:37:04 +02:00
.github github: recommend 0x0.st rather than sprunge.us for logfiles 2018-02-16 00:59:25 -08:00
DOCS demux, demux_edl: add extension for tracks sourced from separate streams 2019-09-19 20:37:04 +02:00
TOOLS TOOLS/travis-rebuild-website: update condition after docker transition 2019-07-30 20:12:33 +01:00
audio ao_opensles: fix delayed audio 2019-09-02 00:38:05 +03:00
ci ci: remove now unuspported libdvdread 2019-09-13 18:19:50 +02:00
common encode: set sample_aspect_ratio on AVStream struct 2019-08-14 21:54:44 +02:00
demux demux, demux_edl: add extension for tracks sourced from separate streams 2019-09-19 20:37:04 +02:00
etc docs: add removed properties and options to interface-changes.rst 2018-12-06 19:14:14 +01:00
filters Merge branch 'master' into pr6360 2019-03-11 01:00:27 +02:00
input Merge commit '559a400ac36e75a8d73ba263fd7fa6736df1c2da' into wm4-commits--merge-edition 2018-12-05 19:19:24 +01:00
libmpv drm: fix libmpv ABI breakage introduced in 351c083487 2019-09-18 23:59:32 +03:00
misc rendezvous: fix a typo 2018-10-01 10:41:01 +02:00
options DOCS: remove references to --video-stereo-mode 2019-09-14 21:16:38 +02:00
osdep cocoa-cb: migrate to swift 5 with swift 4 fallback 2019-07-21 18:13:07 +03:00
player stream: redo buffer handling and allow arbitrary size for stream_peek() 2019-09-19 20:37:04 +02:00
stream stream: redo buffer handling and allow arbitrary size for stream_peek() 2019-09-19 20:37:04 +02:00
sub sub/sd_ass: always set the libass track type to TRACK_TYPE_ASS 2019-09-19 00:02:03 +03:00
ta ta: introduce talloc_dup() and use it in some places 2018-01-18 01:42:36 -08:00
test misc: add linked list helpers 2018-05-24 19:56:35 +02:00
video wayland: fix wl_proxy leak 2019-09-19 00:00:19 +03:00
waftools build: silence idiotic -Wformat-truncation 2019-09-19 20:37:04 +02:00
.gitignore player: move builtin profiles to a separate file 2016-09-15 14:50:38 +02:00
.travis.yml travis: rework scripts to re-enable macOS 2019-09-02 00:34:49 +03:00
Copyright Copyright: fix missing word 2018-01-31 03:50:22 +01:00
LICENSE.GPL Copyright: some more licensing clarifications 2017-10-13 15:44:55 +02:00
LICENSE.LGPL Copyright: some more licensing clarifications 2017-10-13 15:44:55 +02:00
README.md README: remove old googlegroups mailing list address 2019-09-14 16:40:50 +02:00
RELEASE_NOTES docs: add mentions of the Vulkan rendering abstraction replacement 2019-04-22 15:58:10 +03:00
VERSION Update VERSION 2018-07-22 18:47:16 +02:00
appveyor.yml appveyor: remove broken packages, install libplacebo 2019-07-03 17:30:50 +03:00
bootstrap.py build: add --no-download option to bootstrap.py 2018-08-13 19:09:35 +02:00
mpv_talloc.h
version.sh version.sh: update MPVCOPYRIGHT to include the current year, 2019 2019-04-16 20:11:30 +02:00
wscript vo_gpu: hwdec_vaapi: Refactor Vulkan and OpenGL interops for VAAPI 2019-09-15 17:51:47 -07:00
wscript_build.py vo_gpu: hwdec_vaapi: Refactor Vulkan and OpenGL interops for VAAPI 2019-09-15 17:51:47 -07:00

README.md

mpv logo

mpv

Overview

mpv is a media player based on MPlayer and mplayer2. It supports a wide variety of video file formats, audio and video codecs, and subtitle types.

Releases can be found on the release list.

System requirements

  • A not too ancient Linux, Windows 7 or later, or OSX 10.8 or later.
  • A somewhat capable CPU. Hardware decoding might help if the CPU is too slow to decode video in realtime, but must be explicitly enabled with the --hwdec option.
  • A not too crappy GPU. mpv is not intended to be used with bad GPUs. There are many caveats with drivers or system compositors causing tearing, stutter, etc. On Windows, you might want to make sure the graphics drivers are current. In some cases, ancient fallback video output methods can help (such as --vo=xv on Linux), but this use is not recommended or supported.

Downloads

For semi-official builds and third-party packages please see mpv.io/installation.

Changelog

There is no complete changelog; however, changes to the player core interface are listed in the interface changelog.

Changes to the C API are documented in the client API changelog.

The release list has a summary of most of the important changes on every release.

Changes to the default key bindings are indicated in restore-old-bindings.conf.

Compilation

Compiling with full features requires development files for several external libraries. Below is a list of some important requirements.

The mpv build system uses waf, but we don't store it in the repository. The ./bootstrap.py script will download the latest version of waf that was tested with the build system.

For a list of the available build options use ./waf configure --help. If you think you have support for some feature installed but configure fails to detect it, the file build/config.log may contain information about the reasons for the failure.

NOTE: To avoid cluttering the output with unreadable spam, --help only shows one of the two switches for each option. If the option is autodetected by default, the --disable-*** switch is printed; if the option is disabled by default, the --enable-*** switch is printed. Either way, you can use --enable-*** or --disable-** regardless of what is printed by --help.

To build the software you can use ./waf build: the result of the compilation will be located in build/mpv. You can use ./waf install to install mpv to the prefix after it is compiled.

Example:

./bootstrap.py
./waf configure
./waf
./waf install

Essential dependencies (incomplete list):

  • gcc or clang
  • X development headers (xlib, xrandr, xext, xscrnsaver, xinerama, libvdpau, libGL, GLX, EGL, xv, ...)
  • Audio output development headers (libasound/ALSA, pulseaudio)
  • FFmpeg libraries (libavutil libavcodec libavformat libswscale libavfilter and either libswresample or libavresample)
  • zlib
  • iconv (normally provided by the system libc)
  • libass (OSD, OSC, text subtitles)
  • Lua (optional, required for the OSC pseudo-GUI and youtube-dl integration)
  • libjpeg (optional, used for screenshots only)
  • uchardet (optional, for subtitle charset detection)
  • vdpau and vaapi libraries for hardware decoding on Linux (optional)

Libass dependencies:

  • gcc or clang, yasm on x86 and x86_64
  • fribidi, freetype, fontconfig development headers (for libass)
  • harfbuzz (optional, required for correct rendering of combining characters, particularly for correct rendering of non-English text on OSX, and Arabic/Indic scripts on any platform)

FFmpeg dependencies:

  • gcc or clang, yasm on x86 and x86_64
  • OpenSSL or GnuTLS (have to be explicitly enabled when compiling FFmpeg)
  • libx264/libmp3lame/libfdk-aac if you want to use encoding (have to be explicitly enabled when compiling FFmpeg)
  • For native DASH playback, FFmpeg needs to be built with --enable-libxml2 (although there are security implications).
  • For good nvidia support on Linux, make sure nv-codec-headers is installed and can be found by configure.
  • Libav support is broken. (See section below.)

Most of the above libraries are available in suitable versions on normal Linux distributions. For ease of compiling the latest git master of everything, you may wish to use the separately available build wrapper (mpv-build) which first compiles FFmpeg libraries and libass, and then compiles the player statically linked against those.

If you want to build a Windows binary, you either have to use MSYS2 and MinGW, or cross-compile from Linux with MinGW. See Windows compilation.

FFmpeg vs. Libav

Generally, mpv should work with the latest release as well as the git version of FFmpeg. Libav support is currently broken, because they did not add certain FFmpeg API changes which mpv relies on.

FFmpeg ABI compatibility

mpv does not support linking against FFmpeg versions it was not built with, even if the linked version is supposedly ABI-compatible with the version it was compiled against. Expect malfunctions, crashes, and security issues if you do it anyway.

The reason for not supporting this is because it creates far too much complexity with little to no benefit, coupled with absurd and unusable FFmpeg API artifacts.

Newer mpv versions will refuse to start if runtime and compile time FFmpeg library versions mismatch.

Release cycle

Every other month, an arbitrary git snapshot is made, and is assigned a 0.X.0 version number. No further maintenance is done.

The goal of releases is to make Linux distributions happy. Linux distributions are also expected to apply their own patches in case of bugs and security issues.

Releases other than the latest release are unsupported and unmaintained.

See the release policy document for more information.

Bug reports

Please use the issue tracker provided by GitHub to send us bug reports or feature requests. Follow the template's instructions or the issue will likely be ignored or closed as invalid.

Using the bug tracker as place for simple questions is fine but IRC is recommended (see Contact below).

Contributing

Please read contribute.md.

For small changes you can just send us pull requests through GitHub. For bigger changes come and talk to us on IRC before you start working on them. It will make code review easier for both parties later on.

You can check the wiki or the issue tracker for ideas on what you could contribute with.

Relation to MPlayer and mplayer2

mpv is a fork of MPlayer. Much has changed, and in general, mpv should be considered a completely new program, rather than a MPlayer drop-in replacement.

For details see FAQ entry.

If you are wondering what's different from mplayer2 and MPlayer, an incomplete and largely unmaintained list of changes is located here.

License

GPLv2 "or later" by default, LGPLv2.1 "or later" with --enable-lgpl. See details.

Contact

Most activity happens on the IRC channel and the github issue tracker.

  • GitHub issue tracker: issue tracker (report bugs here)
  • User IRC Channel: #mpv on irc.freenode.net
  • Developer IRC Channel: #mpv-devel on irc.freenode.net