* [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
[not found] ` <LV3PR17MB719082A865D4524B4A6CB9D6EE75A@LV3PR17MB7190.namprd17.prod.outlook.com>
@ 2025-06-11 14:22 ` Pierre Le Fevre via ffmpeg-devel
2025-06-11 14:31 ` Devin Heitmueller
0 siblings, 1 reply; 3+ messages in thread
From: Pierre Le Fevre via ffmpeg-devel @ 2025-06-11 14:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Pierre Le Fevre
[-- Attachment #1: Type: message/rfc822, Size: 13665 bytes --]
From: Pierre Le Fevre <pierre.lefevre@netinsight.net>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
Date: Wed, 11 Jun 2025 14:22:29 +0000
Message-ID: <LV3PR17MB7190FB50D8717E2DB7A4F481EE75A@LV3PR17MB7190.namprd17.prod.outlook.com>
Signed-off-by: Pierre Le Fevre <pierre.lefevre@netinsight.net>
---
libavformat/mpegtsenc.c | 27 +++++++++++++++++++++++++++
libavformat/mux.c | 6 ++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 6935b71cfe..ba28e17696 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -84,6 +84,7 @@ typedef struct MpegTSWrite {
MpegTSSection pat; /* MPEG-2 PAT table */
MpegTSSection sdt; /* MPEG-2 SDT table context */
MpegTSSection nit; /* MPEG-2 NIT table context */
+ MpegTSSection scte35;
MpegTSService **services;
AVPacket *pkt;
int64_t sdt_period; /* SDT period in PCR time base */
@@ -443,6 +444,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
stream_type = STREAM_TYPE_PRIVATE_DATA;
}
break;
+ case AV_CODEC_ID_SCTE_35:
+ stream_type = STREAM_TYPE_SCTE_DATA_SCTE_35;
+ break;
default:
av_log_once(s, AV_LOG_WARNING, AV_LOG_DEBUG, &ts_st->data_st_warning,
"Stream %d, codec %s, is muxed as a private data stream "
@@ -530,6 +534,13 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
*q++ = 0xfc; // private_data_byte
}
+ for (i = 0; i < s->nb_streams; i++) {
+ if(s->streams[i]->codecpar->codec_id==AV_CODEC_ID_SCTE_35) {
+ put_registration_descriptor(&q, MKTAG('C', 'U', 'E', 'I'));
+ break;
+ }
+ }
+
val = 0xf000 | (q - program_info_length_ptr - 2);
program_info_length_ptr[0] = val >> 8;
program_info_length_ptr[1] = val;
@@ -1160,6 +1171,11 @@ static int mpegts_init(AVFormatContext *s)
ts->nit.write_packet = section_write_packet;
ts->nit.opaque = s;
+ ts->scte35.cc = 15;
+ ts->scte35.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
+ ts->scte35.write_packet = section_write_packet;
+ ts->scte35.opaque = s;
+
ts->pkt = ffformatcontext(s)->pkt;
/* assign pids to each stream */
@@ -2195,6 +2211,17 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
mpegts_write_pes(s, st, buf, size, pts, dts,
pkt->flags & AV_PKT_FLAG_KEY, stream_id);
return 0;
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_SCTE_35) {
+ uint8_t q[1024];
+ unsigned int len;
+
+ len = pkt->size;
+ memcpy(q, pkt->data, len);
+
+ ts->scte35.pid = ts_st->pid;
+
+ mpegts_write_section(&ts->scte35, q, len);
+ return 0;
}
if (ts_st->payload_size && (ts_st->payload_size + size > ts->pes_payload_size ||
diff --git a/libavformat/mux.c b/libavformat/mux.c
index db3b6c2bfe..411c9674df 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -325,7 +325,8 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
}
if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
- par->codec_id != AV_CODEC_ID_SMPTE_2038)
+ par->codec_id != AV_CODEC_ID_SMPTE_2038 &&
+ par->codec_id != AV_CODEC_ID_SCTE_35)
fci->nb_interleaved_streams++;
}
fci->interleave_packet = of->interleave_packet;
@@ -959,7 +960,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
} else if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
par->codec_id != AV_CODEC_ID_VP8 &&
par->codec_id != AV_CODEC_ID_VP9 &&
- par->codec_id != AV_CODEC_ID_SMPTE_2038) {
+ par->codec_id != AV_CODEC_ID_SMPTE_2038 &&
+ par->codec_id != AV_CODEC_ID_SCTE_35) {
++noninterleaved_count;
}
}
--
2.39.5 (Apple Git-154)
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
2025-06-11 14:22 ` [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly Pierre Le Fevre via ffmpeg-devel
@ 2025-06-11 14:31 ` Devin Heitmueller
2025-06-12 8:48 ` Pierre Le Fevre via ffmpeg-devel
0 siblings, 1 reply; 3+ messages in thread
From: Devin Heitmueller @ 2025-06-11 14:31 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Pierre Le Fevre
Hello Pierre,
On Wed, Jun 11, 2025 at 10:22 AM Pierre Le Fevre via ffmpeg-devel
<ffmpeg-devel@ffmpeg.org> wrote:
> ---------- Forwarded message ----------
> From: Pierre Le Fevre <pierre.lefevre@netinsight.net>
> To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
> Cc:
> Bcc:
> Date: Wed, 11 Jun 2025 14:22:29 +0000
> Subject: [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
> Signed-off-by: Pierre Le Fevre <pierre.lefevre@netinsight.net>
For what it's worth, I submitted a similar patch series a couple of
years ago, which also accommodates modifying the pts_adjust field
(which is mandatory if the output stream's clocks are rebased).
https://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312417.html
Devin
--
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com e: devin.heitmueller@ltnglobal.com
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
2025-06-11 14:31 ` Devin Heitmueller
@ 2025-06-12 8:48 ` Pierre Le Fevre via ffmpeg-devel
0 siblings, 0 replies; 3+ messages in thread
From: Pierre Le Fevre via ffmpeg-devel @ 2025-06-12 8:48 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Pierre Le Fevre
[-- Attachment #1: Type: message/rfc822, Size: 13521 bytes --]
From: Pierre Le Fevre <pierre.lefevre@netinsight.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
Date: Thu, 12 Jun 2025 08:48:09 +0000
Message-ID: <LV3PR17MB719007FA1AFE183A897C8C8AEE74A@LV3PR17MB7190.namprd17.prod.outlook.com>
Hi Devin,
I saw your patch but noticed it was still not merged. Since it’s more comprehensive, I’m all for merging your patch instead of mine if it’s not too stale.
Best,
Pierre
From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> on behalf of Devin Heitmueller <devin.heitmueller@ltnglobal.com>
Date: Wednesday, 11 June 2025 at 16:32
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Pierre Le Fevre <pierre.lefevre@netinsight.net>
Subject: Re: [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
*EXTERNAL EMAIL*- Use caution before opening links or attachments
Hello Pierre,
On Wed, Jun 11, 2025 at 10:22 AM Pierre Le Fevre via ffmpeg-devel
<ffmpeg-devel@ffmpeg.org> wrote:
> ---------- Forwarded message ----------
> From: Pierre Le Fevre <pierre.lefevre@netinsight.net>
> To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
> Cc:
> Bcc:
> Date: Wed, 11 Jun 2025 14:22:29 +0000
> Subject: [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly.
> Signed-off-by: Pierre Le Fevre <pierre.lefevre@netinsight.net>
For what it's worth, I submitted a similar patch series a couple of
years ago, which also accommodates modifying the pts_adjust field
(which is mandatory if the output stream's clocks are rebased).
https://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312417.html
Devin
--
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com e: devin.heitmueller@ltnglobal.com
_______________________________________________
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".
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-12 8:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <LV3PR17MB7190A80B93AB754BB240F92EEE75A@LV3PR17MB7190.namprd17.prod.outlook.com>
[not found] ` <LV3PR17MB719082A865D4524B4A6CB9D6EE75A@LV3PR17MB7190.namprd17.prod.outlook.com>
2025-06-11 14:22 ` [FFmpeg-devel] [PATCH] avformat/mpegts: Passthrough SCTE 35 Current behavior breaks SCTE 35 by wrapping it in a PES packet, this adds the logic for the SCTE 35 messages to be passed through cleanly Pierre Le Fevre via ffmpeg-devel
2025-06-11 14:31 ` Devin Heitmueller
2025-06-12 8:48 ` Pierre Le Fevre via ffmpeg-devel
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