[FFmpeg-devel] [PATCH 2/3] avfilter/vf_cropdetect: don't ignore frames, export crop parameters

Aman Gupta ffmpeg at tmm1.net
Sat Nov 18 02:36:47 EET 2017


From: Aman Gupta <aman at tmm1.net>

---
 libavfilter/vf_cropdetect.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 7c7d0b953a..87ecb2a6ec 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -167,8 +167,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     int outliers, last_y;
     int limit = lrint(s->limit);
 
-    // ignore first 2 frames - they may be empty
-    if (++s->frame_nb > 0) {
+    if (1) {
+        s->frame_nb++;
         metadata = &frame->metadata;
 
         // Reset the crop area every reset_count frames, if reset_count is > 0
@@ -230,6 +230,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         SET_META("lavfi.cropdetect.x",  x);
         SET_META("lavfi.cropdetect.y",  y);
 
+        frame->crop_top = y;
+        frame->crop_left = x;
+        frame->crop_right = frame->width - w - x;
+        frame->crop_bottom = frame->height - h - y;
+
         av_log(ctx, AV_LOG_INFO,
                "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"PRId64" t:%f crop=%d:%d:%d:%d\n",
                s->x1, s->x2, s->y1, s->y2, w, h, x, y, frame->pts,
-- 
2.14.2



More information about the ffmpeg-devel mailing list