summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* demux: fix seeking in .tswm42015-11-231-1/+1
| | | | | .ts files (and some other raw streams) are the only files that enable the SEEK_FACTOR code path, which was broken since commit 70df1608.
* demux_mkv: fix incremental indexing with single-keyframe fileswm42015-11-171-2/+1
| | | | | | | | | | | | This is another regression of the recently added start time probing. If a seek is executed after opening the file (but before reading any packets), the first block is discarded instead of indexed. If there are no other keyframes in the file, seeking will fail completely. Fix it by seeking to the cluster start if there aren't any index entries yet. This will read the skipped packet again. Fixes #2498.
* player: handle rebasing start time differentlywm42015-11-162-1/+21
| | | | | | | | | | | | | | | | Most of this is explained in the DOCS additions. This gives us slightly more sanity, because there is less interaction between the various parts. The goal is getting rid of the video_offset entirely. The simplification extends to the user API. In particular, we don't need to fix missing parts in the API, such as the lack for a seek command that seeks relatively to the start time. All these things are now transparent. (If someone really wants to know the real timestamps/start time, new properties would have to be added.)
* demux_libass: remove this demuxerwm42015-11-112-115/+0
| | | | | | | | | This loaded external .ass files via libass. libavformat's .ass reader is now good enough, so use that instead. Apparently libavformat still doesn't support fonts embedded into text .ass files, but support for this has been accidentally broken in mpv for a while anyway. (And only 1 person complained.)
* demux_lavf: mark ASS tracks as always UTF-8wm42015-11-111-0/+4
| | | | | Stops mpv from trying to run a subtitle charset detector on .ass files loaded by libavformat.
* libarchive: remove redundant log prefixKevin Mitchell2015-11-091-1/+1
| | | | "libarchive:" is already added by the logging system
* demux_mkv: remove --demuxer-mkv-fix-timestampswm42015-11-071-17/+1
| | | | | | | | While it seemed like a pretty good idea at first, it's just a dead end and works only in the simplest cases. While it may or may not help slightly with audio sync mode, the display-sync mode already compensates this in a better way. The main issue is that timestamps at this layer are not in order, so it can look at single timestamps only.
* demux_mkv: dump mixing/writing app fields in verbose logwm42015-11-061-0/+4
|
* Replace deprecated av_free_packet() callswm42015-10-281-4/+4
| | | | | | av_free_packet() got finally deprecated. Use av_packet_unref() instead, which has almost the same semantics, has existed for a while, and is available in all FFmpeg and Libav versions we support.
* demux_mkv: fix cluster skip with duration probingwm42015-10-271-6/+7
| | | | The start time probing essentially broke it.
* demux_mkv: fix duration probing for files with non-0 start timewm42015-10-261-1/+1
| | | | | When using --demuxer-mkv-probe-video-duration=full and the file did not start at timestamp 0, the reported duration was still wrong.
* command: do not return 0 for bitrates if unknownwm42015-10-231-2/+3
| | | | | | | | This makes the bitrate properties unavailable, instead of returning 0 when: 1. No track is selected, or 2. Not enough packets have been read to have a bitrate estimate yet
* demux: cosmetics: remove indirectionwm42015-10-221-4/+2
| | | | Let's not waste precious lines.
* demux_lavf: always copy codec headerswm42015-10-191-1/+8
| | | | | | If this is not done, libavformat could change the headers while demuxing, all while the decoder thread reads these fields during initialization.
* demux: remove demux_add_packet() return valuewm42015-10-173-7/+7
|
* demux_mkv: probe start timewm42015-10-161-10/+43
| | | | | | | | | | | | | | | | | MKV files can very well start with timestamps other than 0. While mpv has support for such files in general, and demux_lavf enables this feature, demux_mkv didn't export a start time. Implement this by simply reading the first cluster timestamp. This in turn is done by reading 1 block. While we don't need the block for this prupose at all, it's the easiest way to get the cluster timestamp read correctly without code duplication. In theory this could be wrong, and a packet could start at a much later time, but in practice this won't happen. This commit also adds an option to disable this feature. It's not documented because nobody should use it. (But I happen to have a need for this.)
* demux_mkv: do not return subtitle packets that end before seek targetwm42015-10-121-2/+6
| | | | | | This affects the subtitle preroll mode during seeking. It could matter somewhat with insane files with ten-thousands of subtitle events, which now seem to pop up, and will avoid packet queue overflow.
* demux_subreader: participate in probing only on Libavwm42015-10-081-0/+4
| | | | | | FFmpeg supports all formats the old subreader code does, and is better at it. On the other hand, subreader.c's probing is bad and can lead to false positives easily.
* demux: don't attempt to open a demuxer after abort signal was givenwm42015-10-061-0/+3
| | | | | demux_open() kept trying to fallback to other demuxers when opening was cancelled. This was not really a problem, but it was stupid.
* cue: read more metadatawm42015-10-014-26/+42
| | | | | | | | | | | Make handling of metadata slightly more generic, and add reading of the "PERFORMER" fields. There are some more fields, but for now let's leave it at this. TRACK-specific PERFORMER fields have to be read from the per-chapter metadata (somewhat obscure). Fixes #2328.
* Take care of libavcodec convergence_duration deprecationwm42015-09-291-0/+2
| | | | | | This AVPacket field was a hack against the fact that the duration field was merely an int (too small for things like subtitle durations). Newer libavcodec drops this field and makes duration 64 bit.
* ebml: warn if an EBML has unknown lengthwm42015-09-031-0/+4
| | | | | | | | | | | | | While unknown lengths are supported in some important cases like segments and clusters, they are not for small and complex metadata elements like the track list. Such elements are simply rejected. This case was caught by the size sanity check below, but the message is misleading and wrong. (There are likely no files in the wild which require support for this. The sample file I've seen was muxed by libavformat, but in a case where it aborted when writing the header. Clearly a broken file.)
* demux_mkv: discard broken indexwm42015-08-261-4/+17
| | | | | | | | | | | | | | | | Add a simplistic heuristic for detecting broken indexes. This includes indexes with very few elements (apparently libavformat sometimes writes such indexes, or used to), and indexes with broken timestamps. The latter was apparently produced by very old HandBrake versions: | + Muxing application: libmkv 0.6.1.2 | + Writing application: HandBrake 0.9.1 These broken files seem to be common enough that libavformat added a workaround for them in 2008 (and maybe again in 2015). Apparently all timestamps are multiplied with the file's tc_scale twice, and FFmpeg attempts to fix them. We should throw away the whole thing.
* demux_mkv: don't read index twicewm42015-08-261-1/+1
| | | | | | Actually, this never happened, because there's logic for ignoring duplicate header elements (which includes the seek index). This is mostly for robustness and readability.
* demux_libarchive: don't allow probing to read unlimited datawm42015-08-241-5/+17
| | | | | | | | | | | | | | | | | Instead, allow reading 2KB only. This seems to be sufficient for libarchive to recognize zip, 7z, rar, tar. Good enough. This is implemented by creating an in-memory stream with a copy of the file header. If libarchive succeeds opening this, the actual stream is opened. Allowing unlimited reading could break unseekable streams, such as playing from http servers with no range request support or pipes. Also, we try not to read too much data in the first probe pass. Some slow network streams like shoutcast services could make probing much slower if we allow it to read too much. In the second probing pass, actually allow 200KB.
* demux_libarchive: reject 0-sized fileswm42015-08-181-0/+3
| | | | libarchive does strange things with them.
* stream: provide a stream_get_size() convenience functionwm42015-08-183-17/+9
| | | | | And use it everywhere, instead of retrieving the size manually. Slight simplification.
* demux_libarchive: open flat compressed fileswm42015-08-171-1/+4
| | | | | | | | Things like .gz etc., which have no real file header. A mixed bag, because it e.g. tends to misdetect mp3 files as compressed files or something (of course it has no mp3 support - I don't know as what it detects them). But requested by someone (or maybe not, I'm not sure how to interpret that).
* stream: libarchive wrapper for reading compressed archiveswm42015-08-172-0/+92
| | | | | | | | | | | | | | | | | | | | This works similar to the existing .rar support, but uses libarchive. libarchive supports a number of formats, including zip and (most of) rar. Unfortunately, seeking does not work too well. Most libarchive readers do not support seeking, so it's emulated by skipping data until the target position. On backwards seek, the file is reopened. This works fine on a local machine (and if the file is not too large), but will perform not so well over network connection. This is disabled by default for now. One reason is that we try libarchive on every file we open, before trying libavformat, and I'm not sure if I trust libarchive that much yet. Another reason is that this breaks multivolume rar support. While libarchive supports seeking in rar, and (probably) supports multivolume archive, our support of libarchive (probably) does not. I don't care about multivolume rar, but vocal users do.
* demux: remove redundant demux_chapter.name fieldwm42015-08-125-15/+11
| | | | | | | | | | Instead, force everyone to use the metadata struct and set a "title" field. This is only a problem for the timeline producers, which set up chapters manually. (They do this because a timeline is a separate struct.) This fixes the behavior of the chapter-metadata property, which never returned a "title" property for e.g. ordered chapters.
* demux_mkv: disable timestamp fixup code againwm42015-08-101-1/+1
| | | | | | | | | | | | This doesn't work too well if sections of the file change to a different framerate. It lowers our chances to guess the correct FPS in the display sync code. For normal playback, this (probably) doesn't help that much anyway, except that the "estimated-vf-fps" property will regress in the simplest mkv case. This will be fixed with the next commit. The now disabled code will probably be removed; it's not useful anymore.
* demux: add options to control maximum queue sizewm42015-08-052-6/+5
| | | | | | | | | | | | | | Add --demuxer-max-packets and --demuxer-max-bytes, which control the maximum size of the packet queue. These can be helpful to avoid excessive memory usage. Memory usage is the reason why there's a limit in the first place. If a file is more or less broken, and audio and video don't line up, the decoders will fill up the packet queue trying to read more audio or video, and the maximum sizes are required to avoid unbounded memory allocation. Being able to override the maximum sizes is useful; either for restricting memory usage further, or enlarging the sizes when attempting to play various broken files.
* demux: remove options to control minimum packet queue sizewm42015-08-051-6/+0
| | | | | | | | Remove --demuxer-readahead-packets and --demuxer-readahead-bytes. These were a bit useless. They could force a minimum packet queue size, but controlling the queue size with --demuxer-readahead-secs is much nicer. It's fairly certain nobody ever used these options.
* player: warn against using HLS URLs with --playlistwm42015-08-041-1/+4
| | | | | | | | | That just makes no sense, but seems to be a somewhat common user error. The detection is not perfect. It's conceivable that EXT-X-... headers are used in normal m3u playlists. After all, HLS playlists are by definition a compatible extension to m3u playlists, as stupid as it sounds.
* player: use demux_open_url() to open main fileswm42015-08-042-4/+17
| | | | | | | | | | | | | | | | Instead of opening a stream and then a demuxer, do both at once with demux_open_url(). This requires some awkward additions to demuxer_params, because there are some weird features associated with opening the main file. E.g. the relatively useless --stream-capture features requires enabling capturing on the stream before the demuxer is opened, but on the other hand shouldn't be done on secondary files like external subtitles. Also relatively bad: since demux_open_url() returns just a demuxer pointer or NULL, additional error reporting is done via demuxer_params. Still, at least conceptually, it's ok, and simpler than before.
* player: remove higher-level remains of DVD/BD menu supportwm42015-08-033-21/+0
| | | | | | | | | | | | | | | Nobody wanted to restore this, so it gets the boot. If anyone still wants to volunteer to restore menu support, this would be welcome. (I might even try it myself if I feel masochistic and like wasting a lot of time for nothing.) But if it does get restored, it should be done differently. There were many stupid things about how it was done. For example, it somehow tried to pull mp_nav_events through all the layers (including needing to "buffer" them in the demuxer), which was needlessly complicated. It could be done simpler. This code was already inactive, so this commit actually changes nothing. Also keep in mind that normal DVD/BD playback still works.
* demux_playlist: skip hidden directorieswm42015-07-291-1/+1
| | | | | | | | The user probably doesn't want these. Conveniently, this also skips the unwanted "." and ".." entries. (This code is triggered if the input stream is a directory - and it's in demux_playlist.c because it's convenient.)
* demux_mkv: remove unnecessary codewm42015-07-201-4/+0
| | | | This did nothing. It's a leftover from ancient times.
* demux_mkv: parse FLAC channel layoutswm42015-07-201-0/+67
| | | | | | | | | | | | | | | | | | Handle a relatively recently introduced hack, that allows FLAC audio to have arbitrary channel layouts, instead of just the predefined fixed ones. This is actually supported by FFmpeg, but since the demuxer (instead of the decoder) handles this in FFmpeg, we need to add special- code to our mkv demuxer. (The way FFmpeg does this seems a bit backwards, since now every demuxer for a format that can handle FLAC needs to contain this logic as well.) The FLAC hack is relatively terrible: we need to parse the FLAC headers, look for a VorbisComment, parse the VorbisComment, and then retrieve the magic WAVEFORMATEXTENSIBLE_CHANNEL_MASK entry. But the hack is officially endorsed, as the official FLAC tools use it. (Although I couldn't find a trace of it in the format specification. Should I be surprised?)
* demux: handle Matroska-style replaygain tags as wellwm42015-07-121-0/+8
| | | | | | | Matroska doesn't follow the usual ReplayGain conventions, and doesn't distinguish between track/album values. Fixes #2128.
* demux: refactor replaygain tag handlingwm42015-07-121-17/+19
| | | | | For the following commit. Also print the replaygain values in verbose mode.
* player: parse and expose m3u playlist titleswm42015-07-101-2/+16
| | | | Requested. Closes #2100.
* demux_mkv: improve video duration detection heuristicwm42015-07-091-16/+29
| | | | | | | | | | | Extend the --demuxer-mkv-probe-video-duration behavior to work with files that are partial and are missing an index. Do this by finding a cluster 10MB before the end of the file, and if that fails, just read the entire file. This is actually pretty trivial to do and requires only 5 lines of code. Also add a mode that always reads the entire file to estimate the video duration.
* player: disable seeking even if the cache is enabledwm42015-07-081-3/+2
| | | | | | | | | | | | | | Until now, if a stream wasn't seekable, but the stream cache was enabled (--cache), we've enabled seeking anyway. The idea was that at least short seeks would typically fall within the cache. And if not, the user was out of luck and terrible things happened. In other words, it was unreliable. Be stricter about it and remove this behavior. Effectively, this will for example disable seeking in piped data. Instead of trying to be clever, add an --force-seekable option, which will always enable seeking if the user really wants it.
* demux_lavf: check for NAN rotation angleswm42015-06-301-3/+5
| | | | Yep, the FFmpeg API can return this.
* demux_mkv: disable ordered chapters if ChapterTimeEnd is missingwm42015-06-281-2/+11
| | | | | | | | | | | | | If the EditionFlagOrdered is set, chapters without ChapterTimeEnd make no sense. Ordered chapters will play the chapters in the order they appear, but will play the ranges the chapters cover. So if the end time is missing, the range is incomplete and it's not clear what should be played. If you assume the start of the next chapter as end time, the ordered flag will have no observable effect, so that's not a useful assumption. This fixes playback of a file which (apparently) had the EditionFlagOrdered set accidentally, with normal chapters.
* demux: export forced flagwm42015-06-273-1/+11
| | | | | | At least Matroska files have a "forced" flag (in addition to the "default" flag). Export this flag. Treat it almost like the default flag, but with slightly higher priority.
* demux_mkv: ignore deprecated FrameRate, do not assume PALwm42015-06-271-8/+2
| | | | | | | | | | | The "FrameRate" element is probably deprecated (it's greyed out in the "spec", and described as "Informational only" in bold). Normally files use DefaultDuration. In fact, the FrameRate field was preferred over DefaultDuration for determining framerate if present. Do not do this and rely on DefaultDuration only. Also, if no framerate is set, do not assume PAL (25 FPS). Such a fallback makes little sense and will cause more problems than it solves.
* demux_mkv: remove some ASCII art log messageswm42015-06-271-8/+4
| | | | | Some of the ASCII art makes sense (like the lines starting with "|"), but these do not make any sense to me and just look annoying.
* demux_mkv: use arrays for codec lookup tableswm42015-06-261-18/+11
| | | | No need to define extra types.
* demux_mkv: minor simplificationwm42015-06-261-3/+1
|
* player, demux: replace some demux_open() uses with demux_open_url()wm42015-06-241-6/+2
|
* demux_lavf: fix chapter titleswm42015-06-241-1/+1
| | | | Obvious bug added earlier today.
* demux_mkv: allow integer and float elements with length 0wm42015-06-241-7/+11
| | | | | | | | Integer and float elements are encoded as a sequence of bytes prefixed by a variable-length encoded length specifier. If the length is 0, then there is no data. Whether this is valid or not is not really clear, but some sample files which do this have surfaced. It's not particularly hard to handle this, so just do it.
* demux: get rid of some bstr thingswm42015-06-248-38/+36
| | | | | Change the demuxer_add_attachment() and demuxer_add_chapter() signatures to take char* instead of bstr, and everything which depends on it.
* demux_mkv: don't use byte stringswm42015-06-242-38/+48
| | | | | | Use char* for strings instead of bstr (data ptr + length pair). Matroska actually (probably) allows "padding" strings with \0 bytes, so using normal C strings instead of byte strings is more appropriate.
* demux: mime types are case-insensitivewm42015-06-211-1/+1
| | | | This one is used for demux_mf and for dmeux_mkv image attachments.
* demux_mkv: share some duplicated codewm42015-06-211-16/+17
| | | | | As a side effect, video tracks now actually export some fields (language, default flag) to the player.
* demux: merge extradata fieldswm42015-06-215-20/+16
| | | | | | | MPlayer traditionally had completely separate sh_ structs for audio/video/subs, without a good way to share fields. This meant that fields shared across all these headers had to be duplicated. This commit deduplicates essentially the last remaining duplicated fields.
* demux_mkv: minor audio extradata cleanupwm42015-06-211-27/+24
| | | | | | Always use the already existing extradata[_len] variable, instead of the awkward switch between manually changed extradata and falling back to passing through extradata at the end.
* demux: rename sh_stream.format to sh_stream.codec_tagwm42015-06-217-13/+11
| | | | | Why not. "format" sounds too misleading for the actual importance and meaning of this field.
* demux_playlist: make mime type comparison case-insensitiv