[FFmpeg-cvslog] r22923 - in trunk: doc/ffmpeg-doc.texi ffmpeg.c

rbultje subversion
Tue Apr 20 19:37:06 CEST 2010


Author: rbultje
Date: Tue Apr 20 19:37:06 2010
New Revision: 22923

Log:
Allow setting the environment variable FFMPEG_DATADIR to locate preset files.

Patch by Robert Kr?ger <krueger signal7 de>.

Modified:
   trunk/doc/ffmpeg-doc.texi
   trunk/ffmpeg.c

Modified: trunk/doc/ffmpeg-doc.texi
==============================================================================
--- trunk/doc/ffmpeg-doc.texi	Tue Apr 20 19:05:02 2010	(r22922)
+++ trunk/doc/ffmpeg-doc.texi	Tue Apr 20 19:37:06 2010	(r22923)
@@ -806,9 +806,9 @@ preset options identifies the preset fil
 following rules:
 
 First ffmpeg searches for a file named @var{arg}.ffpreset in the
-directories @file{$HOME/.ffmpeg}, and in the datadir defined at
-configuration time (usually @file{PREFIX/share/ffmpeg}) in that
-order. For example, if the argument is @code{libx264-max}, it will
+directories @file{$FFMPEG_DATADIR} (if set), and @file{$HOME/.ffmpeg}, and in
+the datadir defined at configuration time (usually @file{PREFIX/share/ffmpeg})
+in that order. For example, if the argument is @code{libx264-max}, it will
 search for the file @file{libx264-max.ffpreset}.
 
 If no such file is found, then ffmpeg will search for a file named

Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c	Tue Apr 20 19:05:02 2010	(r22922)
+++ trunk/ffmpeg.c	Tue Apr 20 19:37:06 2010	(r22923)
@@ -3890,19 +3890,22 @@ static int opt_preset(const char *opt, c
     FILE *f=NULL;
     char filename[1000], tmp[1000], tmp2[1000], line[1000];
     int i;
-    const char *base[2]= { getenv("HOME"),
+    const char *base[3]= { getenv("FFMPEG_DATADIR"),
+                           getenv("HOME"),
                            FFMPEG_DATADIR,
                          };
 
     if (*opt != 'f') {
-        for(i=!base[0]; i<2 && !f; i++){
-            snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg);
+        for(i=0; i<3 && !f; i++){
+            if(!base[i])
+                continue;
+            snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", arg);
             f= fopen(filename, "r");
             if(!f){
                 char *codec_name= *opt == 'v' ? video_codec_name :
                                   *opt == 'a' ? audio_codec_name :
                                                 subtitle_codec_name;
-                snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i],  i ? "" : "/.ffmpeg", codec_name, arg);
+                snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i],  i != 1 ? "" : "/.ffmpeg", codec_name, arg);
                 f= fopen(filename, "r");
             }
         }



More information about the ffmpeg-cvslog mailing list