Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Caleb Sawyer <Caleb.Sawyer@GSDeng.com>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Cc: Caleb Sawyer <Caleb.Sawyer@GSDeng.com>
Subject: [FFmpeg-devel] [PATCH v3] mpegtsenc: Add SYNC KLV metadata descriptors (MISB ST1402)
Date: Thu, 3 Jul 2025 15:36:00 +0000
Message-ID: <20250703153557.1210-1-caleb.sawyer@gsdeng.com> (raw)

From: Caleb Sawyer <caleb.sawyer@gsdeng.com>

Added metadata_descriptor and metadata_std_descriptor to the PMT for synchronous KLV streams. Asynchronous KLV streams remain as they were. The descriptors are required by MISB ST-1402.2 and are in accordance with ISO/IEC 13818-1.

Signed-off-by: Caleb Sawyer <caleb.sawyer@gsdeng.com>
---
 libavformat/mpegtsenc.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 6935b71cfe..e99e189299 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -814,7 +814,28 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
             break;
         case AVMEDIA_TYPE_DATA:
             if (codec_id == AV_CODEC_ID_SMPTE_KLV) {
-                put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A'));
+                if (st->codecpar->profile == AV_PROFILE_KLVA_SYNC) {
+                    const char *fmtIdent = "KLVA";
+                    *q++ = METADATA_DESCRIPTOR;
+                    *q++ = 9;                   /* descriptor length */
+                    put16(&q, 0x0100);          /* metadata_application_format */
+                    *q++ = 0xff;                /* metadata_format */
+                    putbuf(&q, fmtIdent, 4);    /* KLVA */
+                    *q++ = 0x00;                /* metadata_service_id */
+                    *q++ = 0x0f;                /* decoder_config_flags, DSM-CC_flat, reserved */
+                    *q++ = METADATA_STD_DESCRIPTOR;
+                    *q++ = 9;                   /* descriptor length */
+                    *q++ = 0xc0;
+                    put16(&q, 0x0000);          /* reserved, metadata_input_leak_rate 0x01c4 */
+                    *q++ = 0xc0;
+                    put16(&q, 0x0000);          /* reserved, metadata_buffer_size 0x0400 */
+                    *q++ = 0xc0;
+                    put16(&q, 0x0000);          /* reserved, metadata_output_leak_rate */
+                } else {
+                    put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A'));
+                }
+            } else if (codec_id == AV_CODEC_ID_SMPTE_2038) {
+                put_registration_descriptor(&q, MKTAG('V', 'A', 'N', 'C'));
             } else if (codec_id == AV_CODEC_ID_SMPTE_2038) {
                 put_registration_descriptor(&q, MKTAG('V', 'A', 'N', 'C'));
             } else if (codec_id == AV_CODEC_ID_TIMED_ID3) {
-- 
2.47.1.windows.1

_______________________________________________
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".

                 reply	other threads:[~2025-07-03 15:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250703153557.1210-1-caleb.sawyer@gsdeng.com \
    --to=caleb.sawyer@gsdeng.com \
    --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