Browse code

avconv: make the -passlogfile option per-stream.

Anton Khirnov authored on 2012/08/19 16:15:48
Showing 5 changed files
... ...
@@ -43,7 +43,7 @@ version <next>:
43 43
 - RTMPTE protocol support
44 44
 - Canopus Lossless Codec decoder
45 45
 - avconv -shortest option is now per-output file,
46
-  -pass is now per-output stream
46
+  -pass and -passlogfile are now per-output stream
47 47
 - Ut Video encoder
48 48
 
49 49
 
... ...
@@ -183,6 +183,7 @@ void exit_program(int ret)
183 183
 
184 184
         av_freep(&output_streams[i]->forced_keyframes);
185 185
         av_freep(&output_streams[i]->avfilter);
186
+        av_freep(&output_streams[i]->logfile_prefix);
186 187
         av_freep(&output_streams[i]->filtered_frame);
187 188
         av_freep(&output_streams[i]);
188 189
     }
... ...
@@ -1747,7 +1748,8 @@ static int transcode_init(void)
1747 1747
                 FILE *f;
1748 1748
 
1749 1749
                 snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
1750
-                         pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,
1750
+                         ost->logfile_prefix ? ost->logfile_prefix :
1751
+                                               DEFAULT_PASS_LOGFILENAME_PREFIX,
1751 1752
                          i);
1752 1753
                 if (!strcmp(ost->enc->name, "libx264")) {
1753 1754
                     av_dict_set(&ost->opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
... ...
@@ -160,6 +160,8 @@ typedef struct OptionsContext {
160 160
     int        nb_filters;
161 161
     SpecifierOpt *pass;
162 162
     int        nb_pass;
163
+    SpecifierOpt *passlogfiles;
164
+    int        nb_passlogfiles;
163 165
 } OptionsContext;
164 166
 
165 167
 typedef struct InputFilter {
... ...
@@ -284,6 +286,7 @@ typedef struct OutputStream {
284 284
     int forced_kf_index;
285 285
     char *forced_keyframes;
286 286
 
287
+    char *logfile_prefix;
287 288
     FILE *logfile;
288 289
 
289 290
     OutputFilter *filter;
... ...
@@ -323,7 +326,6 @@ extern int         nb_output_files;
323 323
 extern FilterGraph **filtergraphs;
324 324
 extern int        nb_filtergraphs;
325 325
 
326
-extern char *pass_logfilename_prefix;
327 326
 extern char *vstats_filename;
328 327
 
329 328
 extern float audio_drift_threshold;
... ...
@@ -54,7 +54,6 @@
54 54
     }\
55 55
 }
56 56
 
57
-char *pass_logfilename_prefix = NULL;
58 57
 char *vstats_filename;
59 58
 
60 59
 float audio_drift_threshold = 0.1;
... ...
@@ -967,6 +966,11 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
967 967
             }
968 968
         }
969 969
 
970
+        MATCH_PER_STREAM_OPT(passlogfiles, str, ost->logfile_prefix, oc, st);
971
+        if (ost->logfile_prefix &&
972
+            !(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
973
+            exit_program(1);
974
+
970 975
         MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st);
971 976
         if (ost->forced_keyframes)
972 977
             ost->forced_keyframes = av_strdup(ost->forced_keyframes);
... ...
@@ -1967,7 +1971,7 @@ const OptionDef options[] = {
1967 1967
         "use same quantizer as source (implies VBR)" },
1968 1968
     { "pass",         OPT_VIDEO | HAS_ARG | OPT_SPEC | OPT_INT,                  { .off = OFFSET(pass) },
1969 1969
         "select the pass number (1 or 2)", "n" },
1970
-    { "passlogfile",  OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT,             { &pass_logfilename_prefix },
1970
+    { "passlogfile",  OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC,  { .off = OFFSET(passlogfiles) },
1971 1971
         "select two pass log file name prefix", "prefix" },
1972 1972
     { "deinterlace",  OPT_VIDEO | OPT_EXPERT ,                                   { .func_arg = opt_deinterlace },
1973 1973
         "this option is deprecated, use the yadif filter instead" },
... ...
@@ -492,7 +492,7 @@ avconv -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
492 492
 avconv -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
493 493
 @end example
494 494
 
495
-@item -passlogfile @var{prefix} (@emph{global})
495
+@item -passlogfile[:@var{stream_specifier}] @var{prefix} (@emph{output,per-stream})
496 496
 Set two-pass log file name prefix to @var{prefix}, the default file name
497 497
 prefix is ``av2pass''. The complete file name will be
498 498
 @file{PREFIX-N.log}, where N is a number specific to the output