From patchwork Sat Jan 28 10:51:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40154 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp2026229pzj; Sat, 28 Jan 2023 02:53:13 -0800 (PST) X-Google-Smtp-Source: AK7set9m6JM4idCNNfTsYD8uvh6VFlO+uQgAhA6bGFg9yZSE53yJMAgtCyoj09X1GjDcr6oEk4nt X-Received: by 2002:a17:907:e90:b0:87b:daf7:cf3b with SMTP id ho16-20020a1709070e9000b0087bdaf7cf3bmr6443513ejc.47.1674903193442; Sat, 28 Jan 2023 02:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674903193; cv=none; d=google.com; s=arc-20160816; b=SJ0utvVmD1cAu5+aA/aPsna8EkwboFD3+M2vG7Tj3TJE8kKcpDmkFX+Mk8IdHMet50 QN05dHi9vqRt1d7CEV6JJzacIUr0GFHdQoh14/5najs0FvIm/DV43sFKJMhay016uBoU sCq5GjRksBGXR8uRu10mIiSJt8bf9nMfcpRGMVyePhZCTjjfK6TW1TQY7chgIsweFd84 Pu3Ehn2izlSOZfvCjrVUVnbIyZHCii1NVJhoJi5O4QPNckDMGuU+ZjToOwMymCPc7q94 X7LUnpuWJpbmuaCqMUc+iEx57E02Kepa5+EJxCA9FVrFialF7ghJ1wll/N1nhSd9SWyO oXMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=O/I6BIM6RiphuaQIIetGYxYOh9uX4+/LW3I6BoYWRXA=; b=WeWzv6i0IpeN2nBGHUR5uNgfAv842gvol/gMzR2M7zKjtTJ7GlzLpAYxYHekrtxEVd XY/hXj50hdnRwdaxRkY4BvVlJnMPBn+XAq7QMjjr95BXVFR2EqqgjEIXtEnw1vVWb2AU eeWtEoitV3Noev6067XOA3yAL58egzviY9U81yOpORmlHklagsGVFNUDeXMaEZaNcVaI zQzcJWBoO/Wx04nxKdAYfJ6QzhaDo5VUhv5xtlOy3zp96LzhCe9389+SWN3B3eVB6znM bha1aVlo6CluDmAx7GszFgR2ZxLC2xtejap+wbAo3pL37yrkxQ3RdG4kNImaP5MsX0GJ mSdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j20-20020a170906535400b00871d0c97cc3si9058017ejo.856.2023.01.28.02.53.13; Sat, 28 Jan 2023 02:53:13 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33E6D68BE16; Sat, 28 Jan 2023 12:52:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9508868BDBC for ; Sat, 28 Jan 2023 12:52:40 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 011812404F5 for ; Sat, 28 Jan 2023 11:52:39 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id YaSHDddpaVNO for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id CDDD2240178 for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8BCE73A0101 for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Jan 2023 11:51:40 +0100 Message-Id: <20230128105142.12476-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg: add an AVClass to Muxer/OutputFile X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: U/KCqwlhTL2x Use it for logging. This makes log messages related to this output file more consistent. --- fftools/ffmpeg.h | 2 + fftools/ffmpeg_mux.c | 26 +++----- fftools/ffmpeg_mux.h | 3 + fftools/ffmpeg_mux_init.c | 133 +++++++++++++++++++++++--------------- 4 files changed, 96 insertions(+), 68 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 5527dbe49b..b1876f7788 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -628,6 +628,8 @@ typedef struct OutputStream { } OutputStream; typedef struct OutputFile { + const AVClass *class; + int index; const AVOutputFormat *format; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 20524e5a28..96d6747749 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -207,8 +207,7 @@ static void *muxer_thread(void *arg) ret = tq_receive(mux->tq, &stream_idx, pkt); if (stream_idx < 0) { - av_log(NULL, AV_LOG_VERBOSE, - "All streams finished for output file #%d\n", of->index); + av_log(mux, AV_LOG_VERBOSE, "All streams finished\n"); ret = 0; break; } @@ -219,8 +218,7 @@ static void *muxer_thread(void *arg) if (ret == AVERROR_EOF) tq_receive_finish(mux->tq, stream_idx); else if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, - "Error muxing a packet for output file #%d\n", of->index); + av_log(mux, AV_LOG_ERROR, "Error muxing a packet\n"); break; } } @@ -231,7 +229,7 @@ finish: for (unsigned int i = 0; i < mux->fc->nb_streams; i++) tq_receive_finish(mux->tq, i); - av_log(NULL, AV_LOG_VERBOSE, "Terminating muxer thread %d\n", of->index); + av_log(mux, AV_LOG_VERBOSE, "Terminating muxer thread\n"); return (void*)(intptr_t)ret; } @@ -511,10 +509,8 @@ int mux_check_init(Muxer *mux) ret = avformat_write_header(fc, &mux->opts); if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, - "Could not write header for output file #%d " - "(incorrect codec parameters ?): %s\n", - of->index, av_err2str(ret)); + av_log(mux, AV_LOG_ERROR, "Could not write header (incorrect codec " + "parameters ?): %s\n", av_err2str(ret)); return ret; } //assert_avoptions(of->opts); @@ -604,10 +600,9 @@ int of_write_trailer(OutputFile *of) int ret; if (!mux->tq) { - av_log(NULL, AV_LOG_ERROR, - "Nothing was written into output file %d (%s), because " - "at least one of its streams received no packets.\n", - of->index, fc->url); + av_log(mux, AV_LOG_ERROR, + "Nothing was written into output file, because " + "at least one of its streams received no packets.\n"); return AVERROR(EINVAL); } @@ -617,7 +612,7 @@ int of_write_trailer(OutputFile *of) ret = av_write_trailer(fc); if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", fc->url, av_err2str(ret)); + av_log(mux, AV_LOG_ERROR, "Error writing trailer: %s\n", av_err2str(ret)); return ret; } @@ -626,8 +621,7 @@ int of_write_trailer(OutputFile *of) if (!(of->format->flags & AVFMT_NOFILE)) { ret = avio_closep(&fc->pb); if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error closing file %s: %s\n", - fc->url, av_err2str(ret)); + av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", av_err2str(ret)); return ret; } } diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index 6a72b9dc91..8a90cc56c6 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -63,6 +63,9 @@ typedef struct MuxStream { typedef struct Muxer { OutputFile of; + // name used for logging + char log_name[32]; + AVFormatContext *fc; pthread_t thread; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 9eea8639dc..f543438b18 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -818,7 +818,7 @@ static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o, case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(mux, o, NULL); break; case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(mux, o, NULL); break; default: - av_log(NULL, AV_LOG_FATAL, "Only video and audio filters are supported " + av_log(mux, AV_LOG_FATAL, "Only video and audio filters are supported " "currently.\n"); exit_program(1); } @@ -1023,7 +1023,7 @@ static void map_manual(Muxer *mux, const OptionsContext *o, const StreamMap *map } loop_end: if (!ofilter) { - av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist " + av_log(mux, AV_LOG_FATAL, "Output with label '%s' does not exist " "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); exit_program(1); } @@ -1031,7 +1031,7 @@ loop_end: } else { ist = input_files[map->file_index]->streams[map->stream_index]; if (ist->user_set_discard == AVDISCARD_ALL) { - av_log(NULL, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n", + av_log(mux, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n", map->file_index, map->stream_index); exit_program(1); } @@ -1056,11 +1056,11 @@ loop_end: break; } default: - av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, + av_log(mux, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, "Cannot map stream #%d:%d - unsupported type.\n", map->file_index, map->stream_index); if (!ignore_unknown_streams) { - av_log(NULL, AV_LOG_FATAL, + av_log(mux, AV_LOG_FATAL, "If you want unsupported types ignored instead " "of failing, please use the -ignore_unknown option\n" "If you want them copied, please use -copy_unknown\n"); @@ -1082,18 +1082,18 @@ static void of_add_attachments(Muxer *mux, const OptionsContext *o) int64_t len; if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) { - av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", + av_log(mux, AV_LOG_FATAL, "Could not open attachment file %s.\n", o->attachments[i]); exit_program(1); } if ((len = avio_size(pb)) <= 0) { - av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", + av_log(mux, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", o->attachments[i]); exit_program(1); } if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE || !(attachment = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE))) { - av_log(NULL, AV_LOG_FATAL, "Attachment %s too large.\n", + av_log(mux, AV_LOG_FATAL, "Attachment %s too large.\n", o->attachments[i]); exit_program(1); } @@ -1156,7 +1156,7 @@ static void create_streams(Muxer *mux, const OptionsContext *o) if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(oc, nb_output_files - 1, oc->url, 1); - av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1); + av_log(mux, AV_LOG_ERROR, "Output file does not contain any stream\n"); exit_program(1); } } @@ -1255,8 +1255,9 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u return 0; } -static void of_add_programs(AVFormatContext *oc, const OptionsContext *o) +static void of_add_programs(Muxer *mux, const OptionsContext *o) { + AVFormatContext *oc = mux->fc; /* process manually set programs */ for (int i = 0; i < o->nb_program; i++) { const char *p = o->program[i].u.str; @@ -1301,7 +1302,7 @@ static void of_add_programs(AVFormatContext *oc, const OptionsContext *o) key = av_get_token(&p2, "="); if (!key) { - av_log(NULL, AV_LOG_FATAL, + av_log(mux, AV_LOG_FATAL, "No '=' character in program string %s.\n", p2); exit_program(1); @@ -1317,7 +1318,7 @@ static void of_add_programs(AVFormatContext *oc, const OptionsContext *o) int st_num = strtol(p2, NULL, 0); av_program_add_stream_index(oc, progid, st_num); } else { - av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key); + av_log(mux, AV_LOG_FATAL, "Unknown program key %s.\n", key); exit_program(1); } av_freep(&to_dealloc); @@ -1333,7 +1334,8 @@ static void of_add_programs(AVFormatContext *oc, const OptionsContext *o) * @param index for type c/p, chapter/program index is written here * @param stream_spec for type s, the stream specifier is written here */ -static void parse_meta_type(const char *arg, char *type, int *index, const char **stream_spec) +static void parse_meta_type(void *logctx, const char *arg, + char *type, int *index, const char **stream_spec) { if (*arg) { *type = *arg; @@ -1342,7 +1344,7 @@ static void parse_meta_type(const char *arg, char *type, int *index, const char break; case 's': if (*(++arg) && *arg != ':') { - av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", arg); + av_log(logctx, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", arg); exit_program(1); } *stream_spec = *arg == ':' ? arg + 1 : ""; @@ -1353,7 +1355,7 @@ static void parse_meta_type(const char *arg, char *type, int *index, const char *index = strtol(++arg, NULL, 0); break; default: - av_log(NULL, AV_LOG_FATAL, "Invalid metadata type %c.\n", *arg); + av_log(logctx, AV_LOG_FATAL, "Invalid metadata type %c.\n", *arg); exit_program(1); } } else @@ -1371,13 +1373,13 @@ static void of_add_metadata(OutputFile *of, AVFormatContext *oc, val = strchr(o->metadata[i].u.str, '='); if (!val) { - av_log(NULL, AV_LOG_FATAL, "No '=' character in metadata string %s.\n", + av_log(of, AV_LOG_FATAL, "No '=' character in metadata string %s.\n", o->metadata[i].u.str); exit_program(1); } *val++ = 0; - parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec); + parse_meta_type(of, o->metadata[i].specifier, &type, &index, &stream_spec); if (type == 's') { for (int j = 0; j < oc->nb_streams; j++) { OutputStream *ost = of->streams[j]; @@ -1412,20 +1414,20 @@ static void of_add_metadata(OutputFile *of, AVFormatContext *oc, break; case 'c': if (index < 0 || index >= oc->nb_chapters) { - av_log(NULL, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\n", index); + av_log(of, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\n", index); exit_program(1); } m = &oc->chapters[index]->metadata; break; case 'p': if (index < 0 || index >= oc->nb_programs) { - av_log(NULL, AV_LOG_FATAL, "Invalid program index %d in metadata specifier.\n", index); + av_log(of, AV_LOG_FATAL, "Invalid program index %d in metadata specifier.\n", index); exit_program(1); } m = &oc->programs[index]->metadata; break; default: - av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier); + av_log(of, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier); exit_program(1); } av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0); @@ -1514,11 +1516,12 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, AVFormatContext *o return 0; } -static int copy_metadata(const char *outspec, const char *inspec, - AVFormatContext *oc, AVFormatContext *ic, +static int copy_metadata(Muxer *mux, AVFormatContext *ic, + const char *outspec, const char *inspec, int *metadata_global_manual, int *metadata_streams_manual, int *metadata_chapters_manual, const OptionsContext *o) { + AVFormatContext *oc = mux->fc; AVDictionary **meta_in = NULL; AVDictionary **meta_out = NULL; int i, ret = 0; @@ -1526,8 +1529,8 @@ static int copy_metadata(const char *outspec, const char *inspec, const char *istream_spec = NULL, *ostream_spec = NULL; int idx_in = 0, idx_out = 0; - parse_meta_type(inspec, &type_in, &idx_in, &istream_spec); - parse_meta_type(outspec, &type_out, &idx_out, &ostream_spec); + parse_meta_type(mux, inspec, &type_in, &idx_in, &istream_spec); + parse_meta_type(mux, outspec, &type_out, &idx_out, &ostream_spec); if (type_in == 'g' || type_out == 'g') *metadata_global_manual = 1; @@ -1542,7 +1545,7 @@ static int copy_metadata(const char *outspec, const char *inspec, #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ if ((index) < 0 || (index) >= (nb_elems)) {\ - av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\ + av_log(mux, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\ (desc), (index));\ exit_program(1);\ } @@ -1578,7 +1581,7 @@ static int copy_metadata(const char *outspec, const char *inspec, exit_program(1); } if (!meta_in) { - av_log(NULL, AV_LOG_FATAL, "Stream specifier %s does not match any streams.\n", istream_spec); + av_log(mux, AV_LOG_FATAL, "Stream specifier %s does not match any streams.\n", istream_spec); exit_program(1); } } @@ -1612,12 +1615,13 @@ static void copy_meta(Muxer *mux, const OptionsContext *o) int in_file_index = strtol(o->metadata_map[i].u.str, &p, 0); if (in_file_index >= nb_input_files) { - av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index); + av_log(mux, AV_LOG_FATAL, "Invalid input file index %d while " + "processing metadata maps\n", in_file_index); exit_program(1); } - copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, - in_file_index >= 0 ? - input_files[in_file_index]->ctx : NULL, + copy_metadata(mux, + in_file_index >= 0 ? input_files[in_file_index]->ctx : NULL, + o->metadata_map[i].specifier, *p ? p + 1 : p, &metadata_global_manual, &metadata_streams_manual, &metadata_chapters_manual, o); } @@ -1633,7 +1637,7 @@ static void copy_meta(Muxer *mux, const OptionsContext *o) break; } } else { - av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\n", + av_log(mux, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\n", chapters_input_file); exit_program(1); } @@ -1854,7 +1858,7 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o) return 0; } -static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt) +static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt) { const AVClass *class = avcodec_get_class(); const AVClass *fclass = avformat_get_class(); @@ -1880,10 +1884,8 @@ static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt continue; if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) { - av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for " - "output file #%d (%s) is not an encoding option.\n", e->key, - option->help ? option->help : "", nb_output_files - 1, - mux->fc->url); + av_log(mux, AV_LOG_ERROR, "Codec AVOption %s (%s) is not an " + "encoding option.\n", e->key, option->help ? option->help : ""); exit_program(1); } @@ -1891,16 +1893,41 @@ static void validate_enc_avopt(const Muxer *mux, const AVDictionary *codec_avopt if (!strcmp(e->key, "gop_timecode")) continue; - av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for " - "output file #%d (%s) has not been used for any stream. The most " - "likely reason is either wrong type (e.g. a video option with " - "no video streams) or that it is a private option of some encoder " - "which was not actually used for any stream.\n", e->key, - option->help ? option->help : "", nb_output_files - 1, mux->fc->url); + av_log(mux, AV_LOG_WARNING, "Codec AVOption %s (%s) has not been used " + "for any stream. The most likely reason is either wrong type " + "(e.g. a video option with no video streams) or that it is a " + "private option of some encoder which was not actually used for " + "any stream.\n", e->key, option->help ? option->help : ""); } av_dict_free(&unused_opts); } +static const char *output_file_item_name(void *obj) +{ + const Muxer *mux = obj; + + return mux->log_name; +} + +static const AVClass output_file_class = { + .class_name = "OutputFile", + .version = LIBAVUTIL_VERSION_INT, + .item_name = output_file_item_name, + .category = AV_CLASS_CATEGORY_MUXER, +}; + +static Muxer *mux_alloc(void) +{ + Muxer *mux = allocate_array_elem(&output_files, sizeof(*mux), &nb_output_files); + + mux->of.class = &output_file_class; + mux->of.index = nb_output_files - 1; + + snprintf(mux->log_name, sizeof(mux->log_name), "out#%d", mux->of.index); + + return mux; +} + int of_open(const OptionsContext *o, const char *filename) { Muxer *mux; @@ -1911,25 +1938,24 @@ int of_open(const OptionsContext *o, const char *filename) int64_t recording_time = o->recording_time; int64_t stop_time = o->stop_time; + mux = mux_alloc(); + of = &mux->of; + if (stop_time != INT64_MAX && recording_time != INT64_MAX) { stop_time = INT64_MAX; - av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); + av_log(mux, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); } if (stop_time != INT64_MAX && recording_time == INT64_MAX) { int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; if (stop_time <= start_time) { - av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); + av_log(mux, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); exit_program(1); } else { recording_time = stop_time - start_time; } } - mux = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files); - of = &mux->of; - - of->index = nb_output_files - 1; of->recording_time = recording_time; of->start_time = o->start_time; of->shortest = o->shortest; @@ -1948,6 +1974,9 @@ int of_open(const OptionsContext *o, const char *filename) } mux->fc = oc; + av_strlcat(mux->log_name, "/", sizeof(mux->log_name)); + av_strlcat(mux->log_name, oc->oformat->name, sizeof(mux->log_name)); + if (strcmp(oc->oformat->name, "rtp")) want_sdp = 0; @@ -2061,12 +2090,12 @@ int of_open(const OptionsContext *o, const char *filename) /* copy metadata and chapters from input files */ copy_meta(mux, o); - of_add_programs(oc, o); + of_add_programs(mux, o); of_add_metadata(of, oc, o); err = set_dispositions(mux, o); if (err < 0) { - av_log(NULL, AV_LOG_FATAL, "Error setting output stream dispositions\n"); + av_log(mux, AV_LOG_FATAL, "Error setting output stream dispositions\n"); exit_program(1); } @@ -2074,13 +2103,13 @@ int of_open(const OptionsContext *o, const char *filename) // must be done after chapters are created err = process_forced_keyframes(mux, o); if (err < 0) { - av_log(NULL, AV_LOG_FATAL, "Error processing forced keyframes\n"); + av_log(mux, AV_LOG_FATAL, "Error processing forced keyframes\n"); exit_program(1); } err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE); if (err < 0) { - av_log(NULL, AV_LOG_FATAL, "Error setting up output sync queues\n"); + av_log(mux, AV_LOG_FATAL, "Error setting up output sync queues\n"); exit_program(1); } From patchwork Sat Jan 28 10:51:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40153 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp2026141pzj; Sat, 28 Jan 2023 02:53:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXvINWsp0KizrzflOUQswDQ6olHgEgQPlTW3LoI321XQDX4/nfAZ3u1UHUmEFkm1slsfDsmM X-Received: by 2002:aa7:de87:0:b0:49c:d620:4bf8 with SMTP id j7-20020aa7de87000000b0049cd6204bf8mr45182055edv.24.1674903184054; Sat, 28 Jan 2023 02:53:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674903184; cv=none; d=google.com; s=arc-20160816; b=FwSvNj66cUi86EzgbIxJpI9/B3Oiq+7l9qnZSaCg79mwY1PP9wf2dXrT8lCc4cUqcD z9ZKM+PMV4W7Mjw2RKUJ6GeNmUwtuBY832xjFF1Acjki6MQbhImYjYuiLta4HUcuIXqv bVQ/UVv45aDi/PiBbDZjsVTwGrwAVo1CuOjpyY1j6Kld3CJrAvoZCFRbcsUiKwRwUcSi +939+pD0rzmnRwel+TNWz9e7W63BwXHIXyi61lGZSXzyAaAQAcV7/NR4qgPjGVUphst2 itAFQGQ1ER3EyNFaBOhEGQCfvcKIO3kthR60z9DIyuX7fW6WuJLdRUBRDVDE948szvE3 9wFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=3Qf3cZ41aEUt8B0U3f8O8uI9PbridvrsQsmV69bOmTU=; b=EBpSx/4FEjgX/VW0Nko9SpYOUS+3vQ5tPxBfOMuYQJp+L1EbFW3WcERDZg63hTX7hL hp++tBEwovR7QaGAWJfBG/7bo2NUi80OTrO3SGNheJ73Arbv5TVEMkXf4RT23x9ZNkW+ ty9T7itD13qwEDoZHq4nqEso6YrukWxRyh1HR+IGlS2Wkk1mJtw3mTSdIhWlj2bxkOWw C1CjrdL/3fSAtFIL/3KyW0nuIrDWGgO9vlGemRJgh3lTo2Ol1dVpG5PkyzCLnJxACvko nYGOYIIuz1SoznN8LnTu0/3ritRT8Qil3Z3VxfJt1i9xtSsYMEDlthAy2GCk/l4Vo/6u Wg4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a5-20020a509b45000000b0049e2ac8d02fsi10969708edj.569.2023.01.28.02.53.03; Sat, 28 Jan 2023 02:53:04 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D3FD68BDFD; Sat, 28 Jan 2023 12:52:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9001668BBF7 for ; Sat, 28 Jan 2023 12:52:40 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1EEDF2404EE for ; Sat, 28 Jan 2023 11:52:40 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id zkHnB48P-lYS for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id D45652404EC for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9EFED3A0344 for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Jan 2023 11:51:41 +0100 Message-Id: <20230128105142.12476-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230128105142.12476-1-anton@khirnov.net> References: <20230128105142.12476-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] fftools/ffmpeg: add an AVClass to MuxStream/OutputStream X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VIp9T2K1CF2d Use it for logging. This makes log messages related to this output stream more consistent. --- 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 f722ae7632..72206246a7 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -728,8 +728,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); @@ -811,7 +811,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), @@ -823,7 +823,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; } @@ -844,12 +844,12 @@ 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; } 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, @@ -861,7 +861,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, @@ -966,7 +966,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; @@ -1010,7 +1010,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); } @@ -1057,9 +1057,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; @@ -1068,7 +1068,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); @@ -1103,8 +1103,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; @@ -1149,7 +1150,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; } @@ -1201,20 +1202,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; } } @@ -1239,7 +1240,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) @@ -1707,9 +1708,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; @@ -1717,7 +1717,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); } } @@ -1727,7 +1727,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); } @@ -2614,7 +2614,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; @@ -2623,7 +2623,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; } @@ -2705,7 +2705,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) @@ -2762,9 +2762,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; @@ -2789,12 +2788,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 && @@ -2838,9 +2836,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); @@ -2920,7 +2918,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; @@ -2986,12 +2984,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); } @@ -3223,9 +3221,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) @@ -3812,8 +3810,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 b1876f7788..c0996adafb 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -509,6 +509,8 @@ typedef struct KeyframeForceCtx { } KeyframeForceCtx; typedef struct OutputStream { + const AVClass *class; + int file_index; /* file index */ int index; /* stream index in the output file */ @@ -715,7 +717,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 96d6747749..234528eaf8 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 f543438b18..4cf5b47ae5 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -112,15 +112,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; } } @@ -170,6 +169,37 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV return ret; } +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) { @@ -178,7 +208,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; @@ -190,8 +220,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); @@ -199,16 +228,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); } @@ -216,6 +242,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(); @@ -246,7 +277,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; @@ -256,9 +287,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); } } else { @@ -278,7 +308,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; @@ -289,7 +319,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; @@ -300,7 +330,7 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o, for (i = 0; inb_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; } } @@ -312,7 +342,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); } } @@ -371,8 +401,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); } @@ -386,20 +415,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; @@ -409,7 +437,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++; @@ -428,18 +457,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); } @@ -448,7 +477,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; @@ -469,7 +498,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); } @@ -480,7 +509,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; @@ -489,7 +518,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) { @@ -497,13 +526,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); @@ -511,14 +540,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; @@ -538,7 +567,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 @@ -581,7 +610,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); } @@ -590,7 +619,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); @@ -613,7 +642,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); } @@ -691,11 +720,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 @@ -705,7 +734,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); } @@ -729,7 +758,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 { @@ -760,7 +789,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); } @@ -773,7 +802,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); } @@ -801,7 +830,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); } } @@ -829,15 +858,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", @@ -1393,7 +1422,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 " @@ -1835,7 +1864,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; } @@ -2013,10 +2042,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 3df02b7d7f..7c8a668da3 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; From patchwork Sat Jan 28 10:51:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40152 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp2026054pzj; Sat, 28 Jan 2023 02:52:53 -0800 (PST) X-Google-Smtp-Source: AK7set/P25x4s0BWSyHqCeHUjW2X5jY9F2/3nlI85Z3528GS8RPBLiXgITl1+bHQwsVT3cvL2slr X-Received: by 2002:a17:906:ee8a:b0:884:c6d8:e291 with SMTP id wt10-20020a170906ee8a00b00884c6d8e291mr163595ejb.57.1674903173274; Sat, 28 Jan 2023 02:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674903173; cv=none; d=google.com; s=arc-20160816; b=qSFm3yM9rR1nUq6TmnwMN9JRt3JE8g2SpvXeQlQP58x/w91HnDObvukasIbZljWx5f 1IjQHBB+Y6gyjSFyzbY0Nt8/V/izYiM+D8NNA3aRuofPJadVtrJwvi2JJLwdZJzc/XBK 9pH5dB/RQ23k6AMPlPhy7d7LMCWgXnuzqfdDAZ9LcW7G5qXl+lcBP4MSz7Tpetkxui7b eMuulapa4sysjn3uFD0f6N+2t3XJ6lqMuMX556G8DmC63ZaYjSIDmHl5hfo40ttiNLRw AYi+J9aslw0VaxQxpqW/uuUm1kARvNvAyKG32U/0Ua8U+x7iQ0IPzhUxRWAbnXr0D9+D PZMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=/z25CGs1SxM7e1qXB7dJ9SUokAEvMmHcnU8iwbM8X0s=; b=Mpi8BcS52335LM1Vjeg2a+4EauWmfieksW6K161bdrGxda0Qzk0DyeSld4Nhbz1TAA ZYLgxdbKizYuz8aXlNd3Q/M46Lj7uLe4adthEur0hyj5QV51+ZA5/Oc/3i8TJBHzXwDN KuucR2H6IuVV5ueZKe16COHMIMeldl5XApXUSnxJw3Ht3jjS2BAcTs/aCrbNO6sDFxeR IF/QU4tAeth1pFMHGPkrP8+2jrzSOogfcyCzT6GeKsXwMaUTJ4576PRMQbH0ptM38fIU jYgsibKSrti4B5y7xV3zh4IlT9vwgPNfDrld1yqCW4HRTZ7D3tvIjHmtdjVXJar3RVCa 50Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n8-20020a17090673c800b008787c8674b5si7201989ejl.786.2023.01.28.02.52.52; Sat, 28 Jan 2023 02:52:53 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A950F68BDBA; Sat, 28 Jan 2023 12:52:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92F9968BDBA for ; Sat, 28 Jan 2023 12:52:40 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 74311240178 for ; Sat, 28 Jan 2023 11:52:39 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Ng9RGnh7Wfvq for ; Sat, 28 Jan 2023 11:52:39 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E1D732404EE for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id ADB473A034A for ; Sat, 28 Jan 2023 11:52:37 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Jan 2023 11:51:42 +0100 Message-Id: <20230128105142.12476-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230128105142.12476-1-anton@khirnov.net> References: <20230128105142.12476-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] doc/ffmpeg: drop non-existent -dc option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7rQAjkMot4t+ --- doc/ffmpeg.texi | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 67b3294256..6b93386b49 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1041,8 +1041,6 @@ version > 1: @code{out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s} @item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream}) top=1/bottom=0/auto=-1 field first -@item -dc @var{precision} -Intra_dc_precision. @item -vtag @var{fourcc/tag} (@emph{output}) Force video tag/fourcc. This is an alias for @code{-tag:v}. @item -qphist (@emph{global})