@@ -1313,7 +1313,7 @@ static void do_video_out(OutputFile *of,
/* if two pass, output log */
if (ost->logfile && enc->stats_out) {
- fprintf(ost->logfile, "%s", enc->stats_out);
+ avio_write(ost->logfile, enc->stats_out, strlen(enc->stats_out));
}
}
ost->sync_opts++;
@@ -1937,7 +1937,7 @@ static void flush_encoders(void)
exit_program(1);
}
if (ost->logfile && enc->stats_out) {
- fprintf(ost->logfile, "%s", enc->stats_out);
+ avio_write(ost->logfile, enc->stats_out, strlen(enc->stats_out));
}
if (ret == AVERROR_EOF) {
output_packet(of, &pkt, ost, 1);
@@ -4751,13 +4751,7 @@ static int transcode(void)
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost) {
- if (ost->logfile) {
- if (fclose(ost->logfile))
- av_log(NULL, AV_LOG_ERROR,
- "Error closing logfile, loss of information possible: %s\n",
- av_err2str(AVERROR(errno)));
- ost->logfile = NULL;
- }
+ avio_closep(&ost->logfile);
av_freep(&ost->forced_kf_pts);
av_freep(&ost->apad);
av_freep(&ost->disposition);
@@ -500,7 +500,7 @@ typedef struct OutputStream {
int audio_channels_mapped; /* number of channels in audio_channels_map */
char *logfile_prefix;
- FILE *logfile;
+ AVIOContext *logfile;
OutputFilter *filter;
char *avfilter;
@@ -1813,7 +1813,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
if (do_pass) {
char logfilename[1024];
- FILE *f;
snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
ost->logfile_prefix ? ost->logfile_prefix :
@@ -1833,14 +1832,14 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
video_enc->stats_in = logbuffer;
}
if (video_enc->flags & AV_CODEC_FLAG_PASS1) {
- f = av_fopen_utf8(logfilename, "wb");
- if (!f) {
+ int ret = avio_open(&ost->logfile, logfilename, AVIO_FLAG_WRITE);
+
+ if (ret < 0) {
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;
}
}
}