You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-16 22:42:38 +02:00
avfilter/vf_telecine: Fix AV desync by using the first input timestamp
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
committed by
Michael Niedermayer
parent
21adb9964e
commit
1301aa55f6
@ -38,6 +38,7 @@ typedef struct {
|
|||||||
int first_field;
|
int first_field;
|
||||||
char *pattern;
|
char *pattern;
|
||||||
unsigned int pattern_pos;
|
unsigned int pattern_pos;
|
||||||
|
int64_t start_time;
|
||||||
|
|
||||||
AVRational pts;
|
AVRational pts;
|
||||||
double ts_unit;
|
double ts_unit;
|
||||||
@ -89,6 +90,8 @@ static av_cold int init(AVFilterContext *ctx)
|
|||||||
s->pts.den += *p - '0';
|
s->pts.den += *p - '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s->start_time = AV_NOPTS_VALUE;
|
||||||
|
|
||||||
s->out_cnt = (max + 1) / 2;
|
s->out_cnt = (max + 1) / 2;
|
||||||
av_log(ctx, AV_LOG_INFO, "Telecine pattern %s yields up to %d frames per frame, pts advance factor: %d/%d\n",
|
av_log(ctx, AV_LOG_INFO, "Telecine pattern %s yields up to %d frames per frame, pts advance factor: %d/%d\n",
|
||||||
s->pattern, s->out_cnt, s->pts.num, s->pts.den);
|
s->pattern, s->out_cnt, s->pts.num, s->pts.den);
|
||||||
@ -173,6 +176,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
|
|||||||
TelecineContext *s = ctx->priv;
|
TelecineContext *s = ctx->priv;
|
||||||
int i, len, ret = 0, nout = 0;
|
int i, len, ret = 0, nout = 0;
|
||||||
|
|
||||||
|
if (s->start_time == AV_NOPTS_VALUE)
|
||||||
|
s->start_time = inpicref->pts;
|
||||||
|
|
||||||
len = s->pattern[s->pattern_pos] - '0';
|
len = s->pattern[s->pattern_pos] - '0';
|
||||||
|
|
||||||
s->pattern_pos++;
|
s->pattern_pos++;
|
||||||
@ -235,7 +241,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->pts = outlink->frame_count * s->ts_unit;
|
frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
|
||||||
|
outlink->frame_count * s->ts_unit;
|
||||||
ret = ff_filter_frame(outlink, frame);
|
ret = ff_filter_frame(outlink, frame);
|
||||||
}
|
}
|
||||||
av_frame_free(&inpicref);
|
av_frame_free(&inpicref);
|
||||||
|
Reference in New Issue
Block a user