From: Pavel Koshevoy <pkoshevoy-at-gmail.com@ffmpeg.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Add AVFMT_FLAG_ALLOW_CODEC_CHANGES (v2) Date: Mon, 30 Jun 2025 19:32:36 -0600 Message-ID: <CAJgjuoxT44JPHd0rAPHnnH=Y2Otxud66XM_W05f3ODUvp2V_Ag@mail.gmail.com> (raw) In-Reply-To: <cc4569b5-a6c0-4bd4-bfad-418c78f6d229@gmail.com> On Mon, Jun 30, 2025 at 3:46 PM Scott Theisen < scott.the.elm-at-gmail.com@ffmpeg.org> wrote: > On 2025/06/29 23:55, Pavel Koshevoy wrote: > > 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. > > Is this signaled in any way or is the client expected to check if > codecpar has changed? > The client is expected to check codecpar for changes ... I've described it a bit more here https://ffmpeg.org/pipermail/ffmpeg-devel/2025-June/344921.html > > I ask because MythTV added checking and a callback for streams changing > between PMT versions, including adding or removing streams. > > In my code (outside ffmpeg) I've also added a similar mechanism. BTW, in mpeg-ts captures that I have the PMT version doesn't always change, even when there are significant changes in the program structure. > Thanks, > > Scott Theisen > > > --- > > doc/APIchanges | 3 +++ > > libavformat/avformat.h | 2 ++ > > libavformat/mpegts.c | 4 +++- > > libavformat/version.h | 4 ++-- > > tests/ref/fate/ts-demux | 4 ++-- > > 5 files changed, 12 insertions(+), 5 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/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/version.h b/libavformat/version.h > > index b32ddb3617..904e7f06aa 100644 > > --- a/libavformat/version.h > > +++ b/libavformat/version.h > > @@ -31,8 +31,8 @@ > > > > #include "version_major.h" > > > > -#define LIBAVFORMAT_VERSION_MINOR 1 > > -#define LIBAVFORMAT_VERSION_MICRO 101 > > +#define LIBAVFORMAT_VERSION_MINOR 2 > > +#define LIBAVFORMAT_VERSION_MICRO 100 > > > > #define LIBAVFORMAT_VERSION_INT > AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ > > > LIBAVFORMAT_VERSION_MINOR, \ > > diff --git a/tests/ref/fate/ts-demux b/tests/ref/fate/ts-demux > > index d56cc27937..6a830d0d99 100644 > > --- a/tests/ref/fate/ts-demux > > +++ b/tests/ref/fate/ts-demux > > @@ -24,6 +24,6 @@ > packet|codec_type=video|stream_index=0|pts=3912686363|pts_time=43474.292922|dts= > > > packet|codec_type=audio|stream_index=1|pts=3912644825|pts_time=43473.831389|dts=3912644825|dts_time=43473.831389|duration=2880|duration_time=0.032000|size=906|pos=474888|flags=K__|data_hash=CRC32:0893d398 > > > packet|codec_type=audio|stream_index=2|pts=3912645580|pts_time=43473.839778|dts=3912645580|dts_time=43473.839778|duration=2880|duration_time=0.032000|size=354|pos=491808|flags=K__|data_hash=CRC32:f5963fa6 > > > stream|index=0|codec_name=mpeg2video|profile=4|codec_type=video|codec_tag_string=[2][0][0][0]|codec_tag=0x0002|width=1280|height=720|coded_width=0|coded_height=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=16:9|pix_fmt=yuv420p|level=4|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|ts_id=32776|ts_packetsize=188|id=0x31|r_frame_rate=60000/1001|avg_frame_rate=60000/1001|time_base=1/90000|start_pts=3912669846|start_time=43474.109400|duration_ts=19519|duration=0.216878|bit_rate=15000000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=15|extradata_size=150|extradata_hash=CRC32:53134fa8|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic > =0| > > > disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|disposition:multilayer=0|side_datum/cpb_properties:side_data_type=CPB > properties|side_datum/cpb_properties:max_bitrate=15000000|side_datum/cpb_properties:min_bitrate=0|side_datum/cpb_properties:avg_bitrate=0|side_datum/cpb_properties:buffer_size=9781248|side_datum/cpb_properties:vbv_delay=-1 > > > -stream|index=1|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[6][0][0][0]|codec_tag=0x0006|sample_fmt=fltp|sample_rate=48000|channels=6|channel_layout=5.1(side)|bits_per_sample=0|initial_padding=0|dmix_mode=0|ltrt_cmixlev=0.000000|ltrt_surmixlev=0.000000|loro_cmixlev=0.000000|loro_surmixlev=0.000000|ts_id=32776|ts_packetsize=188|id=0x34|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912633305|start_time=43473.703389|duration_ts=14400|duration=0.160000|bit_rate=384000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata= > 0| > > > disposition:dependent=0|disposition:still_image=0|disposition:multilayer=0|tag:language=eng > > > -stream|index=2|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[6][0][0][0]|codec_tag=0x0006|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=0|dmix_mode=0|ltrt_cmixlev=0.000000|ltrt_surmixlev=0.000000|loro_cmixlev=0.000000|loro_surmixlev=0.000000|ts_id=32776|ts_packetsize=188|id=0x35|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912634060|start_time=43473.711778|duration_ts=14400|duration=0.160000|bit_rate=192000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|d > is > > > position:dependent=0|disposition:still_image=0|disposition:multilayer=0|tag:language=es > > > +stream|index=1|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=6|channel_layout=5.1(side)|bits_per_sample=0|initial_padding=0|dmix_mode=0|ltrt_cmixlev=0.000000|ltrt_surmixlev=0.000000|loro_cmixlev=0.000000|loro_surmixlev=0.000000|ts_id=32776|ts_packetsize=188|id=0x34|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912633305|start_time=43473.703389|duration_ts=14400|duration=0.160000|bit_rate=384000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata= > 0| > > > disposition:dependent=0|disposition:still_image=0|disposition:multilayer=0|tag:language=eng > > > +stream|index=2|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=0|dmix_mode=0|ltrt_cmixlev=0.000000|ltrt_surmixlev=0.000000|loro_cmixlev=0.000000|loro_surmixlev=0.000000|ts_id=32776|ts_packetsize=188|id=0x35|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912634060|start_time=43473.711778|duration_ts=14400|duration=0.160000|bit_rate=192000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|d > is > > > position:dependent=0|disposition:still_image=0|disposition:multilayer=0|tag:language=es > > > format|filename=mp3ac325-4864-small.ts|nb_streams=3|nb_programs=1|nb_stream_groups=0|format_name=mpegts|start_time=43473.703389|duration=0.622889|size=512000|bit_rate=6575810|probe_score=50 > > _______________________________________________ > 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". > _______________________________________________ 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".
next prev parent reply other threads:[~2025-07-01 1:33 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-06-30 3:55 Pavel Koshevoy 2025-06-30 21:45 ` Scott Theisen 2025-07-01 1:32 ` Pavel Koshevoy [this message] 2025-07-01 3:46 ` Michael Niedermayer 2025-07-01 5:39 ` Pavel Koshevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAJgjuoxT44JPHd0rAPHnnH=Y2Otxud66XM_W05f3ODUvp2V_Ag@mail.gmail.com' \ --to=pkoshevoy-at-gmail.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git