Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libavfilter/vf_subtitles: also seek in the input to optimize processing
  • Loading branch information
eelco committed Apr 23, 2017
1 parent b4c13e4 commit fa48d4a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libavfilter/vf_subtitles.c
Expand Up @@ -307,6 +307,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
AVStream *st;
AVPacket pkt;
AssContext *ass = ctx->priv;
int64_t timestamp;

/* Init libass */
ret = init(ctx);
Expand Down Expand Up @@ -445,6 +446,16 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
ass_process_codec_private(ass->track,
dec_ctx->subtitle_header,
dec_ctx->subtitle_header_size);

/* Skip the parts that won’t be used anyway */
timestamp = av_rescale(ass->start_time, st->time_base.den,
AV_TIME_BASE * (int64_t) st->time_base.num);
ret = av_seek_frame(fmt, sid, timestamp, 0);
if (ret < 0) {
av_log(ctx, AV_LOG_WARNING, "Error seeking: %s (ignored)\n",
av_err2str(ret));
}

av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
Expand Down

0 comments on commit fa48d4a

Please sign in to comment.