From patchwork Sat May 20 10:19:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Andres Aranda Gutierrez X-Patchwork-Id: 3700 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.10.2 with SMTP id 2csp651215vsk; Sat, 20 May 2017 03:20:07 -0700 (PDT) X-Received: by 10.28.72.68 with SMTP id v65mr19316932wma.41.1495275607142; Sat, 20 May 2017 03:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495275607; cv=none; d=google.com; s=arc-20160816; b=r0NiPDF3k5HsyNaRgFLHuQWvk2i/uN36xQwx8ZqiNta5HvJI6NIQ0Kd5qYwJM/bCS7 F2PW8dYvj/fLSxPdhLipmrte5C5nfTYtcJi3p8LR+y7hEBWKDh5qdNlfrEgXEUs9T/Qj 5yuuIU6HrAduNOzGcCJmtgTX53R88qIUgUHicpAF9YOn/CPXkLbGMo/pgXDcIBMbyx04 hdBP58yIxBtFE88TKZ7dtcZAVN9n9dY4SC2f+q7BOIFrr1PtcY+HAaAmJDVgDfGMb5gu wdTHKLKnSA0wtjQ3OaIN5yYnGBcuxN4yOdUsaGgEHBTjunVi9e0taMJsRHgqpsjgSpb7 i9WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=Wd1W3hyecA3cAl5wipTo9BNe1R2o10JVT1DNBxLFfDQ=; b=cYsPdTAj6QUh/igtLHrh7jqcStmf/Zo07rBCkQR4n+0Uu+81p0LwsNH3inN5shqAIg h1K9+0PjkLhMXH7xYoInxQENkv6InTGw5Fleh9c3TxUd4lPs1HVE94yI5ulfnu6RdYy/ ap0MlTGdZtnkw9ukqthxjjCbJakFM9Di5w12zd8A5uhe07SXRK1C7pWqMz1hSjToWY1U JnuKw9E1gHRtSlAGqkxtuEWWrSguaahXPlg8VAkkxV31uQwFAFJd2eRKZ0zUG1k03dai fkyCC9bQZWQd1y5j5FMA84nL3rZvpItbSg7TzKzWvtdNlM1eOl/OnUs7ZIXOYRBUy+T0 dSrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p14si28727366wmi.47.2017.05.20.03.20.06; Sat, 20 May 2017 03:20:07 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0BE816883A4; Sat, 20 May 2017 13:20:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 83D3C68826B for ; Sat, 20 May 2017 13:19:56 +0300 (EEST) Received: by mail-wm0-f51.google.com with SMTP id d127so104277756wmf.0 for ; Sat, 20 May 2017 03:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ypSvbThN9KFrwP7oD5gH95hiKGDv92i1dR6Po2ySZ/Q=; b=msTtgWZhBP9U8IlhM2vubj5kp2EnPGXlCnbZ8Ai/frUTetPFjrL3AEOuhVzC/6o+MV V6d6YMIupcFq93YjT8HtXao/0uoiMHgDQFOuZIncPmDFo1+u/SFvFgw8TyI1akxFEl2Y DnocU9+auIS3C6GJKDVV/TvXf83eSZIspl3Z0D+/DcZkd/xkrMuKfvJdzhO5rPHsgth7 JKn2/bHD5ICHHCgDhFlzqBgM+kiWSszUJ7sxxNGI0p8xVLdSJsBSICVBsiHAcfccEaVm YCd2PLX3+vYqHr6txasEg2DIc+yJPYQYSLXU8yOV36kCz/4V7jN4lsKXLKpHzxegu1S5 kebQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ypSvbThN9KFrwP7oD5gH95hiKGDv92i1dR6Po2ySZ/Q=; b=l95TX1q9XcxNpGSIlKXSSQSvk+3nYZ2m2BExPamOthO1TLcNJ3T+hJasP34izMi3WT v56Nz1fIUaEK+OdF80F1dHaGZ6J2warzAG8MNv068+HVrJn9emHoWskWk7Z2jhpfTHkW M+G10jLFy7eXho5NDph0gNJoCCGAaqRGM0iL3eu3I7SqDAM5uxdy3qlwyMRGalcejfuk +9MCehTaLzW8lpZAjmQJFaUGSsXIejg/jHhVX5/VQ/HSqA1Z3AvJ7mmQk1nqS1wigHZq 12YvKsyF+FBLqc6pktJVxKVldw2m+4tS2KzSY85/rvVSz6EaTCx3UDQshuVVOo6s2CWn NVYw== X-Gm-Message-State: AODbwcDEC7Zh4b0VqtcWhVukEbGnL6B2GMfcok0qiacHSOLMvcuU4kXC 1E3UDB4eduDO6ayX3aTspKBN8dDWN0Hs X-Received: by 10.28.5.196 with SMTP id 187mr8176964wmf.132.1495275596728; Sat, 20 May 2017 03:19:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.175.109 with HTTP; Sat, 20 May 2017 03:19:56 -0700 (PDT) From: Pedro Andres Aranda Gutierrez Date: Sat, 20 May 2017 12:19:56 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] ffmpeg/ffprobe: Change verbosity level for reporting of empty streams in a Transport Stream X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Rationale: Some satellite PVRs store empty streams in recorded transport stream. The list is of empty streams is sometimes too big to fit one screen-full and you can't see what ffmpeg is actually doing. Proposal: Make the verbosity level required to show empty streams AV_LOG_VERBOSE instead of AV_LOG_INFO Impact: Changes affect only libavformat/dump.c Patch attached. The approach has been to set the loglevel in some dump_function at call time. These functions have been renamed to dump_function_loglevel and new inline functions to replicate the original dump_function have been added. KNOWN CAVEAT: This behaviour for ffmpeg is inherited by ffprobe. Not tested on ffplay. Best regards, Pedro A. Aranda diff --git a/libavformat/dump.c b/libavformat/dump.c index 8fd58a0..771fbeb 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -130,32 +130,44 @@ static void print_fps(double d, const char *postfix) av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix); } -static void dump_metadata(void *ctx, AVDictionary *m, const char *indent) +/* dump metatadata information wiht a specific log level */ + +static void dump_metadata_loglevel(void *ctx, AVDictionary *m, const char *indent, int loglevel) { if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) { AVDictionaryEntry *tag = NULL; - av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent); + av_log(ctx, loglevel, "%sMetadata:\n", indent); while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) if (strcmp("language", tag->key)) { const char *p = tag->value; - av_log(ctx, AV_LOG_INFO, + av_log(ctx, loglevel, "%s %-16s: ", indent, tag->key); while (*p) { char tmp[256]; size_t len = strcspn(p, "\x8\xa\xb\xc\xd"); av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1)); - av_log(ctx, AV_LOG_INFO, "%s", tmp); + av_log(ctx, loglevel, "%s", tmp); p += len; - if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " "); - if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s %-16s: ", indent, ""); + if (*p == 0xd) av_log(ctx, loglevel, " "); + if (*p == 0xa) av_log(ctx, loglevel, "\n%s %-16s: ", indent, ""); if (*p) p++; } - av_log(ctx, AV_LOG_INFO, "\n"); + av_log(ctx, loglevel, "\n"); } } } +/* + This is the function that is used through the file, + will only call the new version with explicit loglevel + when dumping TS information. +*/ +static inline void dump_metadata(void *ctx, AVDictionary *m, const char *indent) +{ + dump_metadata_loglevel(ctx, m, indent, AV_LOG_INFO); +} + /* param change side data*/ static void dump_paramchange(void *ctx, AVPacketSideData *sd) { @@ -378,78 +390,84 @@ static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData * } } -static void dump_sidedata(void *ctx, AVStream *st, const char *indent) +static void dump_sidedata_loglevel(void *ctx, AVStream *st, const char *indent, + int loglevel) { int i; if (st->nb_side_data) - av_log(ctx, AV_LOG_INFO, "%sSide data:\n", indent); + av_log(ctx, loglevel, "%sSide data:\n", indent); for (i = 0; i < st->nb_side_data; i++) { AVPacketSideData sd = st->side_data[i]; - av_log(ctx, AV_LOG_INFO, "%s ", indent); + av_log(ctx, loglevel, "%s ", indent); switch (sd.type) { case AV_PKT_DATA_PALETTE: - av_log(ctx, AV_LOG_INFO, "palette"); + av_log(ctx, loglevel, "palette"); break; case AV_PKT_DATA_NEW_EXTRADATA: - av_log(ctx, AV_LOG_INFO, "new extradata"); + av_log(ctx, loglevel, "new extradata"); break; case AV_PKT_DATA_PARAM_CHANGE: - av_log(ctx, AV_LOG_INFO, "paramchange: "); + av_log(ctx, loglevel, "paramchange: "); dump_paramchange(ctx, &sd); break; case AV_PKT_DATA_H263_MB_INFO: - av_log(ctx, AV_LOG_INFO, "H.263 macroblock info"); + av_log(ctx, loglevel, "H.263 macroblock info"); break; case AV_PKT_DATA_REPLAYGAIN: - av_log(ctx, AV_LOG_INFO, "replaygain: "); + av_log(ctx, loglevel, "replaygain: "); dump_replaygain(ctx, &sd); break; case AV_PKT_DATA_DISPLAYMATRIX: - av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees", + av_log(ctx, loglevel, "displaymatrix: rotation of %.2f degrees", av_display_rotation_get((int32_t *)sd.data)); break; case AV_PKT_DATA_STEREO3D: - av_log(ctx, AV_LOG_INFO, "stereo3d: "); + av_log(ctx, loglevel, "stereo3d: "); dump_stereo3d(ctx, &sd); break; case AV_PKT_DATA_AUDIO_SERVICE_TYPE: - av_log(ctx, AV_LOG_INFO, "audio service type: "); + av_log(ctx, loglevel, "audio service type: "); dump_audioservicetype(ctx, &sd); break; case AV_PKT_DATA_QUALITY_STATS: - av_log(ctx, AV_LOG_INFO, "quality factor: %"PRId32", pict_type: %c", + av_log(ctx, loglevel, "quality factor: %"PRId32", pict_type: %c", AV_RL32(sd.data), av_get_picture_type_char(sd.data[4])); break; case AV_PKT_DATA_CPB_PROPERTIES: - av_log(ctx, AV_LOG_INFO, "cpb: "); + av_log(ctx, loglevel, "cpb: "); dump_cpb(ctx, &sd); break; case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: dump_mastering_display_metadata(ctx, &sd); break; case AV_PKT_DATA_SPHERICAL: - av_log(ctx, AV_LOG_INFO, "spherical: "); + av_log(ctx, loglevel, "spherical: "); dump_spherical(ctx, st->codecpar, &sd); break; case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: dump_content_light_metadata(ctx, &sd); break; default: - av_log(ctx, AV_LOG_INFO, + av_log(ctx, loglevel, "unknown side data type %d (%d bytes)", sd.type, sd.size); break; } - av_log(ctx, AV_LOG_INFO, "\n"); + av_log(ctx, loglevel, "\n"); } } +static inline void dump_sidedata(void *ctx, AVStream *st, const char *indent) +{ + dump_sidedata_loglevel(ctx, st, indent,AV_LOG_INFO); +} + /* "user interface" functions */ -static void dump_stream_format(AVFormatContext *ic, int i, - int index, int is_output) +static void dump_stream_format_loglevel(AVFormatContext *ic, int i, + int index, int is_output,int loglevel) { char buf[256]; int flags = (is_output ? ic->oformat->flags : ic->iformat->flags); @@ -482,17 +500,17 @@ static void dump_stream_format(AVFormatContext *ic, int i, avcodec_string(buf, sizeof(buf), avctx, is_output); avcodec_free_context(&avctx); - av_log(NULL, AV_LOG_INFO, " Stream #%d:%d", index, i); + av_log(NULL, loglevel, " Stream #%d:%d", index, i); /* the pid is an important information, so we display it */ /* XXX: add a generic system */ if (flags & AVFMT_SHOW_IDS) - av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); + av_log(NULL, loglevel, "[0x%x]", st->id); if (lang) - av_log(NULL, AV_LOG_INFO, "(%s)", lang->value); + av_log(NULL, loglevel, "(%s)", lang->value); av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames, st->time_base.num, st->time_base.den); - av_log(NULL, AV_LOG_INFO, ": %s", buf); + av_log(NULL, loglevel, ": %s", buf); if (st->sample_aspect_ratio.num && av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) { @@ -501,7 +519,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, st->codecpar->width * (int64_t)st->sample_aspect_ratio.num, st->codecpar->height * (int64_t)st->sample_aspect_ratio.den, 1024 * 1024); - av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d", + av_log(NULL, loglevel, ", SAR %d:%d DAR %d:%d", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } @@ -513,7 +531,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int tbc = st->codec->time_base.den && st->codec->time_base.num; if (fps || tbr || tbn || tbc) - av_log(NULL, AV_LOG_INFO, "%s", separator); + av_log(NULL, loglevel, "%s", separator); if (fps) print_fps(av_q2d(st->avg_frame_rate), tbr || tbn || tbc ? "fps, " : "fps"); @@ -526,30 +544,36 @@ static void dump_stream_format(AVFormatContext *ic, int i, } if (st->disposition & AV_DISPOSITION_DEFAULT) - av_log(NULL, AV_LOG_INFO, " (default)"); + av_log(NULL, loglevel, " (default)"); if (st->disposition & AV_DISPOSITION_DUB) - av_log(NULL, AV_LOG_INFO, " (dub)"); + av_log(NULL, loglevel, " (dub)"); if (st->disposition & AV_DISPOSITION_ORIGINAL) - av_log(NULL, AV_LOG_INFO, " (original)"); + av_log(NULL, loglevel, " (original)"); if (st->disposition & AV_DISPOSITION_COMMENT) - av_log(NULL, AV_LOG_INFO, " (comment)"); + av_log(NULL, loglevel, " (comment)"); if (st->disposition & AV_DISPOSITION_LYRICS) - av_log(NULL, AV_LOG_INFO, " (lyrics)"); + av_log(NULL, loglevel, " (lyrics)"); if (st->disposition & AV_DISPOSITION_KARAOKE) - av_log(NULL, AV_LOG_INFO, " (karaoke)"); + av_log(NULL, loglevel, " (karaoke)"); if (st->disposition & AV_DISPOSITION_FORCED) - av_log(NULL, AV_LOG_INFO, " (forced)"); + av_log(NULL, loglevel, " (forced)"); if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) - av_log(NULL, AV_LOG_INFO, " (hearing impaired)"); + av_log(NULL, loglevel, " (hearing impaired)"); if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) - av_log(NULL, AV_LOG_INFO, " (visual impaired)"); + av_log(NULL, loglevel, " (visual impaired)"); if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS) - av_log(NULL, AV_LOG_INFO, " (clean effects)"); - av_log(NULL, AV_LOG_INFO, "\n"); + av_log(NULL, loglevel, " (clean effects)"); + av_log(NULL, loglevel, "\n"); + + dump_metadata_loglevel(NULL, st->metadata, " ",loglevel); - dump_metadata(NULL, st->metadata, " "); + dump_sidedata_loglevel(NULL, st, " ",loglevel); +} - dump_sidedata(NULL, st, " "); +static void inline dump_stream_format(AVFormatContext *ic, int i, + int index, int is_output) +{ + dump_stream_format_loglevel(ic, i, index, is_output, AV_LOG_INFO); } void av_dump_format(AVFormatContext *ic, int index, @@ -559,7 +583,8 @@ void av_dump_format(AVFormatContext *ic, int index, uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL; if (ic->nb_streams && !printed) return; - + int av_log_level; + av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n", is_output ? "Output" : "Input", index, @@ -617,9 +642,16 @@ void av_dump_format(AVFormatContext *ic, int index, for (j = 0; j < ic->nb_programs; j++) { AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata, "name", NULL, 0); - av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id, + /* + Sometimes transport streams also have 'empty' programs (i.e. no streams inside). + This can be annoying, so I'm raising the log level to AV_LOG_VERBOSE + for 'empty' programs. Programs with streams get the normal AV_LOG_INFO level. + */ + av_log_level = (ic->programs[j]->nb_stream_indexes > 0) ? + AV_LOG_INFO : AV_LOG_VERBOSE; + av_log(NULL, av_log_level, " Program %d %s\n", ic->programs[j]->id, name ? name->value : ""); - dump_metadata(NULL, ic->programs[j]->metadata, " "); + dump_metadata_loglevel(NULL, ic->programs[j]->metadata, " ", av_log_level); for (k = 0; k < ic->programs[j]->nb_stream_indexes; k++) { dump_stream_format(ic, ic->programs[j]->stream_index[k], index, is_output); @@ -633,7 +665,7 @@ void av_dump_format(AVFormatContext *ic, int index, for (i = 0; i < ic->nb_streams; i++) if (!printed[i]) - dump_stream_format(ic, i, index, is_output); + dump_stream_format_loglevel(ic, i, index, is_output,AV_LOG_VERBOSE); av_free(printed); }