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