[FFmpeg-cvslog] fftools/ffmpeg: add an AVClass to MuxStream/OutputStream

Anton Khirnov git at videolan.org
Sun Jan 29 10:39:56 EET 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Jan 28 10:06:20 2023 +0100| [9b5036fabd41c93cbd623a12893511761827ae98] | committer: Anton Khirnov

fftools/ffmpeg: add an AVClass to MuxStream/OutputStream

Use it for logging. This makes log messages related to this output
stream more consistent.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b5036fabd41c93cbd623a12893511761827ae98
---

 fftools/ffmpeg.c          |  95 ++++++++++++++---------------
 fftools/ffmpeg.h          |   5 +-
 fftools/ffmpeg_demux.c    |  10 ++--
 fftools/ffmpeg_mux.c      |  13 ++--
 fftools/ffmpeg_mux.h      |   3 +
 fftools/ffmpeg_mux_init.c | 149 +++++++++++++++++++++++++++-------------------
 fftools/ffmpeg_opt.c      |   9 +--
 7 files changed, 157 insertions(+), 127 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e4188c5fc8..9884e0c6c6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -730,8 +730,8 @@ static int init_output_stream_wrapper(OutputStream *ost, AVFrame *frame,
 
     ret = init_output_stream(ost, frame, error, sizeof(error));
     if (ret < 0) {
-        av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
-               ost->file_index, ost->index, error);
+        av_log(ost, AV_LOG_ERROR, "Error initializing output stream: %s\n",
+               error);
 
         if (fatal)
             exit_program(1);
@@ -866,7 +866,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
         ost->samples_encoded += frame->nb_samples;
 
         if (debug_ts) {
-            av_log(NULL, AV_LOG_INFO, "encoder <- type:%s "
+            av_log(ost, AV_LOG_INFO, "encoder <- type:%s "
                    "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
                    type_desc,
                    av_ts2str(frame->pts), av_ts2timestr(frame->pts, &enc->time_base),
@@ -878,7 +878,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
 
     ret = avcodec_send_frame(enc, frame);
     if (ret < 0 && !(ret == AVERROR_EOF && !frame)) {
-        av_log(NULL, AV_LOG_ERROR, "Error submitting %s frame to the encoder\n",
+        av_log(ost, AV_LOG_ERROR, "Error submitting %s frame to the encoder\n",
                type_desc);
         return ret;
     }
@@ -899,7 +899,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
             of_output_packet(of, pkt, ost, 1);
             return ret;
         } else if (ret < 0) {
-            av_log(NULL, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
+            av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
             return ret;
         }
 
@@ -909,7 +909,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
             enc_stats_write(ost, &ost->enc_stats_post, NULL, pkt);
 
         if (debug_ts) {
-            av_log(NULL, AV_LOG_INFO, "encoder -> type:%s "
+            av_log(ost, AV_LOG_INFO, "encoder -> type:%s "
                    "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
                    "duration:%s duration_time:%s\n",
                    type_desc,
@@ -921,7 +921,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
         av_packet_rescale_ts(pkt, enc->time_base, ost->mux_timebase);
 
         if (debug_ts) {
-            av_log(NULL, AV_LOG_INFO, "encoder -> type:%s "
+            av_log(ost, AV_LOG_INFO, "encoder -> type:%s "
                    "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
                    "duration:%s duration_time:%s\n",
                    type_desc,
@@ -1023,7 +1023,7 @@ static void do_subtitle_out(OutputFile *of,
     int64_t pts;
 
     if (sub->pts == AV_NOPTS_VALUE) {
-        av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
+        av_log(ost, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
         if (exit_on_error)
             exit_program(1);
         return;
@@ -1067,7 +1067,7 @@ static void do_subtitle_out(OutputFile *of,
         if (i == 1)
             sub->num_rects = save_num_rects;
         if (subtitle_out_size < 0) {
-            av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
+            av_log(ost, AV_LOG_FATAL, "Subtitle encoding failed\n");
             exit_program(1);
         }
 
@@ -1114,9 +1114,9 @@ static void video_sync_process(OutputFile *of, OutputStream *ost,
         ost->vsync_method != VSYNC_PASSTHROUGH &&
         ost->vsync_method != VSYNC_DROP) {
         if (delta0 < -0.6) {
-            av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
+            av_log(ost, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
         } else
-            av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0);
+            av_log(ost, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0);
         sync_ipts = ost->next_pts;
         duration += delta0;
         delta0 = 0;
@@ -1125,7 +1125,7 @@ static void video_sync_process(OutputFile *of, OutputStream *ost,
     switch (ost->vsync_method) {
     case VSYNC_VSCFR:
         if (ost->vsync_frame_number == 0 && delta0 >= 0.5) {
-            av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
+            av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
             delta = duration;
             delta0 = 0;
             ost->next_pts = llrint(sync_ipts);
@@ -1160,8 +1160,9 @@ static void video_sync_process(OutputFile *of, OutputStream *ost,
     }
 }
 
-static enum AVPictureType forced_kf_apply(KeyframeForceCtx *kf, AVRational tb,
-                                          const AVFrame *in_picture, int dup_idx)
+static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
+                                          AVRational tb, const AVFrame *in_picture,
+                                          int dup_idx)
 {
     double pts_time;
 
@@ -1206,7 +1207,7 @@ static enum AVPictureType forced_kf_apply(KeyframeForceCtx *kf, AVRational tb,
     return AV_PICTURE_TYPE_NONE;
 
 force_keyframe:
-    av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
+    av_log(logctx, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
     return AV_PICTURE_TYPE_I;
 }
 
@@ -1258,20 +1259,20 @@ static void do_video_out(OutputFile *of,
 
     if (nb_frames_prev == 0 && ost->last_dropped) {
         nb_frames_drop++;
-        av_log(NULL, AV_LOG_VERBOSE,
-               "*** dropping frame %"PRId64" from stream %d at ts %"PRId64"\n",
-               ost->vsync_frame_number, ost->st->index, ost->last_frame->pts);
+        av_log(ost, AV_LOG_VERBOSE,
+               "*** dropping frame %"PRId64" at ts %"PRId64"\n",
+               ost->vsync_frame_number, ost->last_frame->pts);
     }
     if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) {
         if (nb_frames > dts_error_threshold * 30) {
-            av_log(NULL, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1);
+            av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1);
             nb_frames_drop++;
             return;
         }
         nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev);
-        av_log(NULL, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1);
+        av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1);
         if (nb_frames_dup > dup_warning) {
-            av_log(NULL, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning);
+            av_log(ost, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning);
             dup_warning *= 10;
         }
     }
@@ -1296,7 +1297,7 @@ static void do_video_out(OutputFile *of,
             return;
 
         in_picture->quality = enc->global_quality;
-        in_picture->pict_type = forced_kf_apply(&ost->kf, enc->time_base, in_picture, i);
+        in_picture->pict_type = forced_kf_apply(ost, &ost->kf, enc->time_base, in_picture, i);
 
         ret = submit_encode_frame(of, ost, in_picture);
         if (ret == AVERROR_EOF)
@@ -1764,9 +1765,8 @@ static void flush_encoders(void)
         if (!ost->initialized) {
             FilterGraph *fg = ost->filter->graph;
 
-            av_log(NULL, AV_LOG_WARNING,
-                   "Finishing stream %d:%d without any data written to it.\n",
-                   ost->file_index, ost->st->index);
+            av_log(ost, AV_LOG_WARNING,
+                   "Finishing stream without any data written to it.\n");
 
             if (ost->filter && !fg->graph) {
                 int x;
@@ -1774,7 +1774,7 @@ static void flush_encoders(void)
                     InputFilter *ifilter = fg->inputs[x];
                     if (ifilter->format < 0 &&
                         ifilter_parameters_from_codecpar(ifilter, ifilter->ist->par) < 0) {
-                        av_log(NULL, AV_LOG_ERROR, "Error copying paramerets from input stream\n");
+                        av_log(ost, AV_LOG_ERROR, "Error copying paramerets from input stream\n");
                         exit_program(1);
                     }
                 }
@@ -1784,7 +1784,7 @@ static void flush_encoders(void)
 
                 ret = configure_filtergraph(fg);
                 if (ret < 0) {
-                    av_log(NULL, AV_LOG_ERROR, "Error configuring filter graph\n");
+                    av_log(ost, AV_LOG_ERROR, "Error configuring filter graph\n");
                     exit_program(1);
                 }
 
@@ -2671,7 +2671,7 @@ static int init_output_stream_streamcopy(OutputStream *ost)
     if (ret >= 0)
         ret = av_opt_set_dict(codec_ctx, &ost->encoder_opts);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL,
+        av_log(ost, AV_LOG_FATAL,
                "Error setting up codec context options.\n");
         avcodec_free_context(&codec_ctx);
         return ret;
@@ -2680,7 +2680,7 @@ static int init_output_stream_streamcopy(OutputStream *ost)
     ret = avcodec_parameters_from_context(par, codec_ctx);
     avcodec_free_context(&codec_ctx);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL,
+        av_log(ost, AV_LOG_FATAL,
                "Error getting reference codec parameters.\n");
         return ret;
     }
@@ -2762,7 +2762,7 @@ static int init_output_stream_streamcopy(OutputStream *ost)
             sar =
                 av_mul_q(ost->frame_aspect_ratio,
                          (AVRational){ par->height, par->width });
-            av_log(NULL, AV_LOG_WARNING, "Overriding aspect ratio "
+            av_log(ost, AV_LOG_WARNING, "Overriding aspect ratio "
                    "with stream copy may produce invalid files\n");
             }
         else if (ist->st->sample_aspect_ratio.num)
@@ -2819,9 +2819,8 @@ static void init_encoder_time_base(OutputStream *ost, AVRational default_time_ba
             return;
         }
 
-        av_log(NULL, AV_LOG_WARNING,
-               "Input stream data for output stream #%d:%d not available, "
-               "using default time base\n", ost->file_index, ost->index);
+        av_log(ost, AV_LOG_WARNING,
+               "Input stream data not available, using default time base\n");
     }
 
     enc_ctx->time_base = default_time_base;
@@ -2846,12 +2845,11 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
             ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter);
         if (!ost->frame_rate.num && !ost->max_frame_rate.num) {
             ost->frame_rate = (AVRational){25, 1};
-            av_log(NULL, AV_LOG_WARNING,
+            av_log(ost, AV_LOG_WARNING,
                    "No information "
                    "about the input framerate is available. Falling "
-                   "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
-                   "if you want a different framerate.\n",
-                   ost->file_index, ost->index);
+                   "back to a default value of 25fps. Use the -r option "
+                   "if you want a different framerate.\n");
         }
 
         if (ost->max_frame_rate.num &&
@@ -2895,9 +2893,9 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
         if (   av_q2d(enc_ctx->time_base) < 0.001 && ost->vsync_method != VSYNC_PASSTHROUGH
            && (ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR ||
                (ost->vsync_method == VSYNC_AUTO && !(of->format->flags & AVFMT_VARIABLE_FPS)))){
-            av_log(NULL, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n"
-                                       "Please consider specifying a lower framerate, a different muxer or "
-                                       "setting vsync/fps_mode to vfr\n");
+            av_log(ost, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n"
+                                        "Please consider specifying a lower framerate, a different muxer or "
+                                        "setting vsync/fps_mode to vfr\n");
         }
 
         enc_ctx->width  = av_buffersink_get_w(ost->filter->filter);
@@ -2977,7 +2975,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
             if (output_descriptor)
                 output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
             if (input_props && output_props && input_props != output_props) {
-                av_log(NULL, AV_LOG_ERROR,
+                av_log(ost, AV_LOG_ERROR,
                        "Subtitle encoding currently only possible from text to text "
                        "or bitmap to bitmap");
                 return AVERROR_INVALIDDATA;
@@ -3043,12 +3041,12 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
         assert_avoptions(ost->encoder_opts);
         if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000 &&
             ost->enc_ctx->codec_id != AV_CODEC_ID_CODEC2 /* don't complain about 700 bit/s modes */)
-            av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
-                                         " It takes bits/s as argument, not kbits/s\n");
+            av_log(ost, AV_LOG_WARNING, "The bitrate parameter is set too low."
+                                        " It takes bits/s as argument, not kbits/s\n");
 
         ret = avcodec_parameters_from_context(ost->st->codecpar, ost->enc_ctx);
         if (ret < 0) {
-            av_log(NULL, AV_LOG_FATAL,
+            av_log(ost, AV_LOG_FATAL,
                    "Error initializing the output stream codec context.\n");
             exit_program(1);
         }
@@ -3280,9 +3278,9 @@ static OutputStream *choose_output(void)
             opts = ost->last_mux_dts == AV_NOPTS_VALUE ?
                    INT64_MIN : ost->last_mux_dts;
             if (ost->last_mux_dts == AV_NOPTS_VALUE)
-                av_log(NULL, AV_LOG_DEBUG,
-                    "cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n",
-                    ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished);
+                av_log(ost, AV_LOG_DEBUG,
+                    "cur_dts is invalid [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n",
+                    ost->initialized, ost->inputs_done, ost->finished);
         }
 
         if (!ost->initialized && !ost->inputs_done)
@@ -3869,8 +3867,7 @@ static int transcode(void)
         packets_written = atomic_load(&ost->packets_written);
         total_packets_written += packets_written;
         if (!packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) {
-            av_log(NULL, AV_LOG_FATAL, "Empty output on stream %d:%d.\n",
-                   ost->file_index, ost->index);
+            av_log(ost, AV_LOG_FATAL, "Empty output\n");
             exit_program(1);
         }
     }
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1a235f205f..dddab456f7 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -548,6 +548,8 @@ typedef struct KeyframeForceCtx {
 } KeyframeForceCtx;
 
 typedef struct OutputStream {
+    const AVClass *class;
+
     int file_index;          /* file index */
     int index;               /* stream index in the output file */
 
@@ -757,7 +759,8 @@ void assert_avoptions(AVDictionary *m);
 void assert_file_overwrite(const char *filename);
 char *file_read(const char *filename);
 AVDictionary *strip_specifiers(const AVDictionary *dict);
-const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder);
+const AVCodec *find_codec_or_die(void *logctx, const char *name,
+                                 enum AVMediaType type, int encoder);
 int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
 
 int configure_filtergraph(FilterGraph *fg);
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 4b5c62b0d5..ffece60720 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -503,7 +503,7 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
 
     MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
     if (codec_name) {
-        const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
+        const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0);
         st->codecpar->codec_id = codec->id;
         if (recast_media && st->codecpar->codec_type != codec->type)
             st->codecpar->codec_type = codec->type;
@@ -937,13 +937,13 @@ int ifile_open(const OptionsContext *o, const char *filename)
     MATCH_PER_TYPE_OPT(codec_names, str,     data_codec_name, ic, "d");
 
     if (video_codec_name)
-        ic->video_codec    = find_codec_or_die(video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0);
+        ic->video_codec    = find_codec_or_die(NULL, video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0);
     if (audio_codec_name)
-        ic->audio_codec    = find_codec_or_die(audio_codec_name   , AVMEDIA_TYPE_AUDIO   , 0);
+        ic->audio_codec    = find_codec_or_die(NULL, audio_codec_name   , AVMEDIA_TYPE_AUDIO   , 0);
     if (subtitle_codec_name)
-        ic->subtitle_codec = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0);
+        ic->subtitle_codec = find_codec_or_die(NULL, subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0);
     if (data_codec_name)
-        ic->data_codec     = find_codec_or_die(data_codec_name    , AVMEDIA_TYPE_DATA    , 0);
+        ic->data_codec     = find_codec_or_die(NULL, data_codec_name    , AVMEDIA_TYPE_DATA    , 0);
 
     ic->video_codec_id     = video_codec_name    ? ic->video_codec->id    : AV_CODEC_ID_NONE;
     ic->audio_codec_id     = audio_codec_name    ? ic->audio_codec->id    : AV_CODEC_ID_NONE;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 91be316e0a..5d427b44ea 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -79,7 +79,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
     if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         if (ost->frame_rate.num && ost->is_cfr) {
             if (pkt->duration > 0)
-                av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n");
+                av_log(ost, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n");
             pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate),
                                          ost->mux_timebase);
         }
@@ -132,7 +132,7 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
     pkt->stream_index = ost->index;
 
     if (debug_ts) {
-        av_log(NULL, AV_LOG_INFO, "muxer <- type:%s "
+        av_log(ost, AV_LOG_INFO, "muxer <- type:%s "
                 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s size:%d\n",
                 av_get_media_type_string(st->codecpar->codec_type),
                 av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base),
@@ -271,7 +271,7 @@ static int queue_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
         size_t new_size = FFMIN(2 * cur_size, limit);
 
         if (new_size <= cur_size) {
-            av_log(NULL, AV_LOG_ERROR,
+            av_log(ost, AV_LOG_ERROR,
                    "Too many packets buffered for output stream %d:%d.\n",
                    ost->file_index, ost->st->index);
             return AVERROR(ENOSPC);
@@ -364,8 +364,7 @@ mux_fail:
     err_msg = "submitting a packet to the muxer";
 
 fail:
-    av_log(NULL, AV_LOG_ERROR, "Error %s for output stream #%d:%d.\n",
-           err_msg, ost->file_index, ost->index);
+    av_log(ost, AV_LOG_ERROR, "Error %s\n", err_msg);
     if (exit_on_error)
         exit_program(1);
 
@@ -559,7 +558,7 @@ static int bsf_init(MuxStream *ms)
 
     ret = av_bsf_init(ctx);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
+        av_log(ms, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
                ctx->filter->name);
         return ret;
     }
@@ -640,7 +639,7 @@ static void ost_free(OutputStream **post)
 
     if (ost->logfile) {
         if (fclose(ost->logfile))
-            av_log(NULL, AV_LOG_ERROR,
+            av_log(ms, AV_LOG_ERROR,
                    "Error closing logfile, loss of information possible: %s\n",
                    av_err2str(AVERROR(errno)));
         ost->logfile = NULL;
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index 8a90cc56c6..1487d86ae1 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -37,6 +37,9 @@
 typedef struct MuxStream {
     OutputStream ost;
 
+    // name used for logging
+    char log_name[32];
+
     /* the packets are buffered here until the muxer is ready to be initialized */
     AVFifo *muxing_queue;
 
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index d074318199..35b115f8a6 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -116,15 +116,14 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s,
                                                          NULL, ost->st->codecpar->codec_type);
             *enc = avcodec_find_encoder(ost->st->codecpar->codec_id);
             if (!*enc) {
-                av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for "
-                       "output stream #%d:%d. Default encoder for format %s (codec %s) is "
+                av_log(ost, AV_LOG_FATAL, "Automatic encoder selection failed "
+                       "Default encoder for format %s (codec %s) is "
                        "probably disabled. Please choose an encoder manually.\n",
-                       ost->file_index, ost->index, s->oformat->name,
-                       avcodec_get_name(ost->st->codecpar->codec_id));
+                        s->oformat->name, avcodec_get_name(ost->st->codecpar->codec_id));
                 return AVERROR_ENCODER_NOT_FOUND;
             }
         } else if (strcmp(codec_name, "copy")) {
-            *enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1);
+            *enc = find_codec_or_die(ost, codec_name, ost->st->codecpar->codec_type, 1);
             ost->st->codecpar->codec_id = (*enc)->id;
         }
     }
@@ -369,6 +368,37 @@ fail:
     return 0;
 }
 
+static const char *output_stream_item_name(void *obj)
+{
+    const MuxStream *ms = obj;
+
+    return ms->log_name;
+}
+
+static const AVClass output_stream_class = {
+    .class_name = "OutputStream",
+    .version    = LIBAVUTIL_VERSION_INT,
+    .item_name  = output_stream_item_name,
+    .category   = AV_CLASS_CATEGORY_MUXER,
+};
+
+static MuxStream *mux_stream_alloc(Muxer *mux, enum AVMediaType type)
+{
+    const char *type_str = av_get_media_type_string(type);
+    MuxStream *ms = allocate_array_elem(&mux->of.streams, sizeof(*ms),
+                                        &mux->of.nb_streams);
+
+    ms->ost.file_index = mux->of.index;
+    ms->ost.index      = mux->of.nb_streams - 1;
+
+    ms->ost.class = &output_stream_class;
+
+    snprintf(ms->log_name, sizeof(ms->log_name), "%cost#%d:%d",
+             type_str ? *type_str : '?', mux->of.index, ms->ost.index);
+
+    return ms;
+}
+
 static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
                                        enum AVMediaType type, InputStream *ist)
 {
@@ -377,7 +407,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
     OutputStream *ost;
     const AVCodec *enc;
     AVStream *st = avformat_new_stream(oc, NULL);
-    int idx      = oc->nb_streams - 1, ret = 0;
+    int ret = 0;
     const char *bsfs = NULL, *time_base = NULL;
     char *next, *codec_tag = NULL;
     double qscale = -1;
@@ -389,8 +419,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
     if (oc->nb_streams - 1 < o->nb_streamid_map)
         st->id = o->streamid_map[oc->nb_streams - 1];
 
-    ms  = allocate_array_elem(&mux->of.streams, sizeof(MuxStream),
-                              &mux->of.nb_streams);
+    ms  = mux_stream_alloc(mux, type);
     ost = &ms->ost;
 
     ms->muxing_queue = av_fifo_alloc2(8, sizeof(AVPacket*), 0);
@@ -398,16 +427,13 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
         report_and_exit(AVERROR(ENOMEM));
     ms->last_mux_dts = AV_NOPTS_VALUE;
 
-    ost->file_index = nb_output_files - 1;
-    ost->index      = idx;
     ost->st         = st;
     ost->kf.ref_pts = AV_NOPTS_VALUE;
     st->codecpar->codec_type = type;
 
     ret = choose_encoder(o, oc, ost, &enc);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream "
-               "%d:%d\n", ost->file_index, ost->index);
+        av_log(ost, AV_LOG_FATAL, "Error selecting an encoder\n");
         exit_program(1);
     }
 
@@ -415,6 +441,11 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
         ost->enc_ctx = avcodec_alloc_context3(enc);
         if (!ost->enc_ctx)
             report_and_exit(AVERROR(ENOMEM));
+
+        av_strlcat(ms->log_name, "/",       sizeof(ms->log_name));
+        av_strlcat(ms->log_name, enc->name, sizeof(ms->log_name));
+    } else {
+        av_strlcat(ms->log_name, "/copy", sizeof(ms->log_name));
     }
 
     ost->filtered_frame = av_frame_alloc();
@@ -446,7 +477,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
                 if (!buf[0] || buf[0] == '#')
                     continue;
                 if (!(arg = strchr(buf, '='))) {
-                    av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
+                    av_log(ost, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
                     exit_program(1);
                 }
                 *arg++ = 0;
@@ -456,9 +487,8 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
             avio_closep(&s);
         }
         if (ret) {
-            av_log(NULL, AV_LOG_FATAL,
-                   "Preset %s specified for stream %d:%d, but could not be opened.\n",
-                   preset, ost->file_index, ost->index);
+            av_log(ost, AV_LOG_FATAL,
+                   "Preset %s specified, but could not be opened.\n", preset);
             exit_program(1);
         }
 
@@ -502,7 +532,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
         AVRational q;
         if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 ||
             q.num <= 0 || q.den <= 0) {
-            av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base);
+            av_log(ost, AV_LOG_FATAL, "Invalid time base: %s\n", time_base);
             exit_program(1);
         }
         st->time_base = q;
@@ -513,7 +543,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
         AVRational q;
         if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 ||
             q.den <= 0) {
-            av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base);
+            av_log(ost, AV_LOG_FATAL, "Invalid time base: %s\n", time_base);
             exit_program(1);
         }
         ost->enc_timebase = q;
@@ -524,7 +554,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
     for (i = 0; i<o->nb_max_frames; i++) {
         char *p = o->max_frames[i].specifier;
         if (!*p && type != AVMEDIA_TYPE_VIDEO) {
-            av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
+            av_log(ost, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
             break;
         }
     }
@@ -536,7 +566,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o,
     if (bsfs && *bsfs) {
         ret = av_bsf_list_parse_str(bsfs, &ms->bsf_ctx);
         if (ret < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Error parsing bitstream filter sequence '%s': %s\n", bsfs, av_err2str(ret));
+            av_log(ost, AV_LOG_ERROR, "Error parsing bitstream filter sequence '%s': %s\n", bsfs, av_err2str(ret));
             exit_program(1);
         }
     }
@@ -595,8 +625,7 @@ static char *get_ost_filters(const OptionsContext *o, AVFormatContext *oc,
     AVStream *st = ost->st;
 
     if (ost->filters_script && ost->filters) {
-        av_log(NULL, AV_LOG_ERROR, "Both -filter and -filter_script set for "
-               "output stream #%d:%d.\n", nb_output_files, st->index);
+        av_log(ost, AV_LOG_ERROR, "Both -filter and -filter_script set\n");
         exit_program(1);
     }
 
@@ -610,20 +639,19 @@ static char *get_ost_filters(const OptionsContext *o, AVFormatContext *oc,
 }
 
 static void check_streamcopy_filters(const OptionsContext *o, AVFormatContext *oc,
-                                     const OutputStream *ost, enum AVMediaType type)
+                                     OutputStream *ost, enum AVMediaType type)
 {
     if (ost->filters_script || ost->filters) {
-        av_log(NULL, AV_LOG_ERROR,
-               "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
+        av_log(ost, AV_LOG_ERROR,
+               "%s '%s' was defined, but codec copy was selected.\n"
                "Filtering and streamcopy cannot be used together.\n",
                ost->filters ? "Filtergraph" : "Filtergraph script",
-               ost->filters ? ost->filters : ost->filters_script,
-               av_get_media_type_string(type), ost->file_index, ost->index);
+               ost->filters ? ost->filters : ost->filters_script);
         exit_program(1);
     }
 }
 
-static void parse_matrix_coeffs(uint16_t *dest, const char *str)
+static void parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str)
 {
     int i;
     const char *p = str;
@@ -633,7 +661,8 @@ static void parse_matrix_coeffs(uint16_t *dest, const char *str)
             break;
         p = strchr(p, ',');
         if (!p) {
-            av_log(NULL, AV_LOG_FATAL, "Syntax error in matrix \"%s\" at coeff %d\n", str, i);
+            av_log(logctx, AV_LOG_FATAL,
+                   "Syntax error in matrix \"%s\" at coeff %d\n", str, i);
             exit_program(1);
         }
         p++;
@@ -652,18 +681,18 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
 
     MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st);
     if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
+        av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate);
         exit_program(1);
     }
 
     MATCH_PER_STREAM_OPT(max_frame_rates, str, max_frame_rate, oc, st);
     if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
+        av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate);
         exit_program(1);
     }
 
     if (frame_rate && max_frame_rate) {
-        av_log(NULL, AV_LOG_ERROR, "Only one of -fpsmax and -r can be set for a stream.\n");
+        av_log(ost, AV_LOG_ERROR, "Only one of -fpsmax and -r can be set for a stream.\n");
         exit_program(1);
     }
 
@@ -672,7 +701,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
         AVRational q;
         if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 ||
             q.num <= 0 || q.den <= 0) {
-            av_log(NULL, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio);
+            av_log(ost, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio);
             exit_program(1);
         }
         ost->frame_aspect_ratio = q;
@@ -693,7 +722,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
 
         MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st);
         if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, frame_size) < 0) {
-            av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size);
+            av_log(ost, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size);
             exit_program(1);
         }
 
@@ -704,7 +733,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
                 frame_pix_fmt = NULL;
         }
         if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == AV_PIX_FMT_NONE) {
-            av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
+            av_log(ost, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
             exit_program(1);
         }
         st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
@@ -713,7 +742,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
         if (intra_matrix) {
             if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64)))
                 report_and_exit(AVERROR(ENOMEM));
-            parse_matrix_coeffs(video_enc->intra_matrix, intra_matrix);
+            parse_matrix_coeffs(ost, video_enc->intra_matrix, intra_matrix);
         }
         MATCH_PER_STREAM_OPT(chroma_intra_matrices, str, chroma_intra_matrix, oc, st);
         if (chroma_intra_matrix) {
@@ -721,13 +750,13 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
             if (!p)
                 report_and_exit(AVERROR(ENOMEM));
             video_enc->chroma_intra_matrix = p;
-            parse_matrix_coeffs(p, chroma_intra_matrix);
+            parse_matrix_coeffs(ost, p, chroma_intra_matrix);
         }
         MATCH_PER_STREAM_OPT(inter_matrices, str, inter_matrix, oc, st);
         if (inter_matrix) {
             if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64)))
                 report_and_exit(AVERROR(ENOMEM));
-            parse_matrix_coeffs(video_enc->inter_matrix, inter_matrix);
+            parse_matrix_coeffs(ost, video_enc->inter_matrix, inter_matrix);
         }
 
         MATCH_PER_STREAM_OPT(rc_overrides, str, p, oc, st);
@@ -735,14 +764,14 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
             int start, end, q;
             int e = sscanf(p, "%d,%d,%d", &start, &end, &q);
             if (e != 3) {
-                av_log(NULL, AV_LOG_FATAL, "error parsing rc_override\n");
+                av_log(ost, AV_LOG_FATAL, "error parsing rc_override\n");
                 exit_program(1);
             }
             video_enc->rc_override =
                 av_realloc_array(video_enc->rc_override,
                                  i + 1, sizeof(RcOverride));
             if (!video_enc->rc_override) {
-                av_log(NULL, AV_LOG_FATAL, "Could not (re)allocate memory for rc_override.\n");
+                av_log(ost, AV_LOG_FATAL, "Could not (re)allocate memory for rc_override.\n");
                 exit_program(1);
             }
             video_enc->rc_override[i].start_frame = start;
@@ -762,7 +791,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
 
 #if FFMPEG_OPT_PSNR
         if (do_psnr) {
-            av_log(NULL, AV_LOG_WARNING, "The -psnr option is deprecated, use -flags +psnr\n");
+            av_log(ost, AV_LOG_WARNING, "The -psnr option is deprecated, use -flags +psnr\n");
             video_enc->flags|= AV_CODEC_FLAG_PSNR;
         }
 #endif
@@ -805,7 +834,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
                     char  *logbuffer = file_read(logfilename);
 
                     if (!logbuffer) {
-                        av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
+                        av_log(ost, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
                                logfilename);
                         exit_program(1);
                     }
@@ -814,7 +843,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
                 if (video_enc->flags & AV_CODEC_FLAG_PASS1) {
                     f = fopen_utf8(logfilename, "wb");
                     if (!f) {
-                        av_log(NULL, AV_LOG_FATAL,
+                        av_log(ost, AV_LOG_FATAL,
                                "Cannot write log file '%s' for pass-1 encoding: %s\n",
                                logfilename, strerror(errno));
                         exit_program(1);
@@ -837,7 +866,7 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
         if ((ost->frame_rate.num || ost->max_frame_rate.num) &&
             !(ost->vsync_method == VSYNC_AUTO ||
               ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR)) {
-            av_log(NULL, AV_LOG_FATAL, "One of -r/-fpsmax was specified "
+            av_log(ost, AV_LOG_FATAL, "One of -r/-fpsmax was specified "
                    "together a non-CFR -vsync/-fps_mode. This is contradictory.\n");
             exit_program(1);
         }
@@ -915,11 +944,11 @@ static OutputStream *new_audio_stream(Muxer *mux, const OptionsContext *o, Input
                 })
                 if (!mask) {
 #endif
-                    av_log(NULL, AV_LOG_FATAL, "Unknown channel layout: %s\n", layout);
+                    av_log(ost, AV_LOG_FATAL, "Unknown channel layout: %s\n", layout);
                     exit_program(1);
 #if FF_API_OLD_CHANNEL_LAYOUT
                 }
-                av_log(NULL, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n",
+                av_log(ost, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n",
                        layout);
                 av_channel_layout_from_mask(&audio_enc->ch_layout, mask);
 #endif
@@ -929,7 +958,7 @@ static OutputStream *new_audio_stream(Muxer *mux, const OptionsContext *o, Input
         MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st);
         if (sample_fmt &&
             (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) {
-            av_log(NULL, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt);
+            av_log(ost, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt);
             exit_program(1);
         }
 
@@ -953,7 +982,7 @@ static OutputStream *new_audio_stream(Muxer *mux, const OptionsContext *o, Input
                 if (map->channel_idx == -1) {
                     ist = NULL;
                 } else if (!ost->ist) {
-                    av_log(NULL, AV_LOG_FATAL, "Cannot determine input stream for channel mapping %d.%d\n",
+                    av_log(ost, AV_LOG_FATAL, "Cannot determine input stream for channel mapping %d.%d\n",
                            ost->file_index, ost->st->index);
                     continue;
                 } else {
@@ -984,7 +1013,7 @@ static OutputStream *new_data_stream(Muxer *mux, const OptionsContext *o, InputS
 
     ost = new_output_stream(mux, o, AVMEDIA_TYPE_DATA, ist);
     if (ost->enc_ctx) {
-        av_log(NULL, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n");
+        av_log(ost, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n");
         exit_program(1);
     }
 
@@ -997,7 +1026,7 @@ static OutputStream *new_unknown_stream(Muxer *mux, const OptionsContext *o, Inp
 
     ost = new_output_stream(mux, o, AVMEDIA_TYPE_UNKNOWN, ist);
     if (ost->enc_ctx) {
-        av_log(NULL, AV_LOG_FATAL, "Unknown stream encoding not supported yet (only streamcopy)\n");
+        av_log(ost, AV_LOG_FATAL, "Unknown stream encoding not supported yet (only streamcopy)\n");
         exit_program(1);
     }
 
@@ -1025,7 +1054,7 @@ static OutputStream *new_subtitle_stream(Muxer *mux, const OptionsContext *o, In
 
         MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, mux->fc, st);
         if (frame_size && av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size) < 0) {
-            av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size);
+            av_log(ost, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size);
             exit_program(1);
         }
     }
@@ -1053,15 +1082,15 @@ static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o,
     ofilter->format   = -1;
 
     if (!ost->enc_ctx) {
-        av_log(NULL, AV_LOG_ERROR, "Streamcopy requested for output stream %d:%d, "
-               "which is fed from a complex filtergraph. Filtering and streamcopy "
-               "cannot be used together.\n", ost->file_index, ost->index);
+        av_log(ost, AV_LOG_ERROR, "Streamcopy requested for output stream fed "
+               "from a complex filtergraph. Filtering and streamcopy "
+               "cannot be used together.\n");
         exit_program(1);
     }
 
     if (ost->avfilter && (ost->filters || ost->filters_script)) {
         const char *opt = ost->filters ? "-vf/-af/-filter" : "-filter_script";
-        av_log(NULL, AV_LOG_ERROR,
+        av_log(ost, AV_LOG_ERROR,
                "%s '%s' was specified through the %s option "
                "for output stream %d:%d, which is fed from a complex filtergraph.\n"
                "%s and -filter_complex cannot be used together for the same stream.\n",
@@ -1617,7 +1646,7 @@ static void of_add_metadata(OutputFile *of, AVFormatContext *oc,
                             ost->rotate_override_value = theta;
                         }
 
-                        av_log(NULL, AV_LOG_WARNING,
+                        av_log(ost, AV_LOG_WARNING,
                                "Conversion of a 'rotate' metadata key to a "
                                "proper display matrix rotation is deprecated. "
                                "See -display_rotation for setting rotation "
@@ -2059,7 +2088,7 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
             int ret = av_expr_parse(&ost->kf.pexpr, forced_keyframes + 5,
                                     forced_keyframes_const_names, NULL, NULL, NULL, NULL, 0, NULL);
             if (ret < 0) {
-                av_log(NULL, AV_LOG_ERROR,
+                av_log(ost, AV_LOG_ERROR,
                        "Invalid force_key_frames expression '%s'\n", forced_keyframes + 5);
                 return ret;
             }
@@ -2237,10 +2266,8 @@ int of_open(const OptionsContext *o, const char *filename)
                 ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
                 err = init_simple_filtergraph(ist, ost);
                 if (err < 0) {
-                    av_log(NULL, AV_LOG_ERROR,
-                           "Error initializing a simple filtergraph between streams "
-                           "%d:%d->%d:%d\n", ist->file_index, ist->st->index,
-                           nb_output_files - 1, ost->st->index);
+                    av_log(ost, AV_LOG_ERROR,
+                           "Error initializing a simple filtergraph\n");
                     exit_program(1);
                 }
             }
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index c81c991d5e..c0ae55a359 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -623,7 +623,8 @@ static int opt_recording_timestamp(void *optctx, const char *opt, const char *ar
     return 0;
 }
 
-const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
+const AVCodec *find_codec_or_die(void *logctx, const char *name,
+                                 enum AVMediaType type, int encoder)
 {
     const AVCodecDescriptor *desc;
     const char *codec_string = encoder ? "encoder" : "decoder";
@@ -637,16 +638,16 @@ const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int en
         codec = encoder ? avcodec_find_encoder(desc->id) :
                           avcodec_find_decoder(desc->id);
         if (codec)
-            av_log(NULL, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
+            av_log(logctx, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
                    codec_string, codec->name, desc->name);
     }
 
     if (!codec) {
-        av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
+        av_log(logctx, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
         exit_program(1);
     }
     if (codec->type != type && !recast_media) {
-        av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
+        av_log(logctx, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
         exit_program(1);
     }
     return codec;




More information about the ffmpeg-cvslog mailing list