[FFmpeg-devel] [PATCH 2/4] avfilter/vf_frei0r: fix time when input is realigned
Stefan Breunig
stefan-ffmpeg-devel at breunig.xyz
Wed Jan 1 15:23:54 EET 2025
av_frame_copy doesn't copy the input's PTS property, which resulted
in the frei0r filter always receiving the same (non-sensical) time.
For example, this results in a static distortion, when it should be
changing over time:
ffmpeg -filter_complex "testsrc2=s=342x142:d=5,frei0r=distort0r" out.mp4
Signed-off-by: Stefan Breunig <stefan-ffmpeg-devel at breunig.xyz>
---
libavfilter/vf_frei0r.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 65ee396bcd..0dd44c4519 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -361,6 +361,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{
Frei0rContext *s = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
+ double time;
/* align parameter is the line alignment, not the buffer alignment.
* frei0r expects line size to be width*4 so we want an align of 1
* to ensure lines aren't padded out. */
@@ -370,6 +371,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
av_frame_copy_props(out, in);
+ time = in->pts * av_q2d(inlink->time_base);
+
if (in->linesize[0] != out->linesize[0]) {
AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
if (!in2)
@@ -379,7 +382,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
in = in2;
}
- s->update(s->instance, in->pts * av_q2d(inlink->time_base),
+ s->update(s->instance, time,
(const uint32_t *)in->data[0],
(uint32_t *)out->data[0]);
--
2.45.2
More information about the ffmpeg-devel
mailing list