[FFmpeg-devel] [PATCH] Improve error-messaging with ffmpeg presets

Benoit Fouet benoit.fouet
Fri Oct 17 00:53:04 CEST 2008


Stefano Sabatini a ?crit :
> On date Tuesday 2008-10-14 21:43:08 +0200, Stefano Sabatini encoded:
>   
>> On date Sunday 2008-10-12 11:48:29 +0200, Stefano Sabatini encoded:
>> [...]
>>     
>>> Then I realized I wasn't satisfied with the patch, please check the
>>> attached one.
>>>
>>> I introduced a filename string which is used to print the name of the
>>> file where the error is eventually encountered, and I changed:
>>>    fprintf(stderr, "Preset file '%s' not found\n", arg);
>>> to 
>>>    fprintf(stderr, "File for preset '%s' not found\n", arg);
>>>
>>> since the argument doesn't necessarily specify a filename.
>>>       
>> Attaching again the patch split.
>>
>> Regards.
>> -- 
>> FFmpeg = Forgiving and Fiendish Multimedia Pitiless Eager God
>>     
>
>   
>> Index: ffmpeg.c
>> ===================================================================
>> --- ffmpeg.c	(revision 15615)
>> +++ ffmpeg.c	(working copy)
>> @@ -3690,7 +3690,7 @@
>>      }
>>  
>>      if(!f){
>> -        fprintf(stderr, "Preset file not found\n");
>> +        fprintf(stderr, "File for preset '%s' not found\n", arg);
>>          av_exit(1);
>>      }
>>  
>>     
>
>   

I think I'd prefer "Preset file '%s' not found\n"
the one above could be misinterpreted (arg could be interpreted as a preset)

>> Index: ffmpeg.c
>> ===================================================================
>> --- ffmpeg.c	(revision 15615)
>> +++ ffmpeg.c	(working copy)
>> @@ -3667,7 +3667,7 @@
>>  static int opt_preset(const char *opt, const char *arg)
>>  {
>>      FILE *f=NULL;
>> -    char tmp[1000], tmp2[1000], line[1000];
>> +    char filename[1000], tmp[1000], tmp2[1000], line[1000];
>>      int i;
>>      const char *base[3]= { getenv("HOME"),
>>                             "/usr/local/share",
>> @@ -3675,18 +3675,19 @@
>>                           };
>>  
>>      for(i=!base[0]; i<3 && !f; i++){
>> -        snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);
>> -        f= fopen(tmp, "r");
>> +        snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);
>> +        f= fopen(filename, "r");
>>          if(!f){
>>              char *codec_name= *opt == 'v' ? video_codec_name :
>>                                *opt == 'a' ? audio_codec_name :
>>                                              subtitle_codec_name;
>> -              snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s-%s.ffpreset", base[i],  i ? "" : ".", codec_name, arg);
>> -            f= fopen(tmp, "r");
>> +              snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s-%s.ffpreset", base[i],  i ? "" : ".", codec_name, arg);
>> +            f= fopen(filename, "r");
>>          }
>>      }
>>      if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/')){
>> -        f= fopen(arg, "r");
>> +        snprintf(filename, sizeof(filename), arg);
>> +        f= fopen(filename, "r");
>>      }
>>  
>>      if(!f){
>> @@ -3709,8 +3710,10 @@
>>              opt_video_codec(tmp2);
>>          }else if(!strcmp(tmp, "scodec")){
>>              opt_subtitle_codec(tmp2);
>> -        }else
>> -            opt_default(tmp, tmp2);
>> +        }else if(opt_default(tmp, tmp2) < 0){
>> +            fprintf(stderr, "%s: Invalid option or argument: %s=%s\n", filename, tmp, tmp2);
>> +            av_exit(1);
>> +        }
>>      }
>>  
>>      fclose(f);
>>     
>
> I'll apply both on the weekend if there are no objections.
>
> Regards.
>   

-- 
Benoit Fouet




More information about the ffmpeg-devel mailing list