summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* demux_lavf: remove subtitle seeking special-casewm42016-07-241-22/+7
| | | | | | | | It used not to work - but now it apparently does. Not sure when that got fixed in FFmpeg, but there's no longer a reason to keep this hack. This also gets rid of the check for the read_seek2 field, which is not part of the public API.
* libarchive: unify entry iteration between stream/demux layerswm42016-07-181-16/+3
| | | | No really good reason to duplicate this.
* demux_timeline: restore mkv edition switchingwm42016-07-141-0/+3
|
* demux_mkv: support Matroska webvttwm42016-06-141-0/+1
| | | | | | | They're different from the Google/WebM subtitle types, and use a new codec ID. Fixes #3247.
* demux_lavf: assume fully read files (subtitles) are always seekablewm42016-06-081-0/+1
| | | | | | | Since the libavformat API is crap, we have to apply tons of heuristics to check whether seeking will work. (No, checking it at seek time isn't going to work either, because if a seek fails, the demuxer will be in an undefined state. Because the libavformat API is crap.)
* demux: fix memory leak when loading of ordered chapter file is abortedwm42016-06-071-0/+1
|
* demux_edl: adjust warnings and variable nameswm42016-05-231-14/+14
| | | | | | | Don't warn against unknown sourve length if the segment length is explicitly provided. Rename "len" to "end_time", because that's what it actually is.
* demux_mkv: better resync behavior for broken google-created webmswm42016-05-211-0/+2
| | | | | | | | | | | | | | | | | | | | | I've got a broken webm that fails to seek correctly with "--start=0". The problem is that every index entry points to 1 byte before cluster start (!!!). demux_mkv tries to resync to the next cluster, but since it already has read 2 bytes with ebml_read_id(), it doesn't get the first cluster, but the following one. Actually, it can be any amount of bytes from 1-4, whatever happens to look valid at this essentially random byte position. Improve this by resyncing from the original position, instead of the one after the EBML element ID has been attempted to be read. The file shows the following headers: | + Muxing application: google at 177 | + Writing application: google at 186 Indeed, the file was downloaded with youtube-dl. I can only guess that Google got it completely wrong.
* demux_playlist: recognize m3u8 as playlist extensionwm42016-05-171-2/+9
| | | | Whatever. As mentioned in #3154.
* demux_lavf: fix a minor memory leakwm42016-05-081-1/+5
|
* demux_playlist: read directories recursivewm42016-04-181-17/+57
| | | | | | | | | | | | | | demux_playlist.c recognizes if the source stream points to a directory, and adds its directory entries. Until now, only 1 level was added. During playback, further directory entries could be resolved as directory paths were "played". While this worked fine, it lead to frequent user confusion, because playlist resuming and other things didn't work as expected. So just recursively scan everything. I'm unsure whether it's a good fix, but at least it gets rid of the complaints. (And probably will add others.)
* demux_mkv: fix seeking with files that miss the first index entrywm42016-04-121-3/+6
| | | | | | | | | Now it will always be able to seek back to the start, even if the index is sparse or misses the first entry. This can be achieved by reusing the logic for incremental index generation (for files with no index), and start time probing (for making sure the first block is always indexed).
* demux_lavf, ad_lavc, ad_spdif, vd_lavc: handle FFmpeg codecpar API changewm42016-03-312-2/+18
| | | | | | | | | AVFormatContext.codec is deprecated now, and you're supposed to use AVFormatContext.codecpar instead. Handle this for all of the normal playback code. Encoding mode isn't touched.
* demux_lavf: remove old MicroDVD frame timing guessingwm42016-03-311-6/+1
| | | | | | | | | | This was changed in 2014, so I suppose users will usually have a FFmpeg release which includes the corresponding upstream change. If not, well too bad for those MicroDVD-obsessed users. Also don't try to retrieve the default framerate as exported by the demuxer, and instead hardcode it and trust it won't ever change. this avoids that we have to deal with a larger mess in the codecpar commit.
* demux_lavf: remove some old framerate guessingwm42016-03-311-14/+1
| | | | | | I don't trust it one bit, and it's a bother with the codecpar change. If it turns out to be important for some file formats, it could be added back (or FFmpeg fixed).
* Revert "demux_mkv: don't trust DefaultDuration for audio"wm42016-03-301-3/+5
| | | | | | | | | | This reverts commit 503c6f7fd6c3c542667c93c75db260671c4ba982. There are situations where some decoders (MF apparently) always require a timestamp. Also, this makes bitrate estimation more granular than necessary. It seems it's better to try to detect fiels with broken default durations explicitly instead. Or maybe something should be added to smooth audio timestamps after filters.
* cache: use a single STREAM_CTRL for various cache infowm42016-03-291-26/+8
| | | | | | | | Instead of having a separate for each, which also requires separate additional caching in the demuxer. (The demuxer adds an indirection, since STREAM_CTRLs are not thread-safe.) Since this includes the cache speed, this should fix #3003.
* demux_timeline: request subtitle prefetching on crossing segmentswm42016-03-251-1/+1
| | | | | | | | | | | SEEK_HR is interpreted by demux_mkv.c, and enables subtitle preroll by prefetching additional subtitle pakcets which might overlap with the seek destination. This should make the case work when segment boundaries fall into the middle of subtitle events. This still usually leaves a flicker of at least 1 frame on start, because dec_sub.c does not ensure that enough subtitles are read before rendering after a segment switch. (Probably a WONTFIX.)
* demux_timeline: skip decoder reinit when seeking to same segmentwm42016-03-171-5/+3
| | | | | "Normal" seeks, which don't actually switch the segment, do not need to reinit the decoders.
* demux: remove pausing mechanismwm42016-03-101-43/+22
| | | | | | | | | This is simpler, because it doesn't have to wait from both threads for synchronization. Apart from being simpler/cleaner, this serves vague plans to stop/start the demuxer thread itself automatically on demand (for the purpose of reducing unneeded resource usage).
* demux: replace demux_pause/demux_unpause with demux_run_on_threadwm42016-03-092-16/+43
| | | | | | | This pause stuff is bothersome and is needed only for a few corner- cases. This commit removes it from the demuxer public API and replaces it with a demux_run_on_thread() function and refactors the code which needed demux_pause(). The next commit will change the implementation.
* demux: delay bitrate calculation on packets with unknown timestampswm42016-03-051-2/+2
| | | | | | | | | Commit 503c6f7f essentially removed timestamps from "laces" (Block sub- divisions), which means many audio packets will have no timestamp. There's no reason why bitrate calculation can't just delayed to a point when the next timestamp is known. Fixes #2903 (no audio bitrate with mkv files).
* demux_null: fix segfault with --cache enabledwm42016-03-051-1/+1
| | | | | | stream->info can be NULL if it's the cache wrapper. To be fair, stream->info is considered private API anyway. So don't access it, but check the URL instead.
* demux_mkv: correctly export unknown packet durationswm42016-03-051-2/+3
| | | | Instead of just setting the duration to 0.
* demux: add null demuxerwm42016-03-042-0/+36
| | | | It's useless, but can be used for fancy --lavfi-complex nonsense.
* demux_timeline: set correct seekable flagswm42016-03-032-2/+2
| | | | | | Tricky misleading crap. Fixes #2898.
* demux_lavf: don't copy cover art picturewm42016-03-031-2/+2
| | | | Use the AVPacket refcounting mechanism instead.
* Revert "demux_mkv: pretend waveext channel layouts by default"wm42016-03-021-1/+1
| | | | | | | | | | | | | | | | This reverts commit af66fa8fa5d8e46b26a08a2b241f03d46abb3c2b. The reverted commit caused AVCodecContext.channel_layout to be set, while requesting stereo downmix will make libavcodec output a stupid message: ac3: Channel layout '5.1' with 6 channels does not match specified number of channels 2: ignoring specified channel layout The same happens with --demuxer=lavf (without this change too). I'm not quite sure what acrobatics are required to shut up libavcodec, but for now revert the commit. It was a rather minor, almost cosmetic issue, which I consider less important than clean CLI terminal output.
* demux_mkv: pretend waveext channel layouts by defaultwm42016-02-291-1/+1
| | | | | Not much of an impact, just makes output of the "channels" "track-list" sub-property nicer.
* demux: remove relative seekingwm42016-02-288-102/+40
| | | | | | | | | | | | | | | | | | | Ever since a change in mplayer2 or so, relative seeks were translated to absolute seeks before sending them to the demuxer in most cases. The only exception in current mpv is DVD seeking. Remove the SEEK_ABSOLUTE flag; it's not the implied default. SEEK_FACTOR is kept, because it's sometimes slightly useful for seeking in things like transport streams. (And maybe mkv files without duration set?) DVD seeking is terrible because DVD and libdvdnav are terrible, but mostly because libdvdnav is terrible. libdvdnav does not expose seeking with seek tables. (Although I know xbmc/kodi use an undocumented API that is not declared in the headers by dladdr()ing it - I think the function is dvdnav_jump_to_sector_by_time().) With the current mpv policy if not giving a shit about DVD, just revert our half-working seek hacks and always use dvdnav_time_search(). Relative seeking might get stuck sometimes; in this case --hr-seek=always is recommended.
* demux_timeline: slightly improve reported file formatwm42016-02-251-1/+3
| | | | | Report the underlying demuxer's format. Since there can be many demuxers participating, pick the "main" segment.
* demux: avoid lost wakeup on queue overflowwm42016-02-241-1/+6
| | | | | | | | | If a stream is marked as EOF (due to no packets found in reach), then we need to wakeup the decoder. This is important especially if no packets are found at the start of the file, so the A/V sync logic actually starts playback, instead of waiting for packets that will never come. (It would randomly start playback when running the playback loop due to arbitrary external events like user input.)
* demux_mkv: don't trust DefaultDuration for audiowm42016-02-241-5/+3
| | | | | It's used to interpolate timestamps for sub-packets ("block laces"). It's occasionally broken, and not really needed by us.
* demux_mkv: fix opus gapless behavior (2)wm42016-02-221-2/+2
| | | | | | | Commit 943f76e6, which already tried this, was very stupid: it didn't actually override the samplerate for Opus, but overrode it for all codecs other than Opus. And even then, it failed to use the overridden samplerate. (Sigh...)
* demux_lavf: adjust seeks by maximum codec delaywm42016-02-221-0/+8
| | | | | | | | | | | | | | | Fixes relative seeks. Without this, a seek back could skip so much data that the seek would effectively jump forward. (Or insert silence for files with video.) There's the question whether the frontend should do this instead (by using information from the decoders), but for now this seems more proper. demux_mkv.c does this already, sort of. libavformat doesn't for seeks in .ogg (aka .opus), but might be doing it for mkv. Seems to be a mess as well.
* demux_mkv: add hack to fix opus gapless behaviorwm42016-02-211-0/+6
| | | | | | | I think the conclusion is that AV_PKT_DATA_SKIP_SAMPLES is misdesigned (at least for some formats), and an alternative mechanism using durations would be better. (Combining it with a proper timebase would keep sample-accuracy.)
* demux_timeline: fix nested timelineswm42016-02-202-1/+4
| | | | | You can e.g. reference ordered chapters or other EDL files in EDLs. There were some bugs left which broke this in some cases.
* demux_timeline: cosmetics: move a functionwm42016-02-161-26/+24
| | | | Gets rid of a forward declaration.
* demux_timeline: disable cache for inactive segmentswm42016-02-161-0/+8
| | | | | | | | This is achieved indirectly by deslecting all streams for the non- current segment (and if the segment doesn't share the demuxer with the currently active one). Restores functionality added with commit 46bcdb70.
* Rewrite ordered chapters and timeline stuffwm42016-02-155-2/+418
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This uses a different method to piece segments together. The old approach basically changes to a new file (with a new start offset) any time a segment ends. This meant waiting for audio/video end on segment end, and then changing to the new segment all at once. It had a very weird impact on the playback core, and some things (like truly gapless segment transitions, or frame backstepping) just didn't work. The new approach adds the demux_timeline pseudo-demuxer, which presents an uniform packet stream from the many segments. This is pretty similar to how ordered chapters are implemented everywhere else. It also reminds of the FFmpeg concat pseudo-demuxer. The "pure" version of this approach doesn't work though. Segments can actually have different codec configurations (different extradata), and subtitles are most likely broken too. (Subtitles have multiple corner cases which break the pure stream-concatenation approach completely.) To counter this, we do two things: - Reinit the decoder with each segment. We go as far as allowing concatenating files with completely different codecs for the sake of EDL (which also uses the timeline infrastructure). A "lighter" approach would try to make use of decoder mechanism to update e.g. the extradata, but that seems fragile. - Clip decoded data to segment boundaries. This is equivalent to normal playback core mechanisms like hr-seek, but now the playback core doesn't need to care about these things. These two mechanisms are equivalent to what happened in the old implementation, except they don't happen in the playback core anymore. In other words, the playback core is completely relieved from timeline implementation details. (Which honestly is exactly what I'm trying to do here. I don't think ordered chapter behavior deserves improvement, even if it's bad - but I want to get it out from the playback core.) There is code duplication between audio and video decoder common code. This is awful and could be shareable - but this will happen later. Note that the audio path has some code to clip audio frames for the purpose of codec preroll/gapless handling, but it's not shared as sharing it would cause more pain than it would help.
* packet: cosmetics: reorder fieldswm42016-02-151-4/+8
|
* demux_mkv: support channel layout in VfW muxed PCMwm42016-02-141-1/+7
| | | | Fixes #2820.
* demux: reduce verbositywm42016-02-111-2/+3
| | | | Tired of seeing all these useless pseudo-demuxers in the log.
* demux_mf: only use glob() if it is availableJan Ekström2016-02-101-0/+2
| | | | | The only other place where glob() is used is windows-specific and for windows mpv includes its own glob wrapper.
* demux_mkv: allow negative timestampswm42016-01-271-18/+20
| | | | | | | FFmpeg can generate such files. It's unclear whether they're allowed by Matroska. mkvinfo shows packet timestamps in both forms (one of them must be a bug), and at last libavformat's demuxer treats timestamps as signed.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-1910-88/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* demux: remove a minor difference between threaded/unthreaded modeswm42016-01-191-2/+2
| | | | This difference was unnecessary.
* demux: fix leaking closed captions packets with unselected sub streamwm42016-01-191-6/+6
| | | | | Calling demux_add_packet() unconditonally frees the packet if the stream is not selected.
* vd_lavc: feed A53_CC side data packets into the demuxer for eia_608 decodingAman Gupta2016-01-182-0/+26
|
* demux: disable stream cache if no tracks are selectedwm42016-01-181-0/+8
| | | | | | | | | Slightly helps with timeline stuff, like EDL. There is no need to keep network (or even just disk I/O) busy for all segments at the same time, because 1. the data won't be needed any time soon, and 2. will probably be discarded anyway if the stream is seeked when segment is resumed. Partially fixes #2692.
* demux: remove unused functionwm42016-01-182-15/+0
|
* demux: fix interleaved subtitle reading in unthreaded modewm42016-01-181-16/+17
| | | | | | Meh. Why are there even two code paths. This adds an additional check; the big function is only moved.
* demux: unify codepaths for threaded/unthreaded track switchingwm42016-01-181-10/+8
| | | | Well, not that the unthreaded case is important, or even works properly.
* demux: remove unused flagwm42016-01-181-1/+0
|
* sub: fix memory leakswm42016-01-181-0/+2
| | | | | | | | | demux_lavf.c leaked the complete subtitle data if it was put through iconv. lavc_conv.c leaked AVCodecContext.subtitle_header (set by libavcodec), which is fixed by using avcodec_free_context(). It also leaked the subtitle that was decoded last.
* demux_lavf: update metadata with information from AV_PROGRAM on switch.Oliver Freyermuth2016-01-141-0/+6
| | | | | | Need to trigger demux_changed() manually since metadata of tracks and streams is not changed, but demuxer-metadata is still changed on program switch.
* demux_lavf: fix charset conversion with UTF-16 subtitleswm42016-01-121-5/+6
| | | | | | | | | | | | | | | | | | | | UTF-16 subtitles are special in that they are usually read by libavformat directly, even though they are not in UTF-8. This is explicitly handled convert_charset() and skips conversion to UTF-8. There was a bug due to not resetting the file position: if conversion happens, the actual stream is replaced with a memory stream containing the converted data, but if conversion is skipped, the original stream with the wrong file position is kept. Fix by always opening a memory stream. (We _could_ seek back, but there is a slight possibility of additional failure due to unseekable streams.) Also, don't enter conversion if the subtitle is detected as UTF-8 either. Fixes #2700.
* demux: merge sh_video/sh_audio/sh_subwm42016-01-1211-179/+165
| | | | | | | | | | This is mainly a refactor. I'm hoping it will make some things easier in the future due to cleanly separating codec metadata and stream metadata. Also, declare that the "codec" field can not be NULL anymore. demux.c will set it to "" if it's NULL when added. This gets rid of a corner case everything had to handle, but which rarely happened.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-118-8/+8
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* player: eliminate demux_get_next_pts()wm42016-01-112-17/+0
| | | | | | | | | | | | | | | | This slightly changes behavior when seeking with external audio/subtitle tracks if transport streams and mpeg files are played, as well as behavior when seeking with such external tracks. get_main_demux_pts() is evil because it always blocks on the demuxer (if there isn't already a packet queued). Thus it could lock up the player, which is a shame because all other possible causes have been removed. The red