History

avconv: move handling the 2pass logfile into avconv_opt

It more logically belongs there.

Anton Khirnov committed 11 years ago

Commit 6d5d9241 parent 59245e02 files · +34 −34Browse files

Unified · Split

2 files
  1. avconv.c +0 −34
  2. avconv_opt.c +34 −0
avconv.c+0−34
@@ -93,8 +93,6 @@ static int nb_frames_drop = 0; · 92 unmodified lines
9393 static int transcoding_finished;
9494 #endif
9595
96−#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
97−
9896 InputStream **input_streams = NULL;
9997 int nb_input_streams = 0;
10098 InputFile **input_files = NULL;
@@ -1860,38 +1858,6 @@ static int transcode_init(void) · 1759 unmodified lines
18601858 abort();
18611859 break;
18621860 }
1863− /* two pass mode */
1864− if ((enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
1865− char logfilename[1024];
1866− FILE *f;
1867−
1868− snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
1869− ost->logfile_prefix ? ost->logfile_prefix :
1870− DEFAULT_PASS_LOGFILENAME_PREFIX,
1871− i);
1872− if (!strcmp(ost->enc->name, "libx264")) {
1873− av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
1874− } else {
1875− if (enc_ctx->flags & CODEC_FLAG_PASS1) {
1876− f = fopen(logfilename, "wb");
1877− if (!f) {
1878− av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
1879− logfilename, strerror(errno));
1880− exit_program(1);
1881− }
1882− ost->logfile = f;
1883− } else {
1884− char *logbuffer;
1885− size_t logbuffer_size;
1886− if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
1887− av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
1888− logfilename);
1889− exit_program(1);
1890− }
1891− enc_ctx->stats_in = logbuffer;
1892− }
1893− }
1894− }
18951861 }
18961862 }
18971863
avconv_opt.c+34−0
@@ -41,6 +41,8 @@ · 40 unmodified lines
4141 #include "libavutil/pixdesc.h"
4242 #include "libavutil/pixfmt.h"
4343
44+#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
45+
4446 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
4547 {\
4648 int i, ret;\
@@ -1174,6 +1176,38 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc) · 1127 unmodified lines
11741176 !(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
11751177 exit_program(1);
11761178
1179+ if (do_pass) {
1180+ char logfilename[1024];
1181+ FILE *f;
1182+
1183+ snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
1184+ ost->logfile_prefix ? ost->logfile_prefix :
1185+ DEFAULT_PASS_LOGFILENAME_PREFIX,
1186+ i);
1187+ if (!strcmp(ost->enc->name, "libx264")) {
1188+ av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
1189+ } else {
1190+ if (video_enc->flags & CODEC_FLAG_PASS1) {
1191+ f = fopen(logfilename, "wb");
1192+ if (!f) {
1193+ av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n",
1194+ logfilename, strerror(errno));
1195+ exit_program(1);
1196+ }
1197+ ost->logfile = f;
1198+ } else {
1199+ char *logbuffer;
1200+ size_t logbuffer_size;
1201+ if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {
1202+ av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
1203+ logfilename);
1204+ exit_program(1);
1205+ }
1206+ video_enc->stats_in = logbuffer;
1207+ }
1208+ }
1209+ }
1210+
11771211 MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st);
11781212 if (ost->forced_keyframes)
11791213 ost->forced_keyframes = av_strdup(ost->forced_keyframes);

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