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 EE69C4C18B for ; Sun, 22 Jun 2025 18:10:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8A2BD68C0C5; Sun, 22 Jun 2025 21:10:40 +0300 (EEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 556E26882FB for ; Sun, 22 Jun 2025 21:10:34 +0300 (EEST) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-23636167afeso33675795ad.3 for ; Sun, 22 Jun 2025 11:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750615832; x=1751220632; 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=ujqHiGL9BentwBy97klpzv9f6vvaWwPH2BpEBRlpong=; b=ERI4ie97uhsJbGN/3exoMVw4SlLg0JZF+VIbOXBFWeawjjxPVk1oblFDzBkwgWIrAr fYVhV1RePu0ReBOAs8meIiliLOUCVZOsMp493wGFggYkbfXS+CNBaBZttBqvx8U3tPiv oGGpPMtneHR+zVODWF9K2wb0ejZxq39TBDReqvjnEkobk+q7qijbKgboLrI8Hlbpu5H5 0JxFX81p+SxG6BOAbhxh496r4cYjYXXGV43ED+qo8XuOIxZiRjwkLw/OPaHWspOSndlZ Z98fU7mA+fyLql6lU3njoZsHyaw60E4PDURhqUHjJ8qWtA5kDHT59QL5szQO/ew/YQwH Z8fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750615832; x=1751220632; 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=ujqHiGL9BentwBy97klpzv9f6vvaWwPH2BpEBRlpong=; b=gfmLOsMqDLYxM+TDuOhciwCJoXn0L1JWKdPAnLjQgTamNBKgMB9O2i3A7f95ol/KB7 gF/tDrskmCP/AZ5QDg+Rktw2aWjncZRzzRlUiUxJbFuPOuqciWXDxaBjisk8zkHjeuPc s0HCyt6BN6Bz7RjtCvs/XNNK7/+TZwK7x1GM5n1Yk2Br31q0Va7gS4atj/e5OWh0cRD4 EMK5YJXSG1nFwlxxzuhE853Xpk3jUGLOXi8FdoSc9XVaGw+xJvaqLBq/Zo6PKfK55ABu WkKk0JuQ7uu8GIx5prN1qHlOY5CJ09K8bG4H/vnYieWqmf8N04zI5YUms99pctAOi26o /67g== X-Gm-Message-State: AOJu0Yyyy9R4YKQqMdQG1bUK1wg8DhCr9jIyMr0FDJ4fS+6xFc2qLmx2 ++doBGJI/8KNUfuQVtjOi7RpZ1wDk21cdMlaDXh3OmVl9X5yXHsezuzBGkUHI7it X-Gm-Gg: ASbGncu1wX2S1RpoZ2FGjwjypJdO6wbTsAHLYby7HFzNvr0J4Br8VcooMq4BmDQ3SGq kFYfb61NhCOXCqmCP8oWd0CrBlG1NWJ3VKQmiERKQE3t9fcXudoIW1Pv5S+4muVXOgHb6iYVDr3 ZDXf2E+6So5rAm1eezIHeGbETsnhAGw8tp7YXVZ6E1vgd3OOnuxWUWlxIyoX6dC9mw6EBz6EYO9 GMtohnSTAPoCcb8YkPxoqLDzxK5a7j2gUShu50+mTHC804S+xwct3aXg7HeGi3ftDeBwfX/l8a0 TKh1GFXVSOd272sEUliNlN3rvvPP43b+oq7kmxw/AfY2CuX8QnD+T7XSf2u7wr3ryVKgZ9AxSwZ Y X-Google-Smtp-Source: AGHT+IEZfw66crmcD8hZtq+EfBTEwFNC5PeQie8SN1UgsNV4kCM3E4ioMRwh8MoNcKE13SuRZp82aw== X-Received: by 2002:a17:903:2a87:b0:234:9375:e081 with SMTP id d9443c01a7336-237d9b8ccdbmr140040655ad.42.1750615832182; Sun, 22 Jun 2025 11:10:32 -0700 (PDT) Received: from homestead.aragog.com ([2605:a601:a9a2:a100:67c:16ff:fe02:37f0]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-237d839379bsm65855585ad.51.2025.06.22.11.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Jun 2025 11:10:31 -0700 (PDT) From: Pavel Koshevoy To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Jun 2025 12:10:30 -0600 Message-ID: <20250622181030.11106-1-pkoshevoy@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mpegts: Add AVFMT_FLAG_ALLOW_CODEC_CHANGES 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 midstream AVStream.codecpar updates optional and disabled by default, so that avformat API clients can enable this feature explicitly when they add support for midstream codec changes. --- doc/APIchanges | 3 +++ doc/formats.texi | 5 +++++ libavformat/avformat.h | 2 ++ libavformat/mpegts.c | 4 +++- libavformat/options_table.h | 1 + libavformat/version.h | 2 +- tests/fate/demux.mak | 2 +- 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 91710bb27d..43172fbcdd 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 AVFMT_FLAG_ALLOW_CODEC_CHANGES flag. + 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..5a0d070247 100644 --- a/doc/formats.texi +++ b/doc/formats.texi @@ -39,6 +39,11 @@ Set format flags. Some are implemented for a limited number of formats. Possible values for input files: @table @samp +@item allow_codec_changes +Allow AVStream.codecpar to change midstream if input changes +(for example when MPEG-TS ES stream_type changes). +This is disabled by default, because most clients of avformat API +do not support random midstream codec changes. @item discardcorrupt Discard corrupted packets. @item fastseek diff --git a/libavformat/avformat.h b/libavformat/avformat.h index b6c63e2237..2e5232c96d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1436,6 +1436,8 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats #define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Add bitstream filters as requested by the muxer +#define AVFMT_FLAG_ALLOW_CODEC_CHANGES 0x400000 ///< Allow AVStream.codecpar to be updated midstream if input changes (e.g. MPEG-TS ES stream_type changes) + /** * Maximum number of bytes read from input in order to determine stream * properties. Used when reading the global header and in diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index deb69a0548..ed4ff580e5 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->flags & AVFMT_FLAG_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..811dd342cc 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -50,6 +50,7 @@ static const AVOption avformat_options[] = { {"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, .unit = "fflags"}, {"fastseek", "fast but inaccurate seeks", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_FAST_SEEK }, INT_MIN, INT_MAX, D, .unit = "fflags"}, {"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, .unit = "fflags"}, +{"allow_codec_changes", "allow AVStream.codecpar to change at runtime if input changes", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_ALLOW_CODEC_CHANGES }, 0, 0, D, .unit = "fflags" }, {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, .unit = "fflags" }, {"autobsf", "add needed bsfs automatically", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_AUTO_BSF }, 0, 0, E, .unit = "fflags" }, {"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D}, 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..e293a00dc0 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 -fflags +allow_codec_changes 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".