Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-21 Thread Tobias Rapp

On 21.03.2018 00:04, Michael Niedermayer wrote:

On Tue, Mar 20, 2018 at 09:36:51AM +0100, Tobias Rapp wrote:

On 20.03.2018 02:44, Michael Niedermayer wrote:

On Mon, Mar 19, 2018 at 09:31:44AM +0100, Tobias Rapp wrote:

On 14.03.2018 09:55, Tobias Rapp wrote:

Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
using a distinct command-line option, similar to other flag options.
Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
to the "loglevel" option value.

Signed-off-by: Tobias Rapp 
---
  doc/fftools-common-opts.texi | 13 +
  fftools/cmdutils.c   | 31 +++
  fftools/cmdutils.h   |  6 ++
  3 files changed, 50 insertions(+)

[...]


Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on the
CLI. Using the existing flags option string parsing functions seemed easier
and more consistent that extending the custom loglevel string parser.


this means the feature would require every user app to add similar code
if one wants to support it.

it would be better if apps do not need changes for added options


Not sure I understand. Do you mean user apps that link to libav* libraries
and want to mimic the command-line options of ffmpeg/ffprobe/ffplay?


no, i mean that a user app doesnt want to support each option by specific code
most user apps just want things to work without changes

imagine each option for each codec would need a change to each user app
... unpractical ...



What
alternative would you suggest for managing AV_LOG_PRINT_LEVEL via
command-line options?


whatever parses the log level could also do all options
or am i missing something ?


No existing option is changed or removed, just some new option is added. 
So user apps (like scripts that call ffmpeg binaries, I assume) wouldn't 
need changes.


But it seems a solution that merges into the existing "loglevel" option 
is preferred, so will work on that instead.


Regards,
Tobias

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-20 Thread Michael Niedermayer
On Tue, Mar 20, 2018 at 09:36:51AM +0100, Tobias Rapp wrote:
> On 20.03.2018 02:44, Michael Niedermayer wrote:
> >On Mon, Mar 19, 2018 at 09:31:44AM +0100, Tobias Rapp wrote:
> >>On 14.03.2018 09:55, Tobias Rapp wrote:
> >>>Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
> >>>using a distinct command-line option, similar to other flag options.
> >>>Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
> >>>to the "loglevel" option value.
> >>>
> >>>Signed-off-by: Tobias Rapp 
> >>>---
> >>>  doc/fftools-common-opts.texi | 13 +
> >>>  fftools/cmdutils.c   | 31 +++
> >>>  fftools/cmdutils.h   |  6 ++
> >>>  3 files changed, 50 insertions(+)
> >>>
> >>>[...]
> >>
> >>Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on the
> >>CLI. Using the existing flags option string parsing functions seemed easier
> >>and more consistent that extending the custom loglevel string parser.
> >
> >this means the feature would require every user app to add similar code
> >if one wants to support it.
> >
> >it would be better if apps do not need changes for added options
> 
> Not sure I understand. Do you mean user apps that link to libav* libraries
> and want to mimic the command-line options of ffmpeg/ffprobe/ffplay? 

no, i mean that a user app doesnt want to support each option by specific code
most user apps just want things to work without changes

imagine each option for each codec would need a change to each user app
... unpractical ...


> What
> alternative would you suggest for managing AV_LOG_PRINT_LEVEL via
> command-line options?

whatever parses the log level could also do all options
or am i missing something ?

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-20 Thread Tobias Rapp

On 20.03.2018 02:44, Michael Niedermayer wrote:

On Mon, Mar 19, 2018 at 09:31:44AM +0100, Tobias Rapp wrote:

On 14.03.2018 09:55, Tobias Rapp wrote:

Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
using a distinct command-line option, similar to other flag options.
Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
to the "loglevel" option value.

Signed-off-by: Tobias Rapp 
---
  doc/fftools-common-opts.texi | 13 +
  fftools/cmdutils.c   | 31 +++
  fftools/cmdutils.h   |  6 ++
  3 files changed, 50 insertions(+)

[...]


Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on the
CLI. Using the existing flags option string parsing functions seemed easier
and more consistent that extending the custom loglevel string parser.


this means the feature would require every user app to add similar code
if one wants to support it.

it would be better if apps do not need changes for added options


Not sure I understand. Do you mean user apps that link to libav* 
libraries and want to mimic the command-line options of 
ffmpeg/ffprobe/ffplay? What alternative would you suggest for managing 
AV_LOG_PRINT_LEVEL via command-line options?


Regards,
Tobias

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-19 Thread Michael Niedermayer
On Mon, Mar 19, 2018 at 09:31:44AM +0100, Tobias Rapp wrote:
> On 14.03.2018 09:55, Tobias Rapp wrote:
> >Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
> >using a distinct command-line option, similar to other flag options.
> >Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
> >to the "loglevel" option value.
> >
> >Signed-off-by: Tobias Rapp 
> >---
> >  doc/fftools-common-opts.texi | 13 +
> >  fftools/cmdutils.c   | 31 +++
> >  fftools/cmdutils.h   |  6 ++
> >  3 files changed, 50 insertions(+)
> >
> >[...]
> 
> Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on the
> CLI. Using the existing flags option string parsing functions seemed easier
> and more consistent that extending the custom loglevel string parser.

this means the feature would require every user app to add similar code
if one wants to support it.

it would be better if apps do not need changes for added options

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-19 Thread Tobias Rapp

On 14.03.2018 09:55, Tobias Rapp wrote:

Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
using a distinct command-line option, similar to other flag options.
Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
to the "loglevel" option value.

Signed-off-by: Tobias Rapp 
---
  doc/fftools-common-opts.texi | 13 +
  fftools/cmdutils.c   | 31 +++
  fftools/cmdutils.h   |  6 ++
  3 files changed, 50 insertions(+)

[...]


Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on 
the CLI. Using the existing flags option string parsing functions seemed 
easier and more consistent that extending the custom loglevel string parser.


Regards,
Tobias

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-14 Thread Tobias Rapp
Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
using a distinct command-line option, similar to other flag options.
Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
to the "loglevel" option value.

Signed-off-by: Tobias Rapp 
---
 doc/fftools-common-opts.texi | 13 +
 fftools/cmdutils.c   | 31 +++
 fftools/cmdutils.h   |  6 ++
 3 files changed, 50 insertions(+)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index 185ec21..dd69741 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -209,6 +209,19 @@ the environment variable @env{AV_LOG_FORCE_COLOR}.
 The use of the environment variable @env{NO_COLOR} is deprecated and
 will be dropped in a future FFmpeg version.
 
+@item -logflags flags (@emph{global})
+Allows to set or clear logging flags.
+
+Possible flags for this option are:
+@table @option
+@item repeat
+Repeated log output will not be compressed to the first line and the "Last
+message repeated n times" line will be omitted.
+@item level
+Add a @code{[level]} prefix string to each log message. Can be used as an
+alternative to log coloring e.g. when dumping the log to file.
+@end table
+
 @item -report
 Dump full command line and console output to a file named
 @code{@var{program}-@var{MMDD}-@var{HHMMSS}.log} in the current
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 0c7d13c..11fe69a 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -514,6 +514,9 @@ void parse_loglevel(int argc, char **argv, const OptionDef 
*options)
 idx = locate_option(argc, argv, options, "v");
 if (idx && argv[idx + 1])
 opt_loglevel(NULL, "loglevel", argv[idx + 1]);
+idx = locate_option(argc, argv, options, "logflags");
+if (idx && argv[idx + 1])
+opt_logflags(NULL, "logflags", argv[idx + 1]);
 idx = locate_option(argc, argv, options, "report");
 if ((env = getenv("FFREPORT")) || idx) {
 init_report(env);
@@ -918,6 +921,34 @@ int opt_loglevel(void *optctx, const char *opt, const char 
*arg)
 return 0;
 }
 
+int opt_logflags(void *optctx, const char *opt, const char *arg)
+{
+static const AVOption logflags_opts[] = {
+{ "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, 
INT64_MAX, .unit = "flags" },
+/* implement AV_LOG_SKIP_REPEATED using inverse logic for consistency 
with the -loglevel option */
+{ "repeat", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_LOG_SKIP_REPEATED 
},.unit = "flags" },
+{ "level" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_LOG_PRINT_LEVEL   
},.unit = "flags" },
+{ NULL },
+};
+static const AVClass class = {
+.class_name = "logflags",
+.item_name  = av_default_item_name,
+.option = logflags_opts,
+.version= LIBAVUTIL_VERSION_INT,
+};
+const AVClass *pclass = 
+int flags = av_log_get_flags();
+int ret;
+
+flags ^= AV_LOG_SKIP_REPEATED;
+if ((ret = av_opt_eval_flags(, _opts[0], arg, )) < 0)
+return ret;
+flags ^= AV_LOG_SKIP_REPEATED;
+
+av_log_set_flags(flags);
+return 0;
+}
+
 static void expand_filename_template(AVBPrint *bp, const char *template,
  struct tm *tm)
 {
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 8724489..28735b2 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -99,6 +99,11 @@ int opt_default(void *optctx, const char *opt, const char 
*arg);
  */
 int opt_loglevel(void *optctx, const char *opt, const char *arg);
 
+/**
+ * Update the log flags of libav* libraries.
+ */
+int opt_logflags(void *optctx, const char *opt, const char *arg);
+
 int opt_report(const char *opt);
 
 int opt_max_alloc(void *optctx, const char *opt, const char *arg);
@@ -236,6 +241,7 @@ void show_help_options(const OptionDef *options, const char 
*msg, int req_flags,
 { "colors",  OPT_EXIT, { .func_arg = show_colors },  
"show available color names" },\
 { "loglevel",HAS_ARG,  { .func_arg = opt_loglevel }, 
"set logging level", "loglevel" }, \
 { "v",   HAS_ARG,  { .func_arg = opt_loglevel }, 
"set logging level", "loglevel" }, \
+{ "logflags",HAS_ARG,  { .func_arg = opt_logflags }, 
"set logging flags", "flags" },\
 { "report",  0,{ (void*)opt_report },
"generate a report" }, \
 { "max_alloc",   HAS_ARG,  { .func_arg = opt_max_alloc },
"set maximum size of a single allocated block", "bytes" }, \
 { "cpuflags",HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, 
"force specific cpu flags", "flags" }, \
-- 
2.7.4


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org