It more logically belongs there.
Unified · Split
| @@ -93,8 +93,6 @@ static int nb_frames_drop = 0; · 92 unmodified lines | ||
| 93 | 93 | static int transcoding_finished; |
| 94 | 94 | #endif |
| 95 | 95 | |
| 96 | −#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass" | |
| 97 | − | |
| 98 | 96 | InputStream **input_streams = NULL; |
| 99 | 97 | int nb_input_streams = 0; |
| 100 | 98 | InputFile **input_files = NULL; |
| @@ -1860,38 +1858,6 @@ static int transcode_init(void) · 1759 unmodified lines | ||
| 1860 | 1858 | abort(); |
| 1861 | 1859 | break; |
| 1862 | 1860 | } |
| 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 | − } | |
| 1895 | 1861 | } |
| 1896 | 1862 | } |
| 1897 | 1863 | |
| @@ -41,6 +41,8 @@ · 40 unmodified lines | ||
| 41 | 41 | #include "libavutil/pixdesc.h" |
| 42 | 42 | #include "libavutil/pixfmt.h" |
| 43 | 43 | |
| 44 | +#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass" | |
| 45 | + | |
| 44 | 46 | #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ |
| 45 | 47 | {\ |
| 46 | 48 | int i, ret;\ |
| @@ -1174,6 +1176,38 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc) · 1127 unmodified lines | ||
| 1174 | 1176 | !(ost->logfile_prefix = av_strdup(ost->logfile_prefix))) |
| 1175 | 1177 | exit_program(1); |
| 1176 | 1178 | |
| 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 | + | |
| 1177 | 1211 | MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st); |
| 1178 | 1212 | if (ost->forced_keyframes) |
| 1179 | 1213 | ost->forced_keyframes = av_strdup(ost->forced_keyframes); |