PR #20903 opened by breunigs
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20903
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20903.patch

av_frame_copy doesn't copy the input's PTS property, which resulted
in the frei0r filter always receiving the same static time.

Example that has a static distortion without patch:

ffmpeg -filter_complex "testsrc2=s=328x240:d=5,frei0r=distort0r" out.mp4

An installation of frei0r-plugins is required to run the tests,
which is usually seperate from the build headers. Some systems
have it packaged (e.g. `apt install frei0r-plugins`). An upstream
release extracted to `FREI0R_PATH` also works.

The distort0r filter requires dimensions to be divisible by 8.


>From 8a72bc558ea82e1a0f41d63a706531790a2ce878 Mon Sep 17 00:00:00 2001
From: Stefan Breunig <[email protected]>
Date: Wed, 12 Nov 2025 20:58:05 +0100
Subject: [PATCH] avfilter/vf_frei0r: fix time when input is realigned

av_frame_copy doesn't copy the input's PTS property, which resulted
in the frei0r filter always receiving the same static time.

Example that has a static distortion without patch:

ffmpeg -filter_complex "testsrc2=s=328x240:d=5,frei0r=distort0r" out.mp4

An installation of frei0r-plugins is required to run the tests,
which is usually seperate from the build headers. Some systems
have it packaged (e.g. `apt install frei0r-plugins`). An upstream
release extracted to `FREI0R_PATH` also works.

The distort0r filter requires dimensions to be divisible by 8.
---
 libavfilter/vf_frei0r.c                       |  4 ++++
 tests/fate/filter-video.mak                   |  3 ++-
 tests/ref/fate/filter-frei0r-filter-unaligned | 10 ++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/filter-frei0r-filter-unaligned

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 50d81d220f..5dd7387721 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -375,6 +375,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         if (!in2)
             goto fail;
         av_frame_copy(in2, in);
+        if(av_frame_copy_props(in2, in) < 0) {
+            av_frame_free(&in2);
+            goto fail;
+        }
         av_frame_free(&in);
         in = in2;
     }
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index cd5903c960..3fe7f10476 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -717,8 +717,9 @@ $(FATE_FILTER_VSYNTH-yes): SRC = 
$(TARGET_PATH)/tests/vsynth1/%02d.pgm
 
 FATE_FFMPEG += $(FATE_FILTER_VSYNTH-yes)
 
-FATE_FILTER_FREI0R-$(call FILTERFRAMECRC, TESTSRC2, FREI0R_FILTER) = 
fate-filter-frei0r-filter
+FATE_FILTER_FREI0R-$(call FILTERFRAMECRC, TESTSRC2, FREI0R_FILTER) = 
fate-filter-frei0r-filter fate-filter-frei0r-filter-unaligned
 fate-filter-frei0r-filter: CMD = framecrc -lavfi 
"testsrc2=r=1:d=5,frei0r=enable=gte(n\,3):filter_name=distort0r"
+fate-filter-frei0r-filter-unaligned: CMD = framecrc -lavfi 
"testsrc2=s=328x240:r=1:d=5,frei0r=filter_name=distort0r"
 FATE_FFMPEG += $(FATE_FILTER_FREI0R-yes)
 
 #
diff --git a/tests/ref/fate/filter-frei0r-filter-unaligned 
b/tests/ref/fate/filter-frei0r-filter-unaligned
new file mode 100644
index 0000000000..c3cffc69f1
--- /dev/null
+++ b/tests/ref/fate/filter-frei0r-filter-unaligned
@@ -0,0 +1,10 @@
+#tb 0: 1/1
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 328x240
+#sar 0: 1/1
+0,          0,          0,        1,   314880, 0x7b9cad8f
+0,          1,          1,        1,   314880, 0x0184436f
+0,          2,          2,        1,   314880, 0x7e3f2776
+0,          3,          3,        1,   314880, 0x0dc5e915
+0,          4,          4,        1,   314880, 0xcf9c76ef
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to