mirror of https://git.ffmpeg.org/ffmpeg.git
Merge commit 'b36bc81ccaa2fc85dc4bae7dc546c71e8833573d'
* commit 'b36bc81ccaa2fc85dc4bae7dc546c71e8833573d': avplay: add support for seeking to chapter marks Conflicts: doc/ffplay.texi ffplay.c ffplay uses pageup/down for seeking by +-10min thus this use of the keys conflicts. The merge thus uses them to seek to chapters when there are some or +-10min when there are not Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
6fb8684a24
|
@ -201,6 +201,8 @@ Seek backward/forward 10 seconds.
|
|||
Seek backward/forward 1 minute.
|
||||
|
||||
@item page down/page up
|
||||
Seek to the previous/next chapter.
|
||||
or if there are no chapters
|
||||
Seek backward/forward 10 minutes.
|
||||
|
||||
@item mouse click
|
||||
|
|
35
ffplay.c
35
ffplay.c
|
@ -3170,6 +3170,33 @@ static void refresh_loop_wait_event(VideoState *is, SDL_Event *event) {
|
|||
}
|
||||
}
|
||||
|
||||
static void seek_chapter(VideoState *is, int incr)
|
||||
{
|
||||
int64_t pos = get_master_clock(is) * AV_TIME_BASE;
|
||||
int i;
|
||||
|
||||
if (!is->ic->nb_chapters)
|
||||
return;
|
||||
|
||||
/* find the current chapter */
|
||||
for (i = 0; i < is->ic->nb_chapters; i++) {
|
||||
AVChapter *ch = is->ic->chapters[i];
|
||||
if (av_compare_ts(pos, AV_TIME_BASE_Q, ch->start, ch->time_base) < 0) {
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i += incr;
|
||||
i = FFMAX(i, 0);
|
||||
if (i >= is->ic->nb_chapters)
|
||||
return;
|
||||
|
||||
av_log(NULL, AV_LOG_VERBOSE, "Seeking to chapter %d.\n", i);
|
||||
stream_seek(is, av_rescale_q(is->ic->chapters[i]->start, is->ic->chapters[i]->time_base,
|
||||
AV_TIME_BASE_Q), 0, 0);
|
||||
}
|
||||
|
||||
/* handle an event sent by the GUI */
|
||||
static void event_loop(VideoState *cur_stream)
|
||||
{
|
||||
|
@ -3219,11 +3246,19 @@ static void event_loop(VideoState *cur_stream)
|
|||
toggle_audio_display(cur_stream);
|
||||
break;
|
||||
case SDLK_PAGEUP:
|
||||
if (cur_stream->ic->nb_chapters <= 1) {
|
||||
incr = 600.0;
|
||||
goto do_seek;
|
||||
}
|
||||
seek_chapter(cur_stream, 1);
|
||||
break;
|
||||
case SDLK_PAGEDOWN:
|
||||
if (cur_stream->ic->nb_chapters <= 1) {
|
||||
incr = -600.0;
|
||||
goto do_seek;
|
||||
}
|
||||
seek_chapter(cur_stream, -1);
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
incr = -10.0;
|
||||
goto do_seek;
|
||||
|
|
Loading…
Reference in New Issue