History

In libx264 wrapper, correctly support 2pass log filename option.

Baptiste Coudurier committed 15 years ago

Commit 2c188931 parent b9553cf2 files · +22 −3Browse files

Unified · Split

2 files
  1. ffmpeg.c +9 −3
  2. libavcodec/libx264.c +13 −0
ffmpeg.c+9−3
@@ -207,7 +207,7 @@ static int do_hex_dump = 0; · 206 unmodified lines
207207 static int do_pkt_dump = 0;
208208 static int do_psnr = 0;
209209 static int do_pass = 0;
210−static char *pass_logfilename_prefix = NULL;
210+static const char *pass_logfilename_prefix;
211211 static int audio_stream_copy = 0;
212212 static int video_stream_copy = 0;
213213 static int subtitle_stream_copy = 0;
@@ -2331,7 +2331,7 @@ static int transcode(AVFormatContext **output_files, · 2117 unmodified lines
23312331 break;
23322332 }
23332333 /* two pass mode */
2334− if (ost->encoding_needed &&
2334+ if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
23352335 (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
23362336 char logfilename[1024];
23372337 FILE *f;
@@ -4268,6 +4268,12 @@ static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) · 1930 unmodified lines
42684268 {
42694269 }
42704270
4271+static void opt_passlogfile(const char *arg)
4272+{
4273+ pass_logfilename_prefix = arg;
4274+ opt_default("passlogfile", arg);
4275+}
4276+
42714277 static const OptionDef options[] = {
42724278 /* main options */
42734279 #include "cmdutils_common_opts.h"
@@ -4341,7 +4347,7 @@ static const OptionDef options[] = { · 67 unmodified lines
43414347 { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality},
43424348 "use same quantizer as source (implies VBR)" },
43434349 { "pass", HAS_ARG | OPT_FUNC2 | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" },
4344− { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" },
4350+ { "passlogfile", HAS_ARG | OPT_VIDEO, {(void*)&opt_passlogfile}, "select two pass log file name prefix", "prefix" },
43454351 { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace},
43464352 "deinterlace pictures" },
43474353 { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" },
libavcodec/libx264.c+13−0
@@ -40,6 +40,7 @@ typedef struct X264Context { · 39 unmodified lines
4040 const char *profile;
4141 const char *level;
4242 int fastfirstpass;
43+ const char *stats;
4344 } X264Context;
4445
4546 static void X264_log(void *p, int level, const char *fmt, va_list args)
@@ -164,6 +165,15 @@ static av_cold int X264_close(AVCodecContext *avctx) · 118 unmodified lines
164165 return 0;
165166 }
166167
168+#define OPT_STR(opt, param) \
169+ do { \
170+ if (param && x264_param_parse(&x4->params, opt, param) < 0) { \
171+ av_log(avctx, AV_LOG_ERROR, \
172+ "bad value for '%s': '%s'\n", opt, param); \
173+ return -1; \
174+ } \
175+ } while (0); \
176+
167177 #define OPT_STR(opt, param) \
168178 do { \
169179 if (param && x264_param_parse(&x4->params, opt, param) < 0) { \
@@ -291,6 +301,8 @@ static av_cold int X264_init(AVCodecContext *avctx) · 121 unmodified lines
291301 }
292302 }
293303
304+ OPT_STR("stats", x4->stats);
305+
294306 // if neither crf nor cqp modes are selected we have to enable the RC
295307 // we do it this way because we cannot check if the bitrate has been set
296308 if (!(avctx->crf || (avctx->cqp > -1)))
@@ -371,6 +383,7 @@ static const AVOption options[] = { · 74 unmodified lines
371383 {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE},
372384 {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
373385 {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
386+ {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
374387 { NULL },
375388 };
376389

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t