[FFmpeg-devel] [PATCH] Define cmdline_program_name and use it in show_help

Benoit Fouet ml_benoitfouet
Mon Oct 27 09:51:12 CET 2008


Hi,

Stefano Sabatini wrote:
> Hi, as in subject.
>
> Usage message shown in show_help mimicks the commandline command to
> issue, so program_name is not the right choice, and to use argv[0] is
> nicer than use an hardcoded value.
>
> Regards.
> --
> FFmpeg = Fantastic and Funny Mythic Portentous Empowered Gadget
>   
> ------------------------------------------------------------------------
>
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 15712)
> +++ ffmpeg.c	(working copy)
> @@ -71,6 +71,7 @@
>  #undef exit
>  
>  const char program_name[] = "FFmpeg";
> +const char* cmdline_program_name = NULL;
>   

why is it not static ? btw, I'd prefer char *foo to char* foo, but maybe
that's just me...

>  const int program_birth_year = 2000;
>  
>  /* select an input stream for an output stream */
> @@ -3447,8 +3448,8 @@
>  static void show_help(void)
>  {
>      av_log_set_callback(log_callback_help);
> -    printf("usage: ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...\n"
> -           "Hyper fast Audio and Video encoder\n");
> +    printf("usage: %s [[infile options] -i infile]... {[outfile options] outfile}...\n"
> +           "Hyper fast Audio and Video encoder\n", cmdline_program_name);
>      printf("\n");
>      show_help_options(options, "Main options:\n",
>                        OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE | OPT_GRAB, 0);
> @@ -3856,6 +3857,7 @@
>  
>  int main(int argc, char **argv)
>  {
> +    cmdline_program_name = argv[0];
>      int i;
>      int64_t ti;
>   

please assign the variable after the declaration
same remarks apply to ffplay and ffserver...

-- 
Benoit Fouet
Purple Labs S.A.
www.purplelabs.com





More information about the ffmpeg-devel mailing list