Commit Graph

47405 Commits

Author SHA1 Message Date
wm4 9e76c203f7 DOCS: some corrections around cache options 2019-10-08 18:38:23 +02:00
wm4 1f77102ee8 demux_edl: better selection of part which defines the track layout
Someone crazy is trying to mix images with videos in EDL files. Putting
an image as first thing into the EDL disabled audio, because the first
EDL entry was used to define the layout.

Change this. Make it user-configurable, and use a "better" heuristic to
select the default otherwise.

In theory, EDL could be easily extended to specify track layout and
mapping of parts to virtual EDL tracks manually and in great detail. But
I don't think it's worth it - who would bother using it?

Fixes: #6764
2019-10-06 23:35:02 +02:00
wm4 4ad68d9452 video: always decode 2 frames on playback restart
Unless --video-latency-hacks, always decode 2 frames on playback
restart. This in turn will always compute the correct frame duration
(even for the first frame), which in turn happens to fix that playback
with an image at the beginning breaks display.

If a still image precedes video, and the size/format of the frame is
different from that of the video following it, the incorrect frame
duration caused vo_reconfig2() to be called early, causing the window to
resize, and the renderer to clear the image to black. Specifically, it
hit the default value of 1 second duration (for still images), so the
image was displayed for 1 second, and changed to black until the next
proper video frame was displayed.

Normally this does not happen. Even if a video file displays still
images, it normally repeats the still image at the video's FPS (which is
sane). But you can construct such files, or use EDL to construct
something similarly behaving.

This change may increase seek latency a bit in audio video-sync mode
(the default). It needs to wait until 2 frames are decoded, before it
bothers to display the first frame. This is done even when seeking. In
theory it might be good to introduce a "seek preview" mode, which shows
the target image without all the preparations needed for starting
playback. (For example, it could not decode audio.) But since I'm using
video-sync=display-resample, which already needed to always decode 2
frames, I don't think this is a terribly high priority, nor do I
consider the slightly slower seeking a regression.

Fixes: #6765
2019-10-06 23:31:58 +02:00
ckath 9bc38bd18d player: don't load external files when reading from stdin 2019-10-06 21:35:15 +02:00
wm4 299916bde2 audio: raise log level of playback reset on audio timestamp
Make it a warning. This is such an intrusive and shitty hack (but of
course my fault) that it should not be hidden.
2019-10-06 20:46:22 +02:00
wm4 e5a97ef27f audio: do not try gapless if video is still ongoing
In this case, gapless will most likely not work. It will result in (very
slight) desync, or (more commonly with small buffer sizes), in an
underflow.

I think it would be legitimate to disable gapless at end of playback
completely if video is enabled at all. But this would need an exception
for cover art mode, so I guess the current solution is OK as well.
2019-10-06 20:46:22 +02:00
wm4 e38b0b245e ao_alsa: don't silence legitimate underrun if final chunk underruns
It turns out that case 2) mentioned in the previous commit happened
quite often when playback ended normally.

There is probably a legitimate underrun with normal buffer sizes (100
ms, 4 fragments, gapless audio in "weak" mode). This is a result of the
player waiting for video to end, and/or the time needed to kill the
video window. The former case means that it depends on your test case
whether it happens (a file where video ends slightly before audio is
less likely to trigger it).

This in turn is due to how gapless playback works. Achieving not having
a "gap" requires queuing the audio of the next file without playing a
partial chunk (as AOPLAY_FINAL_CHUNK would do). The partial chunk is
then played as part of the first chunk played from the next file. But if
it detects "later" that there is no next file, it still needs to get rid
of the last fragment with AOPLAY_FINAL_CHUNK. At this point it's too
late, and an underrun may have actually happened. The way the player
uninits and reinits the entire playback engine for the next file in a
"serial" manner means it cannot know in advance whether this works.

This is the reason why the idiot who added the underrun exception for
the last chunk in play() was wrong (I wrote that btw., before you accuse
me of being rude). Yes, it's a real underrun, and you could probably
hear it.
2019-10-06 20:46:22 +02:00
wm4 81e51a15f7 ao_alsa: remove sometimes bogus XRUN message
This XRUN (aka underrun) message was printed in the following
situations:

1) legitimate underrun during playback
2) legitimate underrun when playing final chunk
3) bogus underrun when playing final chunk

The old underrun case (in play()) happens in cases 1) and 2) as well,
but 3) did not happen. It appears 3) is indeed something that happens,
although it's not known for sure. It's still pretty annoying, so remove
the new XRUN message.

When testing, care should be taken to play with buffer sizes, video
versus no video, and gapless enabled/disabled. Also, suspending the
player with Ctrl+Z in the terminal (SIGSTOP) and then resuming is a good
way to trigger a "normal" underrun.
2019-10-06 20:46:22 +02:00
der richter 6d0f0546ee cocoa-cb: remove get_property_* usages and split up mpv helper
all the get_property_* usages were removed because in some circumstances
they can lead to deadlocks. they were replaced by accessing the vo and
mp_vo_opts structs directly, like on other vos.

additionally the mpv helper was split into a mpv and libmpv helper, to
differentiate between private and public APIs and for future changes
like a macOS vulkan context for vo=gpu.
2019-10-06 13:29:48 +02:00
Paul B Mahol 2b19a7c964 audio/filter: remove no longer used header 2019-10-05 12:36:38 +02:00
wm4 49a075d01e DOCS/compatibility.rst: add this file
Another thing nobody will read. I'm attempting to document the rules by
which incompatible changes can be made. These rules have always been
present in this project, but I don't think they were written down. Or
maybe they were, but I forgot where.

I think due to the time of the day it became increasingly incoherent
(not necessarily near the end of the text). Hopefully no logical or
freudian lapses in there.
2019-10-05 02:11:55 +02:00
wm4 788203031d DOCS/interface-changes.rst: simplify playback abort change description
Although it was not true at the time this was written, both the
"program" and "cache-size" are gone now.

Since the changelog is for the entire next release, it makes no sense to
mention these removed properties.

It also happens to make the description of this much simpler, because
it's a non-issue now. It's probably not even worth mentioning anymore.
2019-10-05 02:08:19 +02:00
Niklas Haas e8f32a92f8 player: update for --video-aspect deprecation
We had some dangling references to this option.
2019-10-04 22:41:31 +02:00
Niklas Haas cb95ce75b5 options: rename --video-aspect to --video-aspect-override
The justification for this is the fact that the `video-aspect` property
doesn't work well with `cycle_values` commands that include the value
"-1".

The "video-aspect" property has effectively no change in behavior, but
we may want to make it read-only in the future. I think it's probably
fine to leave as-is, though.

Fixes #6068.
2019-10-04 21:34:22 +02:00
wm4 6064720011 player: "subprocess" command should stop immediately in idle mode
The description of the "playback_only" field in the "subprocess" command
says "you can't start it outside of playback". This did not work
correctly: if the player was started in idle mode in the first place,
the subprocess was allowed to run even with playback_only=yes.

This is a bug, and this change fixes it. Add a test for this to
command-test.lua.

For #7025.
2019-10-04 16:30:48 +02:00
wm4 e49cec5832 manpage: clarify some details about async. commands and "subprocess"
There's potential confusion about how long a process started with the
"subprocess" command is allowed to live. Add some more explanations
regarding "subprocess" specifics (such as the playback_only field), and
things that apply to asynchronous commands in general.

Partially for #7025.
2019-10-04 16:18:10 +02:00
dudemanguy fd7aff7a9d wayland opengl: actually call uninit if init fails
This is the proper fix to the memory leak @wm4 pointed out. It turns out
that when you autoprobe opengl and vo_wayland_init returns false,
vo_wayland_uninit is never actually executed. So you have a leftover
pointer. The vulkan context does this correctly which was why my old,
dumb "fix" broke it.
2019-10-03 14:56:43 +00:00
dudemanguy 9d6ae83fdc Revert "wayland: free wayland_state on a false return"
Dumb idea. The correct thing to do is to fix the preinit and context
creation so that the uninit is correctly executed when probing fails
(and then everything gets freed).

This reverts commit defc8f359c.
2019-10-03 14:56:43 +00:00
Dudemanguy911 defc8f359c wayland: free wayland_state on a false return
wm4 mentioned that the wayland autoprobe leaked. A simple oversight in
the wayland_common code forgot to free the vo_wayland_state if
vo_wayland_init returned false.
2019-10-02 18:38:45 -05:00
wm4 c669a434f3 vf_fingerprint: fix an obvious memory leak
Leaks the entire zimg state on filter deinit. Not sure what I was
thinking; with some luck, I just didn't give a shit about this case, but
most likely I was thinking the same thing as always: nothing.
2019-10-03 01:07:25 +02:00
wm4 5f75365f44 vf_vapoursynth: fix crashing memory management mistake
As pointed out by @olifre in #7016, this line of code was wrong. p->opts
at this point is a struct allocated and managed by m_config. opts->file
is a string, and m_config explicitly frees it on destruction. The line
of code in question replaced the opts->file value, and made both the old
and new value children of the talloc allocation, so they were _also_
freed on destruction.

This crashed due to a double-free. First, talloc auto-freeing freed the
string, then m_config explicitly called talloc_free() on the stale
pointer again.

As @v-fox pointed out, commit 36dd2348a1 seems to have triggered the
crash. I suspect this code merely worked out of coincidence, since it
allowed m_config to free the value first. This removed it from the
auto-free list, and thus did not result in a double-free. The change
in order of calling alloc destructors changed the order of these calls.

There is no strong reason why new behavior (as introduced by commit
36dd2348a1) would be wrong (it feels like cleaner behavior). On the
other hand, what the vf_vapoursynth code did is clearly unclean and
going by the m_config API, you're not at all supposed to do this.
m_config manages all memroy referenced by option structs, the end.

@olifre's suggested fix also would have been correct (not just hiding
the issue), I prefer my fix, as it doesn't mess with the option struct
in tricky ways.

This wouldn't have happened if mpv were written in Haskell.
2019-10-03 00:48:12 +02:00
wm4 d2a10fb02e vf_vapoursynth: do not call vsscript_finalize() if init failed
If vsscript_finalize() is not matched by a successful vsscript_init(),
an assert in the vsscript library triggers. Makes sense, I guess.
2019-10-03 00:48:12 +02:00
wm4 f36ae05aca vf_vapoursynth: remove some Lua backend remains
Pretty funny.
2019-10-03 00:48:12 +02:00
Dudemanguy911 d823b3b39a wayland: always create wl_output before rendering
I previously skipped creating the wl_output if the --fullscreen flag
with no --fsscreen_id was inputted, so the fullscreen video lands on the
correct output (where mpv was launched). This has breakage if someone
combines the --autofit flag (or other similar options with it). Instead,
just actually read xdg_shell spec and realize that you can pass NULL to
xdg_toplevel_set_fullscreen and let the compositor choose the output if
the user doesn't specify it. If this has issues, get a better
compositor.
2019-10-02 22:43:13 +00:00
wm4 1c63869d0a demux: restore some of the DVD/BD/CDDA interaction layers
This partially reverts commit a9d83eac40
("Remove optical disc fancification layers").

Mostly due to the timestamp crap, this was never really going to work.
The playback layer is sensitive to timestamps, and derives the playback
time directly from the low level packet timestamps. DVD/BD works
differently, and libdvdnav/libbluray do not make it easy at all to
compensate for this. Which is why it never worked well, but not doing it
at all is even more awful.

demux_disc.c tried this and rewrote packet timestamps from low level TS
to playback time. So restore demux_disc.c, which should bring behavior
back to the old often non-working but slightly better state.

I did not revert anything that affects components above the demuxer
layer. For example, the properties for switching DVD angles or listing
disc titles are still gone. (Disc titles could be reimplemented as
editions. But not by me.)

This commit modifies the reverted code a bit; this can't be avoided,
because the internal API changed quite a bit. The old seek resync in
demux_lavf.c (which was a hack) is replaced with a hack. SEEK_FORCE and
demux_params.external_stream are new additions.

Some of this could/should be further cleaned up. If you don't want
"proper" DVD/BD support to disappear, you should probably volunteer.

Now why am I wasting my time for this? Just because some idiot users are
too lazy to rip their ever-wearing out shitty physical discs? Then why
should I not be lazy and drop support completely? They won't even be
thankful for me maintaining this horrible garbage for no compensation.
2019-10-03 00:22:18 +02:00
wm4 8c58375dbd f_auto_filters: use f_autoconvert for hw download
Instead of using custom code.

Now if only f_lavfi knew what formats FFmpeg's vf_yadif accepts, this
could look much nicer, and wouldn't require the additional converter
filter setup.
2019-10-02 23:13:26 +02:00
wm4 9b55009e8f f_autoconvert: provide a function to determine if conversion works
This adds the function as seen in the f_autoconvert.h part of the patch.
It's pretty simple, but goes along with an intrusive code move. I guess
the resulting code is slightly nicer anyway.
2019-10-02 23:12:50 +02:00
wm4 55424c29d3 f_autoconvert: add hw->sw download path
For some reason it could do sw->sw and sw->hw (and, in some ways, even
do hw->hw in special cases), but not hw->sw. Add this.
2019-10-02 22:30:25 +02:00
wm4 3e02f39087 f_auto_filters: use software conversion if hw deint is not possible
Before this commit, enabling hardware deinterlacing via the
"deinterlace" option/property just failed if no hardware deinterlacing
was available. An error message was logged, and playback continued
without deinterlacing.

Change this, and try to copy the hardware surface to memory, and then
use yadif. This will have approximately the same effect as
--hwdec=auto-copy. Technically it's implemented differently, because
changing the hwdec mode is much more convoluted than just inserting a
filter for performing the "download". But the low level code for
actually performing the download is the same again.

Although performance won't be as good as with a hardware deinterlacer
(probably), it's more convenient than forcing the user to switch hwdec
modes separately. The "deinterlace" property is supposed to be a
convenience thing after all.

As far as the code architecture goes, it would make sense to auto-insert
such a download filter for all software-only filters that need it.
However, libavfilter does not tell us what formats a filter supports
(isn't that fucking crazy?), so all attempts to work towards this are
kind of hopeless. In this case, we merely have hardcoded knowledge that
vf_yadif definitely does not support hardware formats. But yes, this
sucks ass.
2019-10-02 21:27:07 +02:00
wm4 49f9146fe4 f_hwtransfer: add a mp_hwdownload filter
This just wraps the mp_image_hw_download() function as a filter and adds
some minor caching/error logging. (Shame that it needs to much
boilerplate, I guess.)

Will be used by the following commit. Wrapping it as filter seemed more
convenient than other choices.
2019-10-02 21:14:58 +02:00
wm4 61961d03f6 filters: add another dumb helper
Can be used with mp_chain_filters() to combine multiple filters into a
single one. This is a bit silly, but whatever. I'm making it an explicit
separate filter, because it lets the user access mp_filter.ppins against
all conventions.
2019-10-02 21:09:30 +02:00
wm4 95e13e3d3e mp_image_pool: expose a function for reporting hw download format
Basically predicts what mp_image_hw_download() will do. It's pretty
simple if it gets the full mp_image. (Taking just a imgfmt would make
this pretty hard/impossible or inaccurate.)

Used in one of the following commits.
2019-10-02 21:07:14 +02:00
wm4 25e70f4743 video: remove vf_vavpp from automatic deinterlace property
This reverts commit 6385a5fd1b, and in
addition removes the code that automatically inserts the vavpp filter.

The reason is the same as the commit that is being reverted: this
filter seems to trigger driver bugs. It can cause GPU freezes or
just doesn't work.

This variant of disabling the filter is better. There was no way to
add the "force" parameter to the automatically inserted filter, so
the old approach just made manual filter insertion (with the --vf
option or "vf" command) more cumbersome.
2019-10-02 19:21:42 +02:00
wm4 bc03bc8214 DOCS/tech-overview.txt: caching has changed 2019-10-02 19:20:51 +02:00
wm4 f203a881e5 README.md: minor cleanups
I don't think MPlayer/mplayer2 and Libav are well-known enough anymore
to warrant such a prominent place in the top-level README file of this
project. It's just useless noise to most users. So I've moved these
things to the FAQ.

Update some other minor things.
2019-10-02 13:53:35 +02:00
Vítor Galvão 643db416a1 README.md: remove dead homebrew-mpv link 2019-10-02 13:26:10 +02:00
Marek Sebera 35e8710b86 autoload.lua: Configurable autoload types
Autoload script now suppports loading of not only video, but also
image and audio files, in a manner, where one can configure which
of the groups (audio, videos, images) is currently enabled.

Use file script-opts/autoload.conf with key=value configuration keys
disabled,images,videos,audio to configure autoload script.

See documentation on top of the script
2019-10-02 12:48:56 +02:00
Oliver Freyermuth 64ae475e40 DOCS: Document DVB changes in interface-changes. 2019-10-02 01:25:45 +02:00
Oliver Freyermuth 8c52cd4e4a stream_dvb: Remove now replaced stream-control code for good. 2019-10-02 01:25:45 +02:00
Oliver Freyermuth 5b45b2fcac DOCS: Add documentation for dvbin-prog and dvbin-channel-switch-offset. 2019-10-02 01:25:45 +02:00
Oliver Freyermuth 12d74e4d95 stream_dvb: Allow actual zapping of channels again.
This is realized by dvbin-channel-switch-offset,
which is a numeric offset on the channel initially tuned to.
Since the channel list is kept in the stream alone
depending on detected hardware and chosen card,
and no available backchannel to the player, there's no direct
property which could be switched.

Using input.conf like:
H cycle dvbin-channel-switch-offset up
K cycle dvbin-channel-switch-offset down
Q set dvbin-prog "ZDF HD"
allow fast and reliable channel switching again.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth c408a48119 player: Add mp_property_dvb_channel helper.
Reinitializes the player as is needed when
tuning to a new DVB channel.
Currently triggered when dvbin-prog is written to,
i.e. when the user explicity switches to a channel by name.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth 9cd4638d2b stream_dvb: Add dvb_update_config to poll config parameters.
If any parameters have been updated, reinitiate streaming_start.
Throttle checks since we poll from streaming_read.
This also requires the player to re-initialize, since all video
and audio streams and even the transport format may change.
This is added in the next commit.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth 1768ea0d15 stream_dvb: Move stream->is_on initialization to state preparation.
Notably, this allows to call dvb_streaming_start more than once,
simplifying e.g. channel switching.
Also, get rid of unused timeout variable.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth c15ec393dd stream_dvb: Factor out logic to determine program and card.
This is now treated in dvb_parse_path consistently
instead of logic scattered over various functions.
This is a requirement to sensibly re-evaluate config
after options have been changed, since we have two ways
to configure the stream (decorated URI and config parameters).
2019-10-02 01:25:45 +02:00
Oliver Freyermuth 76918be267 stream_dvb: Use separated out options struct.
This also allows the use of m_config_cache_alloc
which allows to watch config updates.
2019-10-02 01:25:45 +02:00
wm4 86c229fede demux_lavf: remove recently added author name from license header
This was added in 585f9ff42f by @bbarenblat (github handle). We
don't do this. This file alone probably has multiple dozen of authors (I
didn't count, but it has a history of 15 years). If everyone added their
names with each small change, this project would have giant lists of
contributing authors on every source file.

Neither copyright law nor any of the used licenses require listing
authors in the license header. Authorship is recorded in the git log.

So don't start with this, and remove this recent case to avoid setting a
precedent.

Some files still have an author in the header. These cases are
grandfathered, and usually are the actual authors of the original code.
2019-10-01 22:51:46 +02:00
wm4 f290081645 DOCS/contribute.md: split into sections, random changes
Still trying to get people to read it. Even though I wanted to make it
less of a wall of text and more readable, it got bigger. Oops.

While I'm at it, violate my own rules and mix these mostly cosmetic
changes with some actual rule changes and clarifications.
2019-10-01 22:39:56 +02:00
wm4 3bef1190e8 github: try to get contributors to read contribute.md
How hard can it be? I know contribute.md is a shitty wall of text, but
that doesn't make it less important, and each violation will make it
take longer by adding another review round anyway.

And we really don't need lazy pull requests. If you can't be assed to
follow a few simple rules, your code is probably shit or you wanted to
be quick and lazy. Why should we accept it? We're the ones who have to
maintain it and fix bugs in it, and if the contributor is lazy, the
chance of you maintaining it is probably slim as well. On the other
hand, WE the maintainers are not obligated to anything.

Don't say that though, the first contact doesn't need to be negative. I
don't know if the "lazy pull requests" is still too strong, but I can't
tell.
2019-10-01 21:44:57 +02:00
wm4 07d9ca5ee3 demux_mkv: better behavior/warnings on partial files/unseekable streams
demux_mkv may seek to the end of the file to read certain headers (which
should probably be called "footers", but in theory they are just headers
that have been placed at the end of the file unfortunately).

This commit changes behavior not to seek if the stream is not marked as
seekable. Before this, it only checked whether the stream size was
unknown (end negative). In practice it doesn't make much of a
difference, since seekable usually equals known stream size.

Also improve the wording, and distinguish between actual incomplete
files, and unseekable ones.
2019-10-01 21:27:25 +02:00