[FFmpeg-devel] Allow to force colored output

Michael Niedermayer michaelni
Mon Nov 15 02:07:17 CET 2010


On Sun, Nov 14, 2010 at 05:09:31PM +0100, Etienne Buira wrote:
> On Sun, Nov 14, 2010 at 03:47:06PM +0100, Stefano Sabatini wrote:
> > On date Sunday 2010-11-14 15:02:58 +0100, Etienne Buira encoded:
> > > On Sun, Nov 14, 2010 at 02:44:02PM +0100, Etienne Buira wrote:
> > > > On Sun, Nov 14, 2010 at 02:23:29PM +0100, Stefano Sabatini wrote:
> > [...]
> > > > > We should provide a namespace even in this case, I suggest:
> > > > > FFMPEG_NO_COLOR
> > > > > FFMPEG_FORCE_COLOR
> > > > 
> > > > Done, but might break for people who use NO_COLOR yet.
> > > > 
> > > > > Also can you say why do you need this?
> > > > 
> > > > My usecase is to save ffmpeg's output (ffmpeg ... > log 2>&1), but still
> > > > having nice colors.
> > > 
> > > Sorry for the noise, this one should actually not screw up things for
> > > win32.
> > 
> > > Index: libavutil/log.c
> > > ===================================================================
> > > --- libavutil/log.c	(revision 25751)
> > > +++ libavutil/log.c	(working copy)
> > > @@ -55,16 +55,16 @@
> > >  #if defined(_WIN32) && !defined(__MINGW32CE__)
> > >          CONSOLE_SCREEN_BUFFER_INFO con_info;
> > >          con = GetStdHandle(STD_ERROR_HANDLE);
> > > -        use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR");
> > > +        use_color = (con != INVALID_HANDLE_VALUE) && (!getenv("FFMPEG_NO_COLOR") || getenv("FFMPEG_FORCE_COLOR"));
> > >          if (use_color) {
> > >              GetConsoleScreenBufferInfo(con, &con_info);
> > >              attr_orig  = con_info.wAttributes;
> > >              background = attr_orig & 0xF0;
> > >          }
> > >  #elif HAVE_ISATTY
> > > -        use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2);
> > > +        use_color= (getenv("TERM") && !getenv("FFMPEG_NO_COLOR") && isatty(2)) || getenv("FFMPEG_FORCE_COLOR");
> > >  #else
> > > -        use_color= 0;
> > > +        use_color= !!getenv("FFMPEG_FORCE_COLOR");
> > >  #endif
> > >      }
> > 
> > Don't mix separate changes, simply call the new variable
> > FFMPEG_FORCE_COLOR, the change NO_COLOR -> FFMPEG_NO_COLOR belongs to
> > a different patch.
> 
> Hope this one is ok, feel free to adapt to your taste.

>  doc/fftools-common-opts.texi |    3 ++-
>  libavutil/log.c              |    6 +++---
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 8da2d1b26e1b73c92d454900f4d01e17c15e8266  ffmpeg_allow_to_force_colored_output_hns_w32s.diff
> Index: libavutil/log.c
> ===================================================================
> --- libavutil/log.c	(revision 25751)
> +++ libavutil/log.c	(working copy)
> @@ -55,16 +55,16 @@
>  #if defined(_WIN32) && !defined(__MINGW32CE__)
>          CONSOLE_SCREEN_BUFFER_INFO con_info;
>          con = GetStdHandle(STD_ERROR_HANDLE);
> -        use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR");
> +        use_color = (con != INVALID_HANDLE_VALUE) && (!getenv("NO_COLOR") || getenv("FFMPEG_FORCE_COLOR"));

what does this do?
the right side wont even be evaluated if NO_COLOR isnt set

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

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101115/585008e0/attachment.pgp>



More information about the ffmpeg-devel mailing list