aboutsummaryrefslogtreecommitdiffhomepage
path: root/demux/demux_lavf.c
Commit message (Collapse)AuthorAge
* video: switch from using display aspect to sample aspectGravatar wm42015-12-19
| | | | | | | | | | | | | | | | MPlayer traditionally always used the display aspect ratio, e.g. 16:9, while FFmpeg uses the sample (aka pixel) aspect ratio. Both have a bunch of advantages and disadvantages. Actually, it seems using sample aspect ratio is generally nicer. The main reason for the change is making mpv closer to how FFmpeg works in order to make life easier. It's also nice that everything uses integer fractions instead of floats now (except --video-aspect option/property). Note that there is at least 1 user-visible change: vf_dsize now does not set the display size, only the display aspect ratio. This is because the image_params d_w/d_h fields did not just set the display aspect, but also the size (except in encoding mode).
* demux_lavf: minor cleanupsGravatar wm42015-12-17
|
* sub: detect charset in demuxerGravatar wm42015-12-17
| | | | | | | | | | | | Slightly simpler, and removes the need to pre-read all subtitle packets. This still does the subtitle charset conversion on the packet level (instead converting when parsing the file), so in theory this still could provide a way to change the charset at runtime. But maybe even this should be removed, as FFmpeg is somewhat likely to get its own charset detection and conversion mechanism in the future. (Would have to keep the subtitle file in memory to allow changing the charset on the fly, I guess.)
* sub: remove sd_movtext.cGravatar wm42015-12-15
| | | | | libavcodec's movtext-to-ass converter does the same and has more features. On Libav, this commit disables mp4 subtitle display.
* demux_lavf: mark ASS tracks as always UTF-8Gravatar wm42015-11-11
| | | | | Stops mpv from trying to run a subtitle charset detector on .ass files loaded by libavformat.
* Replace deprecated av_free_packet() callsGravatar wm42015-10-28
| | | | | | 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_lavf: always copy codec headersGravatar wm42015-10-19
| | | | | | If this is not done, libavformat could change the headers while demuxing, all while the decoder thread reads these fields during initialization.
* Take care of libavcodec convergence_duration deprecationGravatar wm42015-09-29
| | | | | | 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.
* stream: provide a stream_get_size() convenience functionGravatar wm42015-08-18
| | | | | And use it everywhere, instead of retrieving the size manually. Slight simplification.
* demux_lavf: check for NAN rotation anglesGravatar wm42015-06-30
| | | | Yep, the FFmpeg API can return this.
* demux: export forced flagGravatar wm42015-06-27
| | | | | | 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_lavf: fix chapter titlesGravatar wm42015-06-24
| | | | Obvious bug added earlier today.
* demux: get rid of some bstr thingsGravatar wm42015-06-24
| | | | | Change the demuxer_add_attachment() and demuxer_add_chapter() signatures to take char* instead of bstr, and everything which depends on it.
* demux: merge extradata fieldsGravatar wm42015-06-21
| | | | | | | 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: rename sh_stream.format to sh_stream.codec_tagGravatar wm42015-06-21
| | | | | Why not. "format" sounds too misleading for the actual importance and meaning of this field.
* demux_lavf: fix wrong printf parameter type on 64 bit systemsGravatar wm42015-06-02
| | | | | "f.len - 4" is size_t, not int. Fix by using BSTR_P() (and a bstr function to adjust the length).
* demux_lavf: do a better job at guessing the vobsub .sub filenameGravatar wm42015-05-28
| | | | | | | | | | | Vobsubs come as .idx/.sub pair of files. The .idx file is the one that should be opened, but the name of the .sub file is unknown. We can now make our own guess what the name of that file is. In particular, improve support with URLs (as these can have the file extension in the middle of the filename string if there are HTTP parameters). Note that this works only with newer ffmpeg versions, because the recently added sub_name demuxer option is used for this.
* demux_lavf: drop dead codeGravatar wm42015-04-25
| | | | stream.url can never be NULL, although it probably used to be.
* player: change video-bitrate and audio-bitrate propertiesGravatar wm42015-04-20
| | | | | | | | | | | | | | Remove the old implementation for these properties. It was never very good, often returned very innaccurate values or just 0, and was static even if the source was variable bitrate. Replace it with the implementation of "packet-video-bitrate". Mark the "packet-..." properties as deprecated. (The effective difference is different formatting, and returning the raw value in bits instead of kilobits.) Also extend the documentation a little. It appears at least some decoders (sipr?) need the AVCodecContext.bit_rate field set, so this one is still passed through.
* demuxer_lavf: add an option for disabling hacksGravatar wm42015-04-17
|
* Update license headersGravatar Marcin Kurczewski2015-04-13
| | | | Signed-off-by: wm4 <wm4@nowhere>
* demux_lavf: use mimetype instead of codec type for embedded fontsGravatar wm42015-04-05
| | | | | | | We handle picking out font attachments by mime type ourselves in a higher level, so we really just want to use the mimetype. Also, Matroska is currently the only code in libavformat which uses the fonts at all, and we can drop use of the codec IDs completely.
* demux_lavf: print seek failures in verbose modeGravatar wm42015-03-24
| | | | | Don't bother with making these visible by default, because often they are bogus and/or useless.
* demux_lavf: assume h264/hevc raw streams have no timestampsGravatar wm42015-03-20
| | | | | There are obscure methods to add timestamps to such streams, but assume they're unused.
* player: better handling of video with no timestampsGravatar wm42015-03-20
| | | | | | | | | | | Trying to handle such video is almost worthless, but it was requested by at least 2 users. If there are no timestamps, enable byte seeking by setting ts_resets_possible. Use the video FPS (wherever it comes from) and the audio samplerate for timing. The latter was already done by making the first packet emit DTS=0; remove this again and do it "properly" in a higher level.
* sub: this isn't needed eitherGravatar wm42015-03-03
|
* Revert "demux_lavf: workaround for broken libavformat subtitle seeking"Gravatar wm42015-03-03
| | | | | | | This reverts commit c8f49be919ffaf983bde77b63d75f96a593ec7a8. Not needed anymore; fixed in all supported FFmpeg releases. Though I could not test again, because all sample files are gone (oops).
* Remove some FFmpeg/Libav compatibility hacksGravatar wm42015-03-03
| | | | | | All of these are now in the supported FFmpeg and Libav versions. The 3 remaining API checks are for FFmpeg-only things.
* demux_lavf: use this for image formatsGravatar wm42015-03-02
| | | | | | | | | | | | | | | | | | Use the (relatively new) libavformat image format probing functionality, instead of letting demux_mf guess by file extension and MIME type. The libavformat support is weird, though. Traditionally, it uses an absolutely terrible hack to detect images by extension, _and_ (which is the horrible part) will randomly interpret parts of the filename as specifiers for matching by number. So something like '%03d' will be interpreted as placeholder for a frame number. The worst part is that such character sequences can be perfectly valid and common in http URLs. This is known as "image2" demuxer. The newer support, which probes by examining the file header, is split into several format-specific demuxers with names ending in "_pipe". So we check for such a name suffix. (At this point we're doing fine-grained hacking around ffmpeg weirdness, so a clean solution is impossible anyway until upstream changes.)
* demux_lavf: apply hacks even if format is forcedGravatar wm42015-02-20
| | | | | | | | | | | | | Some of the hacks were not applied if the file format was forced. Commit 37a0c914 moved them to a table, which is checked with normal probing only. Fixes #1612 (DVD forces mpeg, which in turn has to export native stream IDs specifically). Do some code restructuring on the way. For example, the probescore can simply be set to the correct initial value, instead of checking whether it was set at all.
* demux_lavf: blacklist bintext filesGravatar wm42015-02-18
| | | | | | Whatever the hell that is. FFmpeg tries to open any files with .bin file extension with this demuxer (unless it finds a better demuxer), and then reads the whole damn file, along with spamming dumb crap.
* player: enable cache and demuxer thread for subtitles tooGravatar wm42015-02-18
| | | | | | | | | Includes some logic for not starting the demuxer thread for fully read subtitles. (Well, the cache will still waste _lots_ of resources, and the cache always has to be created, because we don't know whether it'll be needed _before_ opening the file.) See #1597.
* demux_lavf: reorganize hacksGravatar wm42015-02-18
| | | | | | | | | | | An attempt to make format-specifics more declarative. (In my opinion, all of this should be either provided by libavformat, or should not be needed.) I'm still leaving many checks with matches_avinputformat_name(), because they're so specific. Also useful for the following commit.
* demux_lavf: set interrupt_callbackGravatar wm42015-02-18
| | | | | | Helps with terminating the stream if e.g. HLS streams are stuck. (For other demuxers, the stream's interrupt callback already takes care of this.)
* demux_lavf: hack against hls showing "100%" positionGravatar wm42015-02-17
| | | | | | | | | | | | | The HLs protocol consists of a "playlist" main file, which mpv downloads and passes to the HLS demuxer. The HLS demuxer actually requests segment files containing media data on its own. The packets read from the demuxer have a source file position set, but it's not from the main file. This leads to a strange effect: as a last fallback, the player will calculate the approximate playback position from the file position/size ratio, and since the main file is tiny, this will always show 100%. Fix this by resetting the packet file position. This doesn't affect the case when HLS actually reports a duration.
* demux: hack for instant stream switchingGravatar wm42015-02-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the delay when switching audio tracks in mkv or mp4 files. Other formats are not enabled, because it's not clear whether the demuxers fulfill the requirements listed in demux.h. (Many formats definitely do not with libavformat.) Background: The demuxer packet cache buffers a certain amount of packets. This includes only packets from selected streams. We discard packets from other streams for various reasons. This introduces a problem: switching to a different audio track introduces a delay. The delay is as big as the demuxer packet cache buffer, because while the file was read ahead to fill the packet buffer, the process of reading packets also discarded all packets from the previously not selected audio stream. Once the remaining packet buffer has been played, new audio packets are available and you hear audio again. We could probably just not discard packets from unselected streams. But this would require additional memory and CPU resources, and also it's hard to tell when packets from unused streams should be discarded (we don't want to keep them forever; it'd be a memory leak). We could also issue a player hr-seek to the current playback position, which would solve the problem in 1 line of code or so. But this can be rather slow. So what we do in this commit instead is: we just seek back to the position where our current packet buffer starts, and start demuxing from this position again. This way we can get the "past" packets for the newly selected stream. For streams which were already selected the packets are simply discarded until the previous position is reached again. That latter part is the hard part. We really want to skip packets exactly until the position where we left off previously, or we will skip packets or feed packets to the decoder twice. If we assume that the demuxer is deterministic (returns exactly the same packets after a seek to a previous position), then we can try to check whether it's the same packet as the one at the end of the packet buffer. If it is, we know that the packet after it is where we left off last time. Unfortunately, this is not very robust, and maybe it can't be made robust. Currently we use the demux_packet.pos field as unique packet ID - which works fine in some scenarios, but will break in arbitrary ways if the basic requirement to the demuxer (as listed in the demux.h additions) are broken. Thus, this is enabled only for the internal mkv demuxer and the libavformat mp4 demuxer. (libavformat mkv does not work, because the packet positions are not unique. Probably could be fixed upstream, but it's not clear whether it's a bug or a feature.)
* command: export file format as propertyGravatar wm42015-01-23
| | | | | | | | | | | | Repurpose demuxer->filetype for this. It used to be used to print a human readable format description; change it to a symbolic format name and export it as property. Unfortunately, libavformat has its own weird conventions, which are reflected through the new property, e.g. the .mp4 case mentioned in the manpage. Fixes #1504.
* Check some mallocsGravatar wm42014-12-12
| | | | Fixes #1337.
* demux_lavf: set PTS of first packet for formats with no timestampsGravatar wm42014-11-25
| | | | Makes time display work for some raw audio formats (*.shn).
* player: always use demux_chapterGravatar wm42014-11-02
| | | | | | | | | Instead of defining a separate data structure in the core. For some odd reason, demux_chapter exported the chapter time in nano-seconds. Change that to the usual timestamps (rename the field to make any code relying on this to fail compilation), and also remove the unused chapter end time.
* demux_lavf, stream_lavf: drop local buffers on time-seeksGravatar wm42014-10-30
| | | | | There was chance that some data was left in various local buffers after time-seeks. Probably doesn't actually matter.
* demux_lavf: mark as seekable if protocol supports seeking by timeGravatar wm42014-10-30
| | | | | | | | | | | | Basically, this will mark the demuxer as seekable with rtmp* and mmsh protocols. These protocols have network-level time seeking, and whether you can seek on the byte level does not matter. Until now, seeking was typically only enabled because of the cache, and a (nonsensical) warning was shown accordingly. It still could happen that the server doesn't actually support thse requests (or simply rejects them), so this is somewhat imperfect.
* player: add stream selection by ffmpeg indexGravatar wm42014-10-21
| | | | | | | | | Apparently using the stream index is the best way to refer to the same streams across multiple FFmpeg-using programs, even if the stream index itself is rarely meaningful in any way. For Matroska, there are some possible problems, depending how FFmpeg actually adds streams. Normally they seem to match though.
* demux_lavf: set stream network options if applicableGravatar wm42014-10-14
| | | | | | | | | | | Normally, we pass libavformat demuxers a wrapped mpv stream. But in some cases, such as HLS and RTSP, we let libavformat open the stream itself. In these cases, set typical network properties like useragent according to the mpv options. (We still don't set it for the cases where libavformat opens other streams on its own, e.g. when opening the companion .sub file for .idx files - not sure if we maybe should always set these options.)
* demux_lavf: let libavformat open HLS streams directlyGravatar wm42014-10-14
| | | | | | | | Fixes opening some streams. This means the HLS playlist will be opened twice, but that's not much of a problem, considering it's pretty small, and HLS will make many other http accesses anyway.
* demux_lavf: blacklist jpeg filesGravatar wm42014-10-06
| | | | | | | We handle them under demux_mf.c for stupid reasons; mostly so that an image is shown for a second instead of just flashing it. CC: @mpv-player/stable
* demux_lavf: bluray: don't skip stream data when flushingGravatar wm42014-09-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This code meant to flush demuxer internal buffers by doing a byte seek to the current position. In theory this shouldn't drop any stream data. However, if the stream positions mismatch, then avio_seek() (called by av_seek_frame()) stops being a no-op, and might for example read some data to skip to the seek target. (This can happen if the distance is less than SHORT_SEEK_THRESHOLD.) The positions get out of sync because we drop data at one point (which is what we _want_ to do). Strictly speaking, the AVIOContext flushing is done incorrectly, becuase pb->pos points to the start of the buffer, not the current position. So we have to increment pb->pos by the buffered amount. Since there are other weird reasons why the positions might go out of sync (such as stream_dvd.c dropping buffers itself), and they don't necessarily need to be in sync in the first place unless AVIOContext has nothing buffered internally, just use the sledgehammer approach and correct the position manually. Also run av_seek_frame() after this. Currently, it shouldn't read anything, but who knows how that might change with future libavformat development. This whole change didn't have any observable effect for me, but I'm hoping it fixes a reported problem.
* demux_disc: bluray: potentially fix some aspects of seekingGravatar wm42014-09-29
| | | | | | | | | | | | | When flushing the AVIOContext, make sure it can't seek back to discarded data. buf_ptr is just the current read position, while buf_end - buffer is the actual buffer size. Since mpegts.c is littered with seek calls, it might be that the ability to seek could read Mark the stream (which the demuxer uses) as not seekable. The cache can enable seeking again (this behavior is sometimes useful for other things). I think this should have had no bad influence in theory, since seeking BD/DVD first does the "real" seek, then flushes libavformat and reads new packets.
* audio: remove WAVEFORMATEX from internal demuxer APIGravatar wm42014-09-25
| | | | | Same as with the previous commit. A bit more involved due to how the code is written.
* demux: gracefully handle packet allocation failuresGravatar wm42014-09-16
| | | | Now the packet allocation functions can fail.