[FFmpeg-cvslog] Blackframe video filter now sets metadata accordingly.

Stepan Bujnak git at videolan.org
Tue Jul 15 23:46:50 CEST 2014


ffmpeg | branch: master | Stepan Bujnak <stepan.bujnak at gmail.com> | Fri Jul 11 23:40:07 2014 +0200| [895e92eca0509e540e98913436533ae032552655] | committer: Michael Niedermayer

Blackframe video filter now sets metadata accordingly.

the libavfilter/vf_blackframe.c filter now not only logs detected
values, but also sets frame metadata. Currently, only `pblack` value is set
but `SET_META` macro has been introduced to ease development in the future.

Signed-off-by: Stepan Bujnak <stepan.bujnak at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=895e92eca0509e540e98913436533ae032552655
---

 libavfilter/vf_blackframe.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c
index 0eeda61..1be9fcc 100644
--- a/libavfilter/vf_blackframe.c
+++ b/libavfilter/vf_blackframe.c
@@ -58,6 +58,10 @@ static int query_formats(AVFilterContext *ctx)
     return 0;
 }
 
+#define SET_META(key, format, value) \
+    snprintf(buf, sizeof(buf), format, value);  \
+    av_dict_set(metadata, key, buf, 0)
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 {
     AVFilterContext *ctx = inlink->dst;
@@ -65,6 +69,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     int x, i;
     int pblack = 0;
     uint8_t *p = frame->data[0];
+    AVDictionary **metadata;
+    char buf[32];
 
     for (i = 0; i < frame->height; i++) {
         for (x = 0; x < inlink->w; x++)
@@ -76,13 +82,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         s->last_keyframe = s->frame;
 
     pblack = s->nblack * 100 / (inlink->w * inlink->h);
-    if (pblack >= s->bamount)
+    if (pblack >= s->bamount) {
+        metadata = avpriv_frame_get_metadatap(frame);
+
         av_log(ctx, AV_LOG_INFO, "frame:%u pblack:%u pts:%"PRId64" t:%f "
                "type:%c last_keyframe:%d\n",
                s->frame, pblack, frame->pts,
                frame->pts == AV_NOPTS_VALUE ? -1 : frame->pts * av_q2d(inlink->time_base),
                av_get_picture_type_char(frame->pict_type), s->last_keyframe);
 
+        SET_META("lavfi.blackframe.pblack", "%u", pblack);
+    }
+
     s->frame++;
     s->nblack = 0;
     return ff_filter_frame(inlink->dst->outputs[0], frame);



More information about the ffmpeg-cvslog mailing list