From patchwork Mon Jun 10 23:05:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: greg Luce X-Patchwork-Id: 13488 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1EF48449733 for ; Tue, 11 Jun 2019 02:06:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E90CF68A723; Tue, 11 Jun 2019 02:06:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4579968A62C for ; Tue, 11 Jun 2019 02:06:26 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id a21so9602915ljh.7 for ; Mon, 10 Jun 2019 16:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=p6Ore4Cdw8i/+PQUG9sKN3nGSa7+Y67U5URAKLg3mzE=; b=QNGkltlTBzn3I3mxwXMxy4jEMqsB/ndp/wmDxpkMg7vydy+7/Af8bjFdFkunGzHRvf bpAId4BGxD/7lwK1XDwZjLnZzH9UJCSxplNhWvrD9BHtP08gwHS0BzUTox9T9z1wlRTX bESwflrGm0YZHSn5bjKoWNVzyNlFMI03n4TuzX9kxHikFrS/F2RUohouPzhs6CCZ06zq 4LoR6wq3A/aiHTJWRbGZzCs6PTvURzNg5MPX8dMtxerVOMFIl8zuJe06/BHASHrRsDzk SmlB4dxQta3ygJR93MRJlkiHsfXWlFZ3TNX7Gd0D8H4hOBUKxLyPYJeCglho61sonysi JbWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=p6Ore4Cdw8i/+PQUG9sKN3nGSa7+Y67U5URAKLg3mzE=; b=SEAraujMy6RYj8X3p3ChFPnK69yFbhAjPx6MiuKF3pPVeM0K2HfxRpk5kbaY+jw5zO WA9VTBcx0bgC0FW1c1OO0aLF4boWHP9YKVZwWd8+QoRsmrNKYoCXzJWEGSJp0+fWlhxr 6rRrI0RY2KPYcnn8fF7EAkQu2Odu5w+lKQqn5lvNtQGJbQorS7JQ0Rja/2Y2vtAt3lX5 Ql4f8HyTk61BRK/kVexbdX5lifUo3irXSmCf0lUe1AAOF7siPwOdUA304kYoWlU1PP8c HUeGVVg5A6u78Ala5/2aLd02FEbWJ+cC+X0Ikw4zEknHC+lOsaQmD8uN9QN+VkzLscJI REsA== X-Gm-Message-State: APjAAAVFntkBi4IPF+OK/8Tq8SniIFyG9LnnFf5x2Bn57oEGTJouMd/A 5iquNtAYWY+QDLaLdubApOwOVztPEK0nPWtRwx/hi1i8 X-Google-Smtp-Source: APXvYqzjdrNVR8nGTbBBIc2Ebg0TEvVVIuCoce/S/PyGi//ul0x51/elnAUCDwb1k+f/cwextKg0CfZhXdsGubI2KV0= X-Received: by 2002:a2e:9692:: with SMTP id q18mr39361930lji.89.1560207985086; Mon, 10 Jun 2019 16:06:25 -0700 (PDT) MIME-Version: 1.0 From: greg Luce Date: Mon, 10 Jun 2019 19:05:21 -0400 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I created this issue on the bugtracker but I'm trying to format it properly for this channel https://trac.ffmpeg.org/ticket/7947 The actual filter change was written by Calvin Walton --- draw_text(ctx, frame, frame->width, frame->height); --- diff --git a/doc/filters.texi b/doc/filters.texi index ec1c7c7591..332f4ddc80 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8584,6 +8584,17 @@ The thickness of the drawn box. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}. +@item pict_type +A 1 character description of the current packet's input picture type. + +@item pkt_pos +The current packet's position in the input datastream (in bytes from the head of the source file) + +@item pkt_duration +The current packet's input duration + +@item pkt_size +The current packet's input size (in bytes) @end table @@ -9032,6 +9043,14 @@ The first argument is mandatory and specifies the metadata key. The second argument is optional and specifies a default value, used when the metadata key is not found or empty. +The use of the term metadata in ffmpeg refers to extra data, +often user-provided or generated live during decode by other filters. + +If you're trying to read data from teh frames in a stream or file, run +@code{ffprobe -show_frames}. If the information doesn't show up between +@code{[FRAME]} and @code{[/FRAME]} in the form @code{TAG:[metadata_key]=[metadata_value]} +then it won't be visible to this function. + @item n, frame_num The frame number, starting from 0. diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 01cd7fa122..8f4badbdb5 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -88,6 +88,9 @@ static const char *const var_names[] = { "x", "y", "pict_type", + "pkt_pos", + "pkt_duration", + "pkt_size", NULL }; @@ -125,6 +128,9 @@ enum var_name { VAR_X, VAR_Y, VAR_PICT_TYPE, + VAR_PKT_POS, + VAR_PKT_DURATION, + VAR_PKT_SIZE, VAR_VARS_NB }; @@ -1516,6 +1522,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) NAN : frame->pts * av_q2d(inlink->time_base); s->var_values[VAR_PICT_TYPE] = frame->pict_type; + s->var_values[VAR_PKT_POS] = frame->pkt_pos; + s->var_values[VAR_PKT_DURATION] = frame->pkt_duration * av_q2d(inlink->time_base); + s->var_values[VAR_PKT_SIZE] = frame->pkt_size; s->metadata = frame->metadata;