diff mbox

[FFmpeg-devel] lavf: add textdata virtual demuxer and demuxer

Message ID 20160830103127.GC8104@barisone
State Superseded
Headers show

Commit Message

Stefano Sabatini Aug. 30, 2016, 10:31 a.m. UTC
On date Tuesday 2016-08-23 16:53:28 +0200, Nicolas George encoded:
> Le septidi 7 fructidor, an CCXXIV, Stefano Sabatini a écrit :
> > Bump.
> > 
> > So, basically, what are the features that you want to add?
> > I can list a few:
> > 
> > - have multiple streams (with media type and optionally encoding,
> >   assumes base64 by default) in a dedicated header
> > 
> > - specify codec parameters: this could be done serializing
> >   AVCodecParameters. This is the part which would be less robust.
> > 
> > The important point to keep in mind is that this is meant to be an
> > internal format, so it should be used internally (e.g. to mux data)
> > coming from an external source, and we give no guarantee that the
> > format will be robust to changes in libavformat/libavcodec (e.g. in
> > case AVCodecParameter is extended).
> > 
> > My main objection to the ffprobe format is that it's not easily
> > parseable, but I can reconsider it in case there is a strong request
> > for that.
> 

> Sorry for the delay. Here is the patch; as you can see it is two and a half
> years old. IIRC, it used to work with the output of "ffprobe -show_format
> -show_streams -show_packets -show_data", provided the output was edited to
> put the sections in the required order.
> 

> The benefit from using ffprobe instead of a custom format is to not have yet
> another variant of text format.

Sure.

I rebased the patch, and performed two simple changes in ffprobe (see
attachment), and it's almost working.

I think supporting the show_compact_data mode should simplify the
format in case the format is generated programmatically/through
scripting.
diff mbox

Patch

From 5547d1c81f61ee16419872073e1775667b6e80a9 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini <stefasab@gmail.com>
Date: Tue, 30 Aug 2016 11:35:18 +0200
Subject: [PATCH] ffprobe: add show_compact_data option

This is meant to slightly reduce the output size.
---
 ffprobe.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ffprobe.c b/ffprobe.c
index 42a8d8e..a06e5d7 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -99,6 +99,7 @@  static int use_byte_value_binary_prefix = 0;
 static int use_value_sexagesimal_format = 0;
 static int show_private_data            = 1;
 static int show_headers_first           = 0;
+static int show_compact_data            = 0;
 
 static char *print_format;
 static char *stream_specifier;
@@ -723,17 +724,20 @@  static void writer_print_data(WriterContext *wctx, const char *name,
     av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
     av_bprintf(&bp, "\n");
     while (size) {
+        if (!show_compact_data)
         av_bprintf(&bp, "%08x: ", offset);
         l = FFMIN(size, 16);
         for (i = 0; i < l; i++) {
             av_bprintf(&bp, "%02x", data[i]);
-            if (i & 1)
+            if (!show_compact_data && (i & 1))
                 av_bprintf(&bp, " ");
         }
+        if (!show_compact_data) {
         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;
@@ -3235,6 +3239,7 @@  static const OptionDef real_options[] = {
     { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default}, "generic catch all option", "" },
     { "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
     { "show_headers_first", OPT_BOOL, {&show_headers_first}, "show headers before the packets/frames" },
+    { "show_compact_data", OPT_BOOL, {&show_compact_data}, "show packet data in a compact format" },
     { NULL, },
 };
 
-- 
1.9.1