diff --git a/ijkmedia/ijkplayer/ff_ffplay.c b/ijkmedia/ijkplayer/ff_ffplay.c index 7aa776cdfc..5ec5a16afc 100644 --- a/ijkmedia/ijkplayer/ff_ffplay.c +++ b/ijkmedia/ijkplayer/ff_ffplay.c @@ -2625,6 +2625,10 @@ static int read_thread(void *arg) ffp_notify_msg1(ffp, FFP_REQ_START); ffp->auto_resume = 0; } + /* offset should be seeked*/ + if (ffp->seek_at_start > 0) { + ffp_seek_to_l(ffp, ffp->seek_at_start); + } for (;;) { if (is->abort_request) diff --git a/ijkmedia/ijkplayer/ff_ffplay_def.h b/ijkmedia/ijkplayer/ff_ffplay_def.h index ae2657952d..5cebd81302 100644 --- a/ijkmedia/ijkplayer/ff_ffplay_def.h +++ b/ijkmedia/ijkplayer/ff_ffplay_def.h @@ -540,6 +540,7 @@ typedef struct FFPlayer { #endif int loop; int framedrop; + int64_t seek_at_start; int infinite_buffer; enum ShowMode show_mode; char *audio_codec_name; @@ -668,6 +669,7 @@ inline static void ffp_reset_internal(FFPlayer *ffp) ffp->autoexit = 0; ffp->loop = 1; ffp->framedrop = 0; // option + ffp->seek_at_start = 0; ffp->infinite_buffer = -1; ffp->show_mode = SHOW_MODE_NONE; av_freep(&ffp->audio_codec_name); diff --git a/ijkmedia/ijkplayer/ff_ffplay_options.h b/ijkmedia/ijkplayer/ff_ffplay_options.h index 7bdef878b9..42b5331bc9 100644 --- a/ijkmedia/ijkplayer/ff_ffplay_options.h +++ b/ijkmedia/ijkplayer/ff_ffplay_options.h @@ -30,7 +30,12 @@ .min = min__, \ .max = max__, \ .flags = AV_OPT_FLAG_DECODING_PARAM - +#define OPTION_INT64(default__, min__, max__) \ + .type = AV_OPT_TYPE_INT64, \ + { .i64 = default__ }, \ + .min = min__, \ + .max = max__, \ + .flags = AV_OPT_FLAG_DECODING_PARAM #define OPTION_CONST(default__) \ .type = AV_OPT_TYPE_CONST, \ { .i64 = default__ }, \ @@ -66,6 +71,8 @@ static const AVOption ffp_context_options[] = { OPTION_OFFSET(infinite_buffer), OPTION_INT(0, 0, 1) }, { "framedrop", "drop frames when cpu is too slow", OPTION_OFFSET(framedrop), OPTION_INT(0, -1, 120) }, + { "seek-at-start", "set offset of player should be seeked", + OPTION_OFFSET(seek_at_start), OPTION_INT64(0, 0, INT_MAX) }, // FFP_MERGE: window_title #if CONFIG_AVFILTER { "af", "audio filters",