[FFmpeg-devel] [PATCH] ffprobe: add -show_data option.

Clément Bœsch ubitux at gmail.com
Sun Apr 8 11:14:00 CEST 2012


On Sun, Apr 08, 2012 at 12:33:54AM +0200, Nicolas George wrote:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  doc/ffprobe.texi |    7 +++++++
>  ffprobe.c        |   35 +++++++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 0 deletions(-)
> 
> 
> The output syntax is probably not ok, but I did not have any better idea,
> and the feature is probably useful (it was to me at least).
> 
> 
> diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> index 12fe29f..7daf7a2 100644
> --- a/doc/ffprobe.texi
> +++ b/doc/ffprobe.texi
> @@ -94,6 +94,13 @@ For example for printing the output in JSON format, specify:
>  For more details on the available output printing formats, see the
>  Writers section below.
>  
> + at item -show_data
> +Show payload data, as an hexadecimal and ASCII dump. Coupled with
> + at option{-show_packets}, it will dump the packets' data. Coupled with
> + at option{-show_streams}, it will dump the codec extradata.
> +

Can't we dump anything with -show_format?

> +The dump is printed as the "data" field. It may contain newlines.
> +
>  @item -show_error
>  Show information about the error found when trying to probe the input.
>  
> diff --git a/ffprobe.c b/ffprobe.c
> index 8a76a0b..992f690 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -52,6 +52,7 @@ static int do_show_format  = 0;
>  static int do_show_frames  = 0;
>  static int do_show_packets = 0;
>  static int do_show_streams = 0;
> +static int do_show_data    = 0;
>  static int do_show_program_version  = 0;
>  static int do_show_library_versions = 0;
>  
> @@ -320,6 +321,34 @@ static inline void writer_show_tags(WriterContext *wctx, AVDictionary *dict)
>      wctx->writer->show_tags(wctx, dict);
>  }
>  
> +static void writer_print_data(WriterContext *wctx, const char *name,
> +                              uint8_t *data, int size)
> +{
> +    AVBPrint bp;
> +    int offset = 0, l, i;
> +
> +    av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
> +    av_bprintf(&bp, "\n");
> +    while (size) {
> +        av_bprintf(&bp, "%08x: ", offset);
> +        l = FFMIN(size, 16);
> +        for (i = 0; i < l; i++) {
> +            av_bprintf(&bp, "%02x", data[i]);
> +            if (i & 1)
> +                av_bprintf(&bp, " ");

I'd personally avoid arbitrary 16-bit grouping, but I guess it can be
changed with an option later. OTOH, an extra space separator in the middle
would be welcome (see hexdump -C).

> +        }
> +        av_bprint_chars(&bp, ' ', 41 - 2 * i - i / 2);
> +        for (i = 0; i < l; i++)
> +            av_bprint_chars(&bp, data[i] - 32U < 95 ? data[i] : '.', 1);
> +        av_bprintf(&bp, "\n");
> +        offset += l;
> +        data   += l;
> +        size   -= l;
> +    }
> +    writer_print_string(wctx, name, bp.str, 0);
> +    av_bprint_finalize(&bp, NULL);
> +}
> +

BTW, can't we improve and make use of av_hex_dump() instead?

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120408/c6971b93/attachment.asc>


More information about the ffmpeg-devel mailing list