From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 3BBF84F722 for ; Sat, 21 Jun 2025 23:25:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id BE97968C7F8; Sun, 22 Jun 2025 02:25:02 +0300 (EEST) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id E5FF068C3BE for ; Sun, 22 Jun 2025 02:24:55 +0300 (EEST) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2349f096605so44630375ad.3 for ; Sat, 21 Jun 2025 16:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750548294; x=1751153094; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7Inh08x2EbqPUnvlUE681VdPQVl/GHLPgCpQn7hOLc0=; b=IGwrg7jvh1/25txj2NIiAPAdtgjh97qH87SPlK/SAP+xgvQjq5vEZnQ8bkTRkBh1JM OTCJFK+G/0BCtOWTEI4Kfw97YdWMr04gNYRzHi9Q3d/2r2sdZpOBeBQbetmi/OXUiGwy EmdDvHsaMp+xDh0xB46W6kHlw1avHshcMOa/suqB9r//xu1pQjppFRYNOYU+6Im+6awz WipnRw1bhBmWRL9yLvn2T7viVeUMiS7dmmtWTMUIcX510vAqQ+Rcz8Cdshrj5dUJZ1Pp d1CiJVSOw+YepSFv3mfXmhUTATBv9IHHinm1EbeJWDMBvuvIvJdSf4FqRLJ/SW+bAJ9Z 3Sxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750548294; x=1751153094; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7Inh08x2EbqPUnvlUE681VdPQVl/GHLPgCpQn7hOLc0=; b=B7YTYmcgPZsweCHJ+Ov19A2M1BRpKrY/7nTzksrTDqJ1+OomZW7fNwj/hVaGnB3sux dHWbZZN24x7zniYoW9CqGvTaq8yHce4RdwRLZn4k0mnZGo5/PPA09swxSrAwSycjNTkm v+lQEDkIIFqMwFqw8TRv8NNJvbzcxS9xuZTb/7sRt6PLijJSJd9VYVfvXb+8LK7QUSc1 yqkPqRdV9WfSVEal4aPe0OAvipMNq/Owslke+CivPMTTdlvN2bchSbzQxQ1ifGMOZcL6 ii+jwunKyU68SRyUnDYNgb7vJNQzzCiCpPHshqb4C3tg7xalHaEU/fYwX2g+82x6GRL2 +WmA== X-Gm-Message-State: AOJu0YyXWYNgYMcitjwOs7m7H6yGGjLYmUn3N2TUAJtBvQwKM2YZpQeS 58AvDcUa6Xp1CTDRoioGMw9hmDueSrZ2pNjOwkzQXLg8VgeE6h8jMyD8hwFnmYxt X-Gm-Gg: ASbGncsr1Xh/DpMbd3D6LgchGHg0L9G0iqcdww/ox14tob7GAtTqkW32yoV07BLKLGM lsjXELDjL99seTdxBObrscivvh2tWjyjtksO4uAhX3kSsF6n2SmU4wSy49Bk/E1kLLJ+oLm8bPr X5aq/0J2Dw1dEGD1m2Oi3xri3o77SmFu25nhAl/aVWvg+S0S9ATPl10vK/Aab5qTTrEMpBfGi0+ +yz9Kup8je8MzxV5Bz3uWv0F+roCPGG1dNXHnV+z0pvptOfPJ6og/wTwKGCQEex5oPiHjNFpifg a3gtkve/MhSWkzwr2Nkl3eIurVgudul0UgSqbKlisrLlKCGsU04A621EOYn0xBk8ci4i2Kb0fY+ ES70pjK9HpYY= X-Google-Smtp-Source: AGHT+IHNvciNWJ5N+r1i9gd2TuAZEk1mLJ8ifsSPDbRwwe0mAChC6wjLVQSZ1QySwl8OrKQWVGaP7g== X-Received: by 2002:a17:902:d58d:b0:234:a033:b6f6 with SMTP id d9443c01a7336-237d9917e17mr125643315ad.31.1750548293644; Sat, 21 Jun 2025 16:24:53 -0700 (PDT) Received: from homestead.aragog.com ([2605:a601:a9a2:a100:67c:16ff:fe02:37f0]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-237d8393741sm47826755ad.15.2025.06.21.16.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jun 2025 16:24:53 -0700 (PDT) From: Pavel Koshevoy To: ffmpeg-devel@ffmpeg.org Date: Sat, 21 Jun 2025 17:24:51 -0600 Message-ID: <20250621232451.9545-1-pkoshevoy@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mpegts: Add allow_codec_changes option to AVFormatContext 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 Cc: Pavel Koshevoy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Make runtime AVStream.codecpar codec_id updates optional and disabled by default, so that avformat API clients can enable this feature explicitly when they add support for runtime codec changes. --- doc/APIchanges | 3 +++ doc/formats.texi | 6 ++++++ libavformat/avformat.h | 10 ++++++++++ libavformat/mpegts.c | 4 +++- libavformat/options_table.h | 1 + libavformat/version.h | 2 +- tests/fate/demux.mak | 2 +- 7 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 91710bb27d..29b3389094 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28 API changes, most recent first: +2025-06-17 - xxxxxxxxxx - lavf 62.2.100 - avformat.h + Add AVFormatContext.allow_codec_changes AVOption. + 2025-05-21 - xxxxxxxxxx - lavu 60.3.100 - avassert.h Add av_unreachable() and av_assume() macros. diff --git a/doc/formats.texi b/doc/formats.texi index 876a9e92b3..d18613f8bd 100644 --- a/doc/formats.texi +++ b/doc/formats.texi @@ -228,6 +228,12 @@ would require too many resources due to a large number of streams. Skip estimation of input duration if it requires an additional probing for PTS at end of file. At present, applicable for MPEG-PS and MPEG-TS. +@item allow_codec_changes @var{bool} (@emph{input}) +Allow AVStream.codecpar codec_type and codec_id to change at runtime +(for example when MPEG-TS PMT ES stream_type changes at runtime). +This is disabled by default, because most clients of avformat API +do not support random mid-stream codec changes. + @item duration_probesize @var{integer} (@emph{input}) Set probing size, in bytes, for input duration estimation when it actually requires an additional probing for PTS at end of file (at present: MPEG-PS and MPEG-TS). diff --git a/libavformat/avformat.h b/libavformat/avformat.h index b6c63e2237..c6956626b5 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1884,6 +1884,16 @@ typedef struct AVFormatContext { * @see skip_estimate_duration_from_pts */ int64_t duration_probesize; + + /** + * Allow AVStream.codecpar codec_type and codec_id to change at runtime + * (for example when MPEG-TS PMT ES stream_type changes at runtime). + * This is disabled by default, because most clients of avformat API + * do not support random mid-stream codec changes. + * - muxing: unused + * - demuxing: set by user + */ + int allow_codec_changes; } AVFormatContext; /** diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index deb69a0548..0c78e870bb 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2510,7 +2510,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (!st) goto out; - if (pes && pes->stream_type != stream_type) + if (pes && (!pes->stream_type || + (pes->stream_type != stream_type && + ts->stream->allow_codec_changes))) mpegts_set_stream_info(st, pes, stream_type, prog_reg_desc); add_pid_to_program(prg, pid); diff --git a/libavformat/options_table.h b/libavformat/options_table.h index e2e690fd2a..e949d60c3e 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -106,6 +106,7 @@ static const AVOption avformat_options[] = { {"skip_estimate_duration_from_pts", "skip duration calculation in estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D}, {"max_probe_packets", "Maximum number of packets to probe a codec", OFFSET(max_probe_packets), AV_OPT_TYPE_INT, { .i64 = 2500 }, 0, INT_MAX, D }, {"duration_probesize", "Maximum number of bytes to probe the durations of the streams in estimate_timings_from_pts", OFFSET(duration_probesize), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, D}, +{"allow_codec_changes", "Allow AVStream.codecpar codec_type and codec_id to change at runtime", OFFSET(allow_codec_changes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D}, {NULL}, }; diff --git a/libavformat/version.h b/libavformat/version.h index a7c80dc564..904e7f06aa 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 1 +#define LIBAVFORMAT_VERSION_MINOR 2 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak index ead5ad4b10..4a39e950b9 100644 --- a/tests/fate/demux.mak +++ b/tests/fate/demux.mak @@ -158,7 +158,7 @@ FATE_SAMPLES_DEMUX-$(CONFIG_XWMA_DEMUXER) += fate-xwma-demux fate-xwma-demux: CMD = crc -i $(TARGET_SAMPLES)/xwma/ergon.xwma -c:a copy FATE_FFPROBE_DEMUX-$(CONFIG_MPEGTS_DEMUXER) += fate-ts-demux -fate-ts-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/ac3/mp3ac325-4864-small.ts +fate-ts-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/ac3/mp3ac325-4864-small.ts -allow_codec_changes 1 FATE_FFPROBE_DEMUX-$(CONFIG_MPEGTS_DEMUXER) += fate-ts-timed-id3-demux fate-ts-timed-id3-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/mpegts/id3.ts -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".