Commit Graph

46080 Commits

Author SHA1 Message Date
wm4 b1a11191fd demux_null: mark as seekable
No reason not to, and enables some strange constructions with
--external-file (although the result is not too smooth for certain
reasons).
2018-01-06 14:42:22 -08:00
wm4 34cf655ddd player: strictly never autoselect tracks from --external-files
Before this commit, some autoselection of tracks coming from files
loaded with --external-files was still done. This commit removes all of
it, and the only way to select a track is via the explicit stream
selection options like --vid/--sid/--aid.

I think this was always the original intention. The change could in
theory still unintentionally surprise some users, so add a changelog
entry.

This does not affect --audio-file/--sub-file, even if these contain
mismatching track types. E.g. if audio files passed to --audio-file
contain subtitles, these should still be selected. Past feature requests
indicate that users want this.
2018-01-06 14:42:22 -08:00
Ricardo Constantino cf8855cd2e
ytdl_hook: check for possible infinite loop in playlist generation 2018-01-06 18:43:46 +00:00
Ricardo Constantino 442ff93626
ytdl_hook: add additional check for comedycentral urls
If this breaks another site again, remove this whole if and just leave them as
separate playlist items.

Close #5364
2018-01-06 18:22:08 +00:00
wm4 1eec7d2315 demux: include EOF state in cached seekable range
This means if the user tries to seek past EOF, and we know EOF was seen
already, then use a cached seek, instead of triggering a low level seek.

This requires some annoying tracking, but seems pretty simple otherwise.

One advantage of doing this is that if the user tries to do this kind of
seek, there's no unnecessary waiting for a reaction by network (and in
most cases, redundant downloading of data just to discard it again).

Another is that this avoids creating overlapping seek ranges: previously, the
low level seek would naturally create a new range. Then it would read and add
data from the end of the stream due to the low level demuxer not being able to
seek to the target and selecting the last seek point before the end of the
stream. Consequently, this new range would overlap with the previous cached
range. But since the cache joining code is written such that you join the
current range with the _next_ range (instead of the previous as it would be
needed in this case), the overlapping ranges were left alone, until seeking back
to the previous range. That was ugly, sort of harmless, and could happen in
other cases, but this avoidable case was pretty easy to trigger.
2018-01-05 18:34:29 -08:00
wm4 8e1390e734 demux: export some debugging fields about low level demuxer behavior
Export them as explicitly undocumented debugging fields for the
"demuxer-cache-state" property.

Should be somewhat helpful to debug "wtf is the demuxer" doing
situations better, especially when seeking. It also becomes visible how
long the demuxer is blocked on an "old" seek when you keep seeking while
the first seek hasn't finished.
2018-01-05 18:34:29 -08:00
wm4 95dce50347 demux: fix crash due to incorrect seek range accounting
update_seek_ranges() has some special code that attempts to correctly
adjust seek ranges for subtitle tracks. (Subtitle are a nightmare for
seek ranges, because they are sparse, so using the packet list is not
enough to reliably determine the valid cached range.)

This had code like this inside the modified if statement:

  range->seek_start = MP_PTS_MAX(range->seek_start, <something>);

If seek_start is NOPTS, then seek_start will be set to <something>,
breaking some other code that checks seek_start for NOPTS to see if it's
empty. Fix this by explicitly checking whether seek_start is NOPTS
before adjusting it.

The crash happened in prune_old_packets() because the range was marked
as non-empty, yet there was no packet in it to prune. This was with
files with muxed subtitles, when seeking back to the start. This should
not happen anymore with the change. Also add an assert() to
check_queue_consistency() that checks for this specific case.

There's still some mess. In theory, subtitle tracks could be completely
empty, yet their seek range would span the entire file. Seek range
tracking of subtitle files is slightly broken (even before this change).
Some of this should probably be revisited later, including not just
using seek_start to determine whether a seek range should be pruned due
to being empty.
2018-01-05 18:34:29 -08:00
James Ross-Gowan 88c29b1301 vo_gpu: hwdec_dxva2dxgi: initial implementation
This enables DXVA2 hardware decoding with ra_d3d11. It should be useful
for Windows 7, where D3D11VA is not available. Images are transfered
from D3D9 to D3D11 using D3D9Ex surface sharing[1].

Following Microsoft's recommendations, it uses a queue of shared
surfaces, similar to Microsoft's ISurfaceQueue. This will hopefully
prevent surface sharing from impacting parallelism and allow multiple
D3D11 frames to be in-flight at once.

[1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ee913554.aspx
2018-01-06 11:26:15 +11:00
wm4 185e63a3e2 stream: use native libavformat reconnection feature
Remove our own hacky reconnection code, and use libavformat's feature for
that. It's disabled by default, and until recently it did not work too
well. This has been fixed in recent ffmpeg git master[1], so there's no reason
to keep our own code.

[1] FFmpeg/FFmpeg@8a108bdea0

We set "reconnect_delay_max" to 7, which limits the maximum time it
waits. Since libavformat doubles the wait time on each reconnect attempt
(starting with 1), and stops trying to reconnect once the wait time is
over the reconnect_delay_max value, this allows for 4 reconnection
attempts which should add to 11 seconds maximum wait time. The default
is 120, which seems too high for normal playback use.

(The user can still override these parameters with --stream-lavf-o.)
2018-01-04 18:33:18 -08:00
Ricardo Constantino cf411a9489
ytdl_hook: update obsolete warning about retrying URL if failed 2018-01-04 20:35:43 +00:00
James Ross-Gowan a9a4d6349a vo_gpu: d3d11: check for NULL backbuffer in start_frame
In a lost device scenario, resize() will fail and p->backbuffer will be
NULL. We can't recover from lost devices yet, but we should still check
for a NULL backbuffer in start_frame() rather than crashing.

Also remove a NULL check for p->swapchain. This was a red herring, since
p->swapchain never becomes NULL in an error condition, but p->backbuffer
actually does.

This should fix the crash in #5320, but it doesn't fix the underlying
reason for the lost device (which is probably a driver bug.)
2018-01-04 23:05:10 +11:00
James Ross-Gowan baa18f76ca vo_gpu: d3d11: don't use a bgra8 swapchain
Previously, mpv would attempt to use a BGRA swapchain in the hope that
it would give better performance, since the Windows desktop is also
composited in BGRA. In practice, it seems like there is no noticable
performance difference between RGBA and BGRA swapchains and BGRA
swapchains cause trouble with a42b8b1142, which attempts to use the
swapchain format for intermediate FBOs, even though D3D11 does not
guarantee BGRA surfaces will work with UAV typed stores.
2018-01-04 22:08:10 +11:00
wm4 e894f75bb5 player: cosmetics: rename internal variable for consistency
This was so annoying.
2018-01-03 15:43:51 -08:00
wm4 f798bc3c25 player: add --cache-pause-initial option to start in buffering state
Reasons why you'd want this see manpage additions. Disabled by default,
because it would increase latency of live streams by default. (Or well,
at least it would be another problem when trying getting lower latency.)
2018-01-03 15:43:51 -08:00
wm4 9c22108fec player: use fixed timeout for cache pausing (buffering) duration
This tried to be clever by waiting for a longer time each time the
buffer was underrunning, or shorter if it was getting better. I think
this was pretty weird behavior and makes no sense. If the user really
wants the stream to buffer longer, he/she/it can just pause the player
(the network caches will continue to be filled until they're full).
Every time I actually noticed this code triggering in my own use, I
didn't find it helpful. Apart from that it was pretty hard to test.

Some waiting is needed to avoid that the player just plays the available
data as fast as possible (to compensate for late frames and underrunning
audio). Just use a fixed wait time, which can now be controlled by the
new --cache-pause-wait option.
2018-01-03 15:43:51 -08:00
wm4 6092c967ab manpage: slightly improve description of --cache-pause option 2018-01-03 15:43:51 -08:00
wm4 ad1d845682 av_log: stop accessing private ffmpeg fields
MPlayer legacy added in 3c49701490.
2018-01-03 15:11:27 -08:00
Ricardo Constantino 877775f84e m_option: add print callback to start/end/length 2018-01-03 15:10:25 -08:00
dudemanguy c809b73db6
osc: add seekbarkeyframes as a user option 2018-01-03 15:35:39 +00:00
sfan5 3cb616a286 player: remove internal `vo-resize` command again
Its only usecase was automated in the previous commit.
2018-01-02 15:04:31 -08:00
sfan5 48943a73f6 vo_gpu/context_android: replace both options with android-surface-size
This allows us to automatically trigger a VOCTRL_RESIZE (also contained).
2018-01-02 15:04:31 -08:00
wm4 08bcf1d92d client API: be more explicit about how to make libmpv use config files 2018-01-02 15:02:03 -08:00
wm4 722f9b63c2 stream_lavf: minor fixes to HTTP reconnection support
Don't drop the stream buffers, because the read call (that must have
been failing) might try to extend an existing read buffer in the first
place. Just move the messy seek logic to stream_lavf.c. (In theory,
stream_lavf should probably make libavformat connect at the correct
offset instead of using a seek to reconnect it again. This patch doesn't
fix it, but at least it's a good argument to have the messing with the
position not in the generic code.)

Also update the comment about avio not supporting reconnecting. It has
that feature now. Maybe we should use it, but only after it gets fixed.
2018-01-02 14:59:27 -08:00
wm4 6aad532aa3 options: move most subtitle and OSD rendering options to sub structs
Remove them from the big MPOpts struct and move them to their sub
structs. In the places where their fields are used, create a private
copy of the structs, instead of accessing the semi-deprecated global
option struct instance (mpv_global.opts) directly.

This actually makes accessing these options finally thread-safe. They
weren't even if they should have for years. (Including some potential
for undefined behavior when e.g. the OSD font was changed at runtime.)

This is mostly transparent. All options get moved around, but most users
of the options just need to access a different struct (changing sd.opts
to a different type changes a lot of uses, for example).

One thing which has to be considered and could cause potential
regressions is that the new option copies must be explicitly updated.
sub_update_opts() takes care of this for example.

Another thing is that writing to the option structs manually won't work,
because the changes won't be propagated to other copies. Apparently the
only affected case is the implementation of the sub-step command, which
tries to change sub_delay. Handle this one explicitly (osd_changed()
doesn't need to be called anymore, because changing the option triggers
UPDATE_OSD, and updates the OSD as a consequence). The way the option
value is propagated is rather hacky, but for now this will do.
2018-01-02 14:27:37 -08:00
wm4 3bf7df4a5e sub: move all subtitle timestamp messing code to a central place
It was split at least across osd.c and sd_ass.c/sd_lavc.c. sd_lavc.c
actually ignored most of the more obscure subtitle timing things.
There's no reason for this - just move it all to dec_sub.c (mostly from
sd_ass.c, because it has some of the most complex stuff).

Now timestamps are transformed as they enter or leave dec_sub.c.

There appear to have been some subtle mismatches about how subtitle
timestamps were transformed, e.g. sd_functions.accepts_packet didn't
apply the subtitle speed to the timestamp. This patch should fix them,
although it's not clear if they caused actual misbehavior.

The semantics of SD_CTRL_SUB_STEP are slightly changed, which is the
reason for the changes in command.c and sd_lavc.c.
2018-01-02 14:27:37 -08:00
Ricardo Constantino 828bd2963c
command: add demuxer-lavf-list property
Was only available with --demuxer-lavf-format=help and the demuxer
needed to be used for it to actually print the list.

This can be used in the future to check if 'dash' support was compiled
with FFmpeg so ytdl_hook can use it instead. For now, dashdec is too
rudimentary to be used right away.
2018-01-02 20:46:58 +00:00
Ricardo Constantino 89f81da481
player: add on_load_fail hook 2018-01-02 16:01:22 +00:00
Ricardo Constantino 97816bbef0
osc: check if demuxer cache has not reached eof
Avoids flickering stream cache status while filling the demuxer cache.
2018-01-02 14:28:32 +00:00
Ricardo Constantino 0da5688c84
ytdl_hook: fix single-entry playlists
Close #5313
2018-01-02 14:28:03 +00:00
wm4 33e5755c23 video, audio: always read all frames before getting next packet
The old code tried to make sure at all times to try to read a new
packet. Only once that was read, it tried to retrieve new video or audio
frames the decoder might already have decoded.

Change this to strictly read frames from the decoder until it signals
that it wants a new packet, and only then read and feed a new packet.
This is in theory nicer, follows the libavcodec recommended data flow,
and and reduces the minimum latency by 1 frame.

This merely requires switching the order in which those calls are done.
Normally, the decoder will return only 1 frame until a new packet is
required. If we would just feed it 1 packet, return DATA_AGAIN, and wait
until the next frame is decoded, we would run the playloop 1 time too
often for no reason (which is fine but might have some overhead). To
avoid this, try to read a frame again after possibly feeding a packet.
For this reason, move the feed/read code to its own functions each,
instead of merely moving the code.

The audio and video code for this particular thing is basically
duplicated. The idea is to unify them one day, so make the change to
both. (Doing this for video is the real motivation for this change, see
below.)

The video code change is slightly more complicated, because we have to
care about the framedrop counting (which is just a heuristic, but for
now considered better than nothing, and possibly considered required to
warn the user of framedrops happening - maybe).

Apparently this change helps with stalling streams on Android with the
mediacodec wrapper and mpeg2 decoder implementations which deinterlace on
decoding (and return 2 frames per packet).

Based on an idea and observations by tmm1.
2018-01-01 23:17:56 -08:00
Aman Gupta 2dd020efc2 vo_gpu/android: fallback to EGL_WIDTH/HEIGHT
Uses the EGL width/height by default when the user fails to set
the android-surface-width/android-surface-height options.

This means the vo-resize command is optional, and does not need to
be implemented on android devices which do not support rotation.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-01-01 22:21:44 -08:00
Ricardo Constantino d7188ce753
mpv.rc: readd actual version info 2018-01-01 21:44:01 +00:00
Ricardo Constantino 8457287bd0
build: use unicode codepage in windres 2018-01-01 21:41:48 +00:00
wm4 49e704cb19
build: move copyright statement to a shared location
Now macosx_menubar.m and mpv.rc (win32) use the same copyright string.
(This is a bit roundabout, because mpv.rc can't use C constants. Also
the C code wants to avoid rebuilding real source files if only version.h
changed, so only version.c includes version.h.)
2018-01-01 21:05:09 +00:00
wm4 a90abe0546
Update copyright year 2018-01-01 21:05:07 +00:00
Stefano Pigozzi dc21473907 build: generate version.h before anything else
This seems to fix issues when building on windows where compiling mpv.rc
after a `waf clean` resulted in a failure because version.h was not
always present
2018-01-01 16:56:58 +01:00
wm4 ed6ae656b0 main: fix typo
What the heck. This negated the entire check.
2018-01-01 22:26:43 +11:00
James Ross-Gowan 7677c7c32c vo_gpu: d3d11: avoid copying staging buffers to cbuffers
Apparently some Intel drivers have a bug where copying from staging
buffers to constant buffers does not work. We used to keep a copy of the
buffer data in a staging buffer to enable partial constant buffer
updates. To work around this bug, keep the copy in talloc-allocated
system memory instead.

There doesn't seem to be any noticable performance difference from
keeping the copy in system memory. Our cbuffers are probably too small
for it to matter anyway.

See also: https://crbug.com/593024

Fixes #5293
2018-01-01 20:31:45 +11:00
Leo Izen 4a6bb49215 player/playloop.c: Revert --loop-file and --start interaction
This reverts commit 9513165c99
and commit 4efe330efb.

I had changed --loop-file to interact with --start to work
the same way that --loop-playlist does. (That is, --loop-file
seeks to the --start time upon looping, not the beginning of
the file.) However, the consensus is that the old behavior is
preferred and the interaction with --loop-playlist is the one
that is incorrect.

In addition, this change introduced a bug in the interaction
between Quit-Watch-Later and --loop-file, where upon reaching
playback end it would seek to the resume timestamp, not the
start of the file.

As a result, this commit reverts that change.
2017-12-31 17:02:55 -07:00
wm4 ff506c1e49 demux_mkv: fix x264 hack if video track uses header compression
The x264 hack requires reading the first video packet, which in turn we
handle with a hack in demux_mkv.c to get the packet without having to
add special crap to demux.c. Another useless MKV feature (which they
enabled by default at one point and which caused many demuxers to break
completely, only to disable it again when it was too late) conflicts
with this, because we actually pass a block as packet contents, instead
of after "decompression".

Fix this by calling demux_mkv_decode().
2017-12-30 00:37:58 -07:00
Kevin Mitchell d9ca235c68 manpage: put android surface options on one line
This is required by rst2man.
2017-12-28 05:12:54 -07:00
wm4 5e50fe3049 demux_mkv: add hack to pass along x264 version to decoder
This fixes when resuming certain broken h264 files encoded by x264. See
FFmpeg commit 840b41b2a643fc8f0617c0370125a19c02c6b586 about the x264
bug itself.

Normally, the unregistered user data SEI (that contains the x264 version
string) is informational only. But libavcodec uses it to workaround a
x264 bug, which was recently fixed in both libavcodec and x264. The fact
that both encoder and decoder were buggy is the reason that it was not
found earlier, and there are apparently a lot of files around created by
the broken decoder. If libavcodec sees the SEI, this bug can be worked
around by using the old behavior.

If you resume a file with mpv (i.e. seeking when the file loads),
libavcodec never sees the first video packet. Consequently it has to
assume the file is not broken, and never applies the workaround,
resulting in garbage being played.

Fix this by always feeding the first video packet to the decoder on
init, and then flushing the codec (to avoid that an unwanted image is
output). Flushing the codec does not remove info such as the x264
version. We also abuse the fact that the first avcodec_send_packet()
always pushes the frame into the decoder (so we don't have to trigger
the decoder by requsting an output frame).
2017-12-28 00:59:22 -07:00
wm4 d480b1261b vd_lavc: add an option to explicitly workaround x264 4:4:4 bug
Technically, the user could just use --vd-lavc-o with the same result.
But I find it better to make this an explicit option, so we can document
the ups and downs, and also avoid setting it for non-h264.
2017-12-28 00:59:22 -07:00
wm4 f6a582e0b2 demux_mkv: maintain a small packet read queue
This is less of a mess than the single-item queue in tmp_block, and also
might help us in the future.
2017-12-28 00:59:22 -07:00
wm4 5cbadbe721 vd_lavc: fix crash with RPI hwdec
If you use vo_rpi, this could crash, because hwdec_devs is NULL.

Untested. Fixes #5301.
2017-12-28 00:17:42 -07:00
sfan5 0030e049cd player: add internal `vo-resize` command
Intended to be used with the properties from previous commit.
2017-12-27 14:29:15 -07:00
sfan5 451fc931b0 vo_gpu/context: Let embedding application handle surface resizes
The callbacks for this are Java-only and EGL does not reliably
return the correct values.
2017-12-27 14:29:15 -07:00
Bisaloo 8a2db0c4b1 manpage: fix typo in warning 2017-12-27 13:16:30 -07:00
wm4 016c4405fb vo_gpu: EGL: provide SwapInterval to generic code
This means that we now explicitly set an interval of 1. Although that
should be the EGL default, some drivers could possibly ignore this
(unconfirmed). In any case, this commit also allows disabling vsync, for
users who want it.
2017-12-27 04:13:46 -07:00
wm4 9708248eb3 vf_vdpaupp: fix error handling and software input mode
Crashed when no vdpau device was loaded. Also there was a mistake of not
setting p->ctx, which broke software surface input mode. This was not
found before, because p->ctx is not needed for anything else.

Fixes #5294.
2017-12-27 01:52:09 -07:00