The lack of AVIOContext means that ffmpeg was attempting to open logfiles for two pass encoding with the "protocol" part of the url on the first pass. This manifested mainly when a user needed to have a colon in the filename as they would require a url style path (according to #8898). --- fftools/ffmpeg.c | 12 +++--------- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_opt.c | 7 +++---- 3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 84306818a2..d292e346a9 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -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); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8665218dcf..d907d4a6ad 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -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; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 19f719e3ff..e3e6054b06 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -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; } } } -- 2.28.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".