[FFmpeg-devel] [PATCH] lavfi/cropdetect: export crop info to metadata

Paul B Mahol onemda at gmail.com
Fri May 24 15:53:28 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavfilter/vf_cropdetect.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 28ae887..25a8989 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -118,6 +118,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     CropDetectContext *s = ctx->priv;
     int bpp = s->max_pixsteps[0];
     int w, h, x, y, shrink_by;
+    char buf[128];
 
     // ignore first 2 frames - they may be empty
     if (++s->frame_nb > 0) {
@@ -181,6 +182,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         h -= shrink_by;
         y += (shrink_by/2 + 1) & ~1;
 
+        snprintf(buf, sizeof(buf), "%d:%d:%d:%d", w, h, x, y);
+        av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.crop", buf, 0);
+
         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,
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list