diff options
author | wm4 <wm4@nowhere> | 2015-11-16 22:47:17 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-11-16 22:47:17 +0100 |
commit | 70df1608d6f74f3eba9a5e593822984194f63951 (patch) | |
tree | e6f332aa72d8fd8020d4ba9a214a4826ed6e711f /player/loadfile.c | |
parent | e24e0ccd6828ff8a50fb290bed45a0f6d81eb00b (diff) | |
download | mpv-70df1608d6f74f3eba9a5e593822984194f63951.tar.bz2 mpv-70df1608d6f74f3eba9a5e593822984194f63951.tar.xz |
player: handle rebasing start time differently
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.)
Diffstat (limited to 'player/loadfile.c')
-rw-r--r-- | player/loadfile.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index 3007ef4f8e..be54b4c9c0 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -714,6 +714,9 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename, if (!demuxer) goto err_out; + if (filter != STREAM_SUB && opts->rebase_start_time) + demux_set_ts_offset(demuxer, -demuxer->start_time); + struct track *first = NULL; for (int n = 0; n < demuxer->num_streams; n++) { struct sh_stream *sh = demuxer->streams[n]; @@ -910,6 +913,10 @@ static void load_chapters(struct MPContext *mpctx) talloc_free(mpctx->chapters); mpctx->num_chapters = src->num_chapters; mpctx->chapters = demux_copy_chapter_data(src->chapters, src->num_chapters); + if (mpctx->opts->rebase_start_time) { + for (int n = 0; n < mpctx->num_chapters; n++) + mpctx->chapters[n].pts -= src->start_time; + } } if (free_src) free_demuxer_and_stream(src); @@ -954,8 +961,11 @@ static void open_demux_thread(void *pctx) args->err = MPV_ERROR_LOADING_FAILED; } } - if (args->demux) + if (args->demux) { args->tl = timeline_load(global, args->log, args->demux); + if (global->opts->rebase_start_time) + demux_set_ts_offset(args->demux, -args->demux->start_time); + } } static void open_demux_reentrant(struct MPContext *mpctx) |