mirror of
https://github.com/mpv-player/mpv
synced 2025-02-21 15:27:00 +00:00
Fix chapter handling with first chapter not at beginning of file
Before "-chapter 1" did nothing even if the first chapter didn't start at the beginning of file. Fix it. Before all chapter property commands (including chapter seek keys) failed if the current playback position was before the start of the first chapter. Now they'll work. Relative chapter seeks will go to the first chapter (even if that's in the wrong direction for backward seeks).
This commit is contained in:
parent
dd1760e697
commit
05ae9dbd0d
@ -396,7 +396,7 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg,
|
||||
|
||||
if (mpctx->demuxer)
|
||||
chapter = get_current_chapter(mpctx);
|
||||
if (chapter < 0)
|
||||
if (chapter < -1)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
switch (action) {
|
||||
|
@ -1529,11 +1529,11 @@ int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, double *seek_pts,
|
||||
|
||||
int demuxer_get_current_chapter(demuxer_t *demuxer)
|
||||
{
|
||||
int chapter = -1;
|
||||
int chapter = -2;
|
||||
if (!demuxer->num_chapters || !demuxer->chapters) {
|
||||
if (stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_CHAPTER,
|
||||
&chapter) == STREAM_UNSUPPORTED)
|
||||
chapter = -1;
|
||||
chapter = -2;
|
||||
} else {
|
||||
sh_video_t *sh_video = demuxer->video->sh;
|
||||
sh_audio_t *sh_audio = demuxer->audio->sh;
|
||||
|
@ -2790,6 +2790,7 @@ static int seek(MPContext *mpctx, double amount, int style)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -2 is no chapters, -1 is before first chapter
|
||||
int get_current_chapter(struct MPContext *mpctx)
|
||||
{
|
||||
if (!mpctx->chapters || !mpctx->sh_video)
|
||||
@ -4058,7 +4059,7 @@ if (seek_to_sec || mpctx->timeline) {
|
||||
seek(mpctx, seek_to_sec, SEEK_ABSOLUTE);
|
||||
end_at.pos += seek_to_sec;
|
||||
}
|
||||
if (opts->chapterrange[0] > 1) {
|
||||
if (opts->chapterrange[0] > 0) {
|
||||
double pts;
|
||||
if (seek_chapter(mpctx, opts->chapterrange[0]-1, &pts, NULL) >= 0
|
||||
&& pts > -1.0)
|
||||
|
Loading…
Reference in New Issue
Block a user