summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-19 12:57:32 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-19 12:59:05 +0200
commit247f4d1f181c2801b8321a7ddb88818dc4861155 (patch)
tree37592f29866ffba276115808a1c896bc2c4e7bf2
parentdb3e12a828553171f37c98119679316720e4caed (diff)
parent6d5d9246042acb804a652e6fedfb7afe0ca85614 (diff)
Merge commit '6d5d9246042acb804a652e6fedfb7afe0ca85614'
* commit '6d5d9246042acb804a652e6fedfb7afe0ca85614': avconv: move handling the 2pass logfile into avconv_opt Conflicts: ffmpeg.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--ffmpeg.c35
-rw-r--r--ffmpeg_opt.c36
2 files changed, 36 insertions, 35 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 73792ed44f..4f021d1808 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -136,8 +136,6 @@ AVIOContext *progress_avio = NULL;
static uint8_t *subtitle_out;
-#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
-
InputStream **input_streams = NULL;
int nb_input_streams = 0;
InputFile **input_files = NULL;
@@ -3053,39 +3051,6 @@ static int transcode_init(void)
abort();
break;
}
- /* two pass mode */
- if (enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) {
- char logfilename[1024];
- FILE *f;
-
- snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
- ost->logfile_prefix ? ost->logfile_prefix :
- DEFAULT_PASS_LOGFILENAME_PREFIX,
- i);
- if (!strcmp(ost->enc->name, "libx264")) {
- av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
- } else {
- if (enc_ctx->flags & CODEC_FLAG_PASS2) {
- char *logbuffer;
- size_t logbuffer_size;
- if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
- av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
- logfilename);
- exit_program(1);
- }
- enc_ctx->stats_in = logbuffer;
- }
- if (enc_ctx->flags & CODEC_FLAG_PASS1) {
- f = av_fopen_utf8(logfilename, "wb");
- if (!f) {
- av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
- logfilename, strerror(errno));
- exit_program(1);
- }
- ost->logfile = f;
- }
- }
- }
}
if (ost->disposition) {
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index b04e319630..172a2255d1 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -42,6 +42,8 @@
#include "libavutil/pixfmt.h"
#include "libavutil/time_internal.h"
+#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
+
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
{\
int i, ret;\
@@ -1468,6 +1470,40 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
!(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
exit_program(1);
+ if (do_pass) {
+ char logfilename[1024];
+ FILE *f;
+
+ snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
+ ost->logfile_prefix ? ost->logfile_prefix :
+ DEFAULT_PASS_LOGFILENAME_PREFIX,
+ i);
+ if (!strcmp(ost->enc->name, "libx264")) {
+ av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
+ } else {
+ if (video_enc->flags & CODEC_FLAG_PASS2) {
+ char *logbuffer;
+ size_t logbuffer_size;
+ if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
+ av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
+ logfilename);
+ exit_program(1);
+ }
+ video_enc->stats_in = logbuffer;
+ }
+ if (video_enc->flags & CODEC_FLAG_PASS1) {
+ f = av_fopen_utf8(logfilename, "wb");
+ if (!f) {
+ av_log(NULL, AV_LOG_FATAL,
+ "Cannot write log file '%s' for pass-1 encoding: %s\n",
+ logfilename, strerror(errno));
+ exit_program(1);
+ }
+ ost->logfile = f;
+ }
+ }
+ }
+
MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st);
if (ost->forced_keyframes)
ost->forced_keyframes = av_strdup(ost->forced_keyframes);