summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* win32/pthread: define _POSIX_TIMERS to notify they are not supportedKacper Michajłow2023-09-291-0/+1
|
* timer: rename mp_time_us_to_timespec to reflect what it actually doesKacper Michajłow2023-09-291-1/+1
|
* demux: improve stream selection stateDudemanguy2023-09-274-12/+13
| | | | | | | | | | | | | | | | | | | | | | | This replaces the previous commit and makes more sense. The internal demux marked tracks as eager depending on their type and for subtitles it would always lazily read them unless there happened to be no available av stream. However, we want the sub stream to be eager if the player is paused. The existing subtitle is still preserved on the screen, but if the user changes tracks that's when the problem occurs. So to handle this case, propagate the mpctx->paused down to the stream selection logic. This modifies both demuxer_refresh_track and demuxer_select_track to take that boolean value. A few other parts of the player use this, but we can just assume false there (no change in behavior from before) since they should never be related to subtitles. The core player code is aware of its own state naturally, and can always pass the appropriate value so go ahead and do so. When we change the pause state, a refresh seek is done on all existing subtitle tracks to make sure their eager state is the appropriate value (i.e. so it's not still set to eager after a pause and a track switch). Slightly invasive change, but it works with the existing logic instead of going around it so ultimately it should be a better approach. We can additionally remove the old force boolean from sub_read_packets since it is no longer needed.
* Revert "demux: eagerly read subtitle streams when switching tracks while paused"Dudemanguy2023-09-272-9/+4
| | | | | | | Actually, I thought of a better way of handling this shortly after merging this. Revert it and redo it in the next commit. This reverts commit c2c157ebeca3d072d4f48ff36228d01ebe888699.
* demux: eagerly read subtitle streams when switching tracks while pausedDudemanguy2023-09-272-4/+9
| | | | | | | | | | | | | | | | | a323dfae426e43451f4d3e08a9a63cb7d1c1ace9 almost fixed subtitle tracks disappearing when paused but it actually missed one part: the behavior of demux_read_packet_async_until. It's a bit unintuitive, but for subtitle streams, that function would only return the very first packet regardless of whatever pts you pass to it. So the previous commit worked on the very first subtitle, but not actually any of the others (oops). This is because subtitle streams never marked as eager and thus never actually read farther ahead. While the video is playing, this is OK, but if we're paused and switching subtitle tracks then the stream should be eagerly read. Luckily, the logic is already there in the function for this. All we have to do add an extra argument to demux_read_packet_async_until to force the stream to be read eagerly and then it just works. Be sure to unset the eager flag when we're done. Actually fixes the bug for real this time.
* demuxer: remove several mp_read_option_raw callsDudemanguy2023-09-223-25/+12
| | | | | | | With the previous commit, we can just access option values directly now and avoid a lot of complication. Note that the mp_read_option_raw call for edition requires calling mp_get_config_group since that option needs to live in MPOpts.
* demux: make demux opts publicDudemanguy2023-09-222-43/+47
| | | | | | | Several parts of the code need to access options here. There's no point in hiding it demux.c so just expose it in the demux.h header. This means pulling it out of demux_internal and putting it in the demuxer struct instead.
* options: move some demux-specific opts to demux optsDudemanguy2023-09-221-0/+8
| | | | | These options are only ever accessed by the demuxer and have no need to be in MPOpts. Move them to demux.c instead.
* demux_lavf: set duration to -1 if unknownllyyr2023-09-221-3/+3
| | | | | | | | | | | | | `demux->duration` is set to -1 on initialization, and some checks rely on it being -1 when unknown. Before this commit, we set `demux->duration` to 0 when unknown. This is incorrect and breaks rtsp logic for disabling seeking outside of cached regions. To fix these issues, initialize `total_duration` and `av_duration` at -1. They're only changed if a real duration is detected, so in cases where the duration is unknown, demux->duration is set to -1 correctly. Fixes: e6afc53e7c ("demux_lavf: get total duration from track durations")
* options: remove a few options marked with .deprecation_messageDudemanguy2023-09-211-4/+1
| | | | | | | | | | | A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the options still possibly do something but they have a deprecation message. Most of these are old and have no real usage. The only potentially controversial ones are the removal of --oaffset and --ovoffset which were deprecated years ago and seemingly have no real replacement. There's a cryptic message about --audio-delay but who knows. The less encoding mode code we have, the better so just chuck it.
* demux_playlist: add --directory-mode=autoGuido Cella2023-09-211-1/+11
| | | | This is a more useful default with --shuffle.
* various: add missing include in header fllesllyyr2023-09-211-0/+1
| | | | Mostly cosmetic
* demux_mf: detect svgGuido Cella2023-09-211-0/+1
| | | | | This allows playing svgs without having to specify --demuxer-lavf-format=svg_pipe.
* demux: prepend some cache options with demuxerDudemanguy2023-09-181-2/+4
| | | | | | --cache-dir is an awful name that leads to confusion (see #12418). Change the name to --demuxer-cache-dir and --demuxer-cache-unlink-files instead.
* demux_mkv: support ProjectionPoseRoll elementKacper Michajłow2023-09-171-0/+23
|
* demux_mkv: support PixelCrop* elementsKacper Michajłow2023-09-171-0/+29
| | | | Fixes #6017
* demux: add crop to mp_codec_paramsKacper Michajłow2023-09-171-0/+1
|
* demux_lavf: get total duration from track durationsllyyr2023-09-021-18/+18
| | | | | | | | | | | | | | | | | | | | | | | Before this change, mpv used to get the total duration from `avformat_find_stream_info` and used the per-track duration as a fallback. This change reverses this order of preference. The timestamps returned by `avformat_find_stream_info` are truncated or rounded or floored (depending on the decoder) at the 6th decimal place. For e.g. `avformat_find_stream_info` may return us a duration like 44.138667, whereas the duration we get from the per-track struct has a higher degree of precision like 44.13866666666... and so on. This caused various problems such as the playback_pts being a bigger value than the duration, which would cause time-remaining to be a negative value in some cases. Or cause you to reach a negative starting timestamp when looping on an audio file with `gapless-audio`. Moreover, we already skipped calling `avformat_find_stream_info` for mp4, so we had already been utilizing this per-track fallback method for finding the duration for mp4 files. It should be noted that while this change is only required for audio-only formats, there is no harm in doing this for videos as well.
* demux_playlist: default to --directory-mode=lazyGuido Cella2023-08-301-3/+3
| | | | | | 64959c450d solved the problems with resuming playback, so default to --directory-mode=lazy because it's faster, especially on slow drives, and results in smaller playlists.
* demux_mf: utilize stdbool bool for if a format specifier was badJan Ekström2023-08-201-2/+4
| | | | | It is not an iterator, thus while the ++ is completely correct, it is somewhat weird.
* demux_mf: early exit with the '%%' caseJan Ekström2023-08-201-11/+23
|
* demux_playlist: remove len restriction on headerless m3uDudemanguy2023-08-151-1/+1
| | | | | | | | | | | | | Discovered by @christoph-heinrich in IRC. 09c701b797c44293dc0e22874b4acf0246b3d148 added a fallback for headerless m3u files. However, it requires that the bstr len be greater than 10. This means that a m3u playlist with a single entry with a very short filename (such as "test.flac") will not be recognized as a playlist since the amount of data is too small. The reason for this restriction is unexplained and really shouldn't matter given that the important thing mpv should be doing is checking if the data is text. Instead, loosen the check so that it only needs to be 2 or greater. This covers a single byte filename and a line terminator.
* build: remove outdated generated directoryDudemanguy2023-07-312-2/+2
| | | | | | | | | | | | | | | | This only existed as essentially a workaround for meson's behavior and to maintain compatibility with the waf build. Since waf put everything in a generated subdirectory, we had to put make a subdirectory called "generated" in the source for meson so stuff could go to the right place. Well now we don't need to do that anymore. Move the meson.build files around so they go in the appropriate place in the subdirectory of the source tree and change the paths of the headers accordingly. A couple of important things to note. 1. mpv.com now gets made in build/player/mpv.com (necessary because of a meson limitation) 2. The macos icon generation path is shortened to TOOLS/osxbundle/icon.icns.inc.
* demux_mkv: add missing space to log msgsfan52023-07-261-1/+1
|
* demux_playlist: sort files before directoriesChristoph Heinrich2023-07-061-22/+45
|
* demux_playlist: add option to control recursive directory loadingChristoph Heinrich2023-07-061-9/+40
| | | | | | | | | | | Directories were always loaded recursively, which can be slow (e.g. one of the subdirectories is a mounting point to a slow device) and can unexpectedly expand into a massive playlist. Due to the problems described in 503dada42f1ea1007768da0dc6a41b67cdf89400, this defaults to recursive loading. ref. https://github.com/mpv-player/mpv/issues/9652
* various: correctly ignore cache files with --no-configDudemanguy2023-07-061-1/+4
| | | | | | | | | | | | --no-config should prevent loading user files of any type: configs, cache, etc. For cache files, this case wasn't properly handled and it was assumed they would always get something. vo_gpu's shader cache actually already handles this, so it was left untouched. In theory, demuxer cache should never have this issue because saving it to disk is disabled by default (and likely that will never change), but go ahead and change it for consistency's sake. Fixes some segfaults with --no-config and various combinations of settings (particularly --vo=gpu-next).
* demux/demux_lavf: avoid leaking AVFormatContext during demux_open_lavfLeo Izen2023-06-181-12/+18
| | | | | | | If demux_open_lavf fails between calling avformat_alloc_context() and assigning the context to priv->avfc, it will never be properly freed. Fixes #11793.
* demux/demux_lavf: strip URL parameters before matching extensionKacper Michajłow2023-05-301-1/+4
| | | | | | | Unfortunately Content-Type matching seems to be not enough as there are mistagged streams. Try to match extension and pass-through URL. Fixes #11700
* demux/demux_lavf: pass-through mime_typeKacper Michajłow2023-05-161-0/+1
| | | | | | This fixes HLS playback. After FFmpeg@954d16f check is strict as per RFC8216 requirement and demuxer need to have this information to work properly.
* demux/demux_lavf: pass-through filename for HLSKacper Michajłow2023-05-161-2/+3
| | | | | | | Fixes local HLS playback. After FFmpeg@6b1f68c commit HLS is only processed if file extension matches RFC8216 requirement.
* Revert "demux/demux_lavf: pass dummy filename when an HLS mimetype is detected"Kacper Michajłow2023-05-161-27/+2
| | | | | | This reverts commit acababec208ec4f26c1462228a9ec1d4aac2c815. Now it has been fixed upstream FFmpeg@6b1f68c.
* demux/demux_lavf: pass dummy filename when an HLS mimetype is detectedLeo Izen2023-05-141-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pass "dummy.m3u8" filename to work around FFmpeg commit 6b1f68ccb04d791f0250e05687c346a99ff47ea1 which broke their HLS demuxer and its ability to probe. Since the above commit, libavformat will check the filename of the file to be probed and reject it if it doesn't end with a valid HLS extension i.e. m3u8,hls,m3u (never mind that .hls is not a valid HLS extension). In addition to a bug with query strings, this also breaks mpv functionality as mpv explicitly doesn't tell libavformat the filename when probing, in order to properly detect the file based only on their contents. The [HLS specification](https://www.rfc-editor.org/rfc/rfc8216.txt) aka RFC 8216, specifies in section 4 that "Each Playlist file MUST be identifiable either by the path component of its URI or by HTTP Content-Type." Notably, it does not require both, so this FFmpeg commit is noncompliant. We work around this noncompliance by checking the MIME type ourselves. If the mimetype matches one of the valid HLS mimetypes (and also application/x-mpegurl, a legacy pre-standardization type), then we pass "dummy.m3u8" to libavformat in order to work around its overly strict checking of filenames. Without this patch, we are unable to play many HLS streams, including a few from the ytdl hook. This patch restores those ability to play those streams when built against FFmpeg master. Do note that if the server sends an invalid content-type header then we cannot implement this workaround so those streams will still fail to play.
* player: use XDG_CACHE_HOME by defaultDudemanguy2023-05-091-3/+5
| | | | | | | | | | | | This adds cache as a possible path for mpv to internally pick (~/.cache/mpv for non-darwin unix-like systems, the usual config directory for everyone else). For gpu shader cache and icc cache, controlling whether or not to write such files is done with the new --gpu-shader-cache and --icc-cache options respectively. Additionally, --cache-on-disk no longer requires explicitly setting the --cache-dir option. The old options, --cache-dir, --gpu-shader-cache-dir, and --icc-cache-dir simply set an override for the directory to save cache files. If unset, then the cache is saved in XDG_CACHE_HOME.
* various: fix various typos in the code baseAlexander Seiler2023-03-281-7/+7
| | | | Signed-off-by: Alexander Seiler <seileralex@gmail.com>
* demux_lavf: update to handle deprecation of `io_close`Philip Langdale2023-03-281-2/+24
| | | | | | | | `io_close2` was introduced as a superior replacement for `io_close` in ffmpeg 5.0, and then deprecated in 6.0. The difference is that `io_close2` can return errors. In our case, we're just calling through to the original function anyway, so we don't need to do more than pass the return value back.
* demux_mkv: support ARIB captionsrcombs2023-03-141-0/+38
|
* demux: propagate hls_bitrate and program_id in generated caption tracksrcombs2023-03-031-0/+2
|
* demux_lavf: report program_idrcombs2023-03-033-0/+5
| | | | This can be useful in stream selection.
* demux: constify a struct membersfan52023-02-241-3/+2
| | | | | Fixes a segfault when an invalid demuxer is given due to uninitialized use of `filename` after goto.
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-214-28/+28
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* various: drop unused #include "config.h"Thomas Weißschuh2023-02-204-7/+0
| | | | | | Most sources don't need config.h. The inclusion only leads to lots of unneeded recompilation if the configuration is changed.
* demux: remove unused codeKacper Michajłow2023-02-021-4/+0
|
* various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriatesfan52023-01-122-3/+3
| | | | | | | | In debug mode the macro causes an assertion failure. In release mode it works differently and tells the compiler that it can assume the codepath will never execute. For this reason I was conversative in replacing it, e.g. in mpv-internal code that exhausts all valid values of an enum or when a condition is clear from directly preceding code.
* various: replace if + abort() with MP_HANDLE_OOM()sfan52023-01-122-4/+2
| | | | | MP_HANDLE_OOM also aborts but calls assert() first, which will result in an useful message if compiled in debug mode.
* demux_mf: replace unsafe string functionssfan52023-01-121-4/+3
|
* demux: new packet should not point to source buffer when copying dataPhilip Langdale2023-01-061-1/+0
| | | | | | | In `new_demux_packet_from`, we initialise a new packet and allocate a buffer which we copy the source data into. But I was then assigning the original source pointer as the packet's buffer, rather than keeping the newly allocated one. Whoops.
* demux: actually initialise packet buffer when creating new packetPhilip Langdale2023-01-061-0/+1
| | | | | | | | When I refactored the code here to stop using stack allocated AVPackets, I forgot to assign `dp->buffer` after initialising the AVPacket. Fixes #11097
* demux: boost read EBU R128 gain values to ReplayGain's reference levelSimon Ruderich2023-01-041-0/+5
| | | | | | | | | | | | | Without this change the same track encoded as Opus - which requires R128 tagging - and e.g. Vorbis with ReplayGain tagging have different volumes. This is caused by ReplayGain 2 having a higher reference level of -18 dB LUFS, while EBU R128 has a lower reference level of -23 dB LUFS. For the results of gain application to match, the read EBU R128 values need to be boosted according to the difference in reference levels. Patch inspired by mpd's source code.
* demux: add --demuxer-hysteresis-secs option to save power with cachingSultan Alsawaf2022-12-301-3/+14
| | | | | | | | | | | | | | | | | | | | | | Buffering ahead nonstop into the cache results in nonstop disk or network activity to read stream data from wherever it may originate. Currently, there's no way to configure the demuxer to back off once it's buffered ahead enough data, since the cache limit will be perpetually not-reached as a stream continues to play, until the entire stream is eventually buffered. On a laptop with an i9-12900H with decoding performed by the iGPU, watching a locally-saved 1080p video which hasn't been buffered into the page cache consumes approximately 15 W even with caching enabled. When configuring a hysteresis to make the demuxer back off, power consumption drops to 9 W when watching the same video, resulting in a whopping 6 W of power savings. To make it possible to attain significant power savings via caching, add a --demuxer-hysteresis-secs option to configure a hysteresis to make the demuxer back off until there's only the configured number of seconds remaining in the cache from the current playback position. This feature is disabled by default.
* demux: replace deprecated usage of stack allocated AVPacketsPhilip Langdale2022-12-242-24/+45
| | | | | | | | | | | | | In the previous change, I replaced the callsites that used `av_init_packet`, but there are a handful of places that use stack allocated packets with no initialisation. In one case, I just switched to heap allocation as it's only done once per stream at most. In the other case, I removed our usage of the AVPackets as a convenience mechanism to transfer data into a heap allocated packet. Instead, I inlined the data copying.
* ffmpeg: increase minimum required version to 4.4Philip Langdale2022-12-011-4/+0
| | | | | | | | | Now that 0.35 has been released, we can consider increasing our minimum required ffmpeg version. Currently, we think 4.4 is the most recent version we can move to (from the current requirement of 4.0). This allows us to remove a few conditionals. There are more that we won't be able to remove unless we move further up to 5.1.
* demux/codec_tags: support more WAVEFORMATEXTENSIBLE tagsLeo Izen2022-11-011-8/+78
| | | | | | | | | This patch adds support for two extra WAVEFORMATEXTENSIBLE GUID tags that can appear inside RIFF headers. It also adds support for extra codec IDs that may appear as their own unique wSubFormats inside RIFF headers, such as ATRAC9 inside matroska, as one example. Fixes #10757.
* demux_mkv: add AVS2 and AVS3 to tag listNicolas F2022-10-211-0/+2
| | | | | | | Add support for playing back AVS2 and AVS3 video streams inside mkv containers if ffmpeg was compiled with avs2/avs3 support. Fixes: #10695
* demux_mf: add support for QOI, PHM and HDR imagesPaul B Mahol2022-10-151-0/+3
|
* demux_lavf: extract is_image functionGuido Cella2022-09-201-8/+13
|
* demux_lavf: detect avif imagesGuido Cella2022-09-201-1/+2
| | | | | Detect avif files with 1 frame as images. This works because AV1 videos and AVIF animations have nb_frames 0 or > 1.
* demux_lavf: switch to AVChannelLayout when availableJan Ekström2022-06-121-0/+14
|
* demux: stop iterating over demuxers as soon as a match is foundEmanuele Torre2022-05-211-1/+3
|
* demux: add support for r128 replaygain tagsdatasone2022-04-281-0/+13
|
* various: fix typosCœur2022-04-251-1/+1
|
* build: remove aviocontext bytes_read checkDudemanguy2022-01-251-4/+0
| | | | | | | | | | | | | | | | This define was always just a stopgap for that two month period (August 2021 - October 2021) where the bytes_read field in ffmpeg was completely missing. Before that time, it was a private member in a struct (which mpv used). Afterwards, it officially became public. Fortunately, the lack of this field never actually made it into a release, so it could have only possibly affected people building from the master branch. Since ffmpeg 5.0 came out recently, and it's been plenty of months since that two month window, we can go ahead and drop this check. This finishes up the work done in 78cfe