From patchwork Fri Mar 17 15:03:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 40712 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp637170pzb; Fri, 17 Mar 2023 08:04:04 -0700 (PDT) X-Google-Smtp-Source: AK7set/sr1NWsrFtjf5So7V0wo2c28F/1WPSDI/oD0Q+TE1JvkbPpkTbQMlWt05xuALRzxCv3V8H X-Received: by 2002:a17:907:8688:b0:932:8cd:1021 with SMTP id qa8-20020a170907868800b0093208cd1021mr2732304ejc.33.1679065444081; Fri, 17 Mar 2023 08:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679065444; cv=none; d=google.com; s=arc-20160816; b=JeJQCngX207xCAJq4lmMBbWqXAGuLlenFgoLX9q+xUEvTC85ohhYhe+IynhwgQF+mo 8WTcW/ya8VTGybycM4zBCAGGjNIDyvH4Gk17GLScxHMNTpH+5t6Xg4fIFEDnzAxA8QAt NKzEVNEOeTufltu/98zkNmFiAulRLfeaA7oovz33dJMT56ReYuGxU9pCD1IBWJvrpIYg TRdauC9dfcm+MoEKV4r86Ys/PYsMQFtfgh8gF+2t8+Dh0lHD+6uuDhRNleCSvbxWseUc yMyWW5TP8U79fdAn+ISWDZBr43yJpglf0HWX3DCmIKGJYZRluA1yq3wA2mEX8n9NV3V0 RHsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=Y7Y74vcOqvduYp7H2sG/C/WNeRzsGaPRaWWCNtXXeSk=; b=HxE36r0SWMuOYY9rDRoYc8gEVhBCc1RbbGs+HWKmVZoAmO1Y3+ryC9zo2itXM2ZVvp kq72pVAEtcqeEEZd5V6FvOLOvNAq9m1srtmdgJzvzlY2Oc3g8NwaI4OAqM5w7y2ZNrne kWEXXedpSgmrWeInXh76efnI4V+f+JqltCxlV4M2qmRYeIDV6ZBGQBziNxfaG8xCGKxL dJZctK4reOIDym8ULFCWTt5cDFxOfGtYtVxx96CcGq4WN83sLSr+oLSbXnYFWceh4CD4 rKFeJEopcraylCyzm56FcM8JhnN0h2JUBXy6xHETjaO82Bown6Ec3xiM+cXHVuF4GOM2 ev8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ltnglobal-com.20210112.gappssmtp.com header.s=20210112 header.b=7KwmaTAA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dn14-20020a17090794ce00b008d19011d63asi3278086ejc.4.2023.03.17.08.04.03; Fri, 17 Mar 2023 08:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ltnglobal-com.20210112.gappssmtp.com header.s=20210112 header.b=7KwmaTAA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 98E8968C215; Fri, 17 Mar 2023 17:04:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7319768C17E for ; Fri, 17 Mar 2023 17:03:54 +0200 (EET) Received: by mail-yb1-f176.google.com with SMTP id r1so6000147ybu.5 for ; Fri, 17 Mar 2023 08:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1679065432; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LAAypmz3Pxi8fI+iX1XntpB6OXR1hKe6DBxuekPzpAI=; b=7KwmaTAA9f6gYcFAUb0g5RKHG8kOD6BxAS0YuBI/HyEsCXqoS0esM6IIUHOjokgjtK 5U6mecwIamtNG/hTvlo9j21U5CUUI+eyJ9TkSEv83z9S1xacrUGKcb2EN4SJLzWjqloc OqPtmLLZwcqyrekwdYNjV52pgOkFxB3U5TdNSggkYm4m2R9xGhVjvS1pV/q9i3VGfca5 c2eIv56BmzzIxabOHX1+0Egj1DxNfKyeR7PEtUL4Zmf4VVbRSprxYhDFamSKYfZMhXHp Vsx01hBtiPVYUqx2a3IUUkQlKa+VbAuip9GeYD2cOt7w5qTVcnHw5yaH8M8kHoEacmJU xSkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679065432; 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=LAAypmz3Pxi8fI+iX1XntpB6OXR1hKe6DBxuekPzpAI=; b=krl5EDXRXbnzUPPix1VgTYQe5HRF6+FRnHsc4H8HUCbm0UXMF4brglEgg3IeYFwNtp CBuXiGxMF7AI+/JulfqxLtZbvKXTREwgcZB0Fx40aXQ48l6nCpMWK6RY/fGFGig5fys0 3SXkeg0cMNDeGjrDLshAn1U3+X9OFqIG82r+6ovr3FCXzSs4zG2vfooFwzMaG/xi2iUg l9w4O58FreLnprnrJcMmeW7K8GQpQg+ns4wA+VcyEYkH2lwEuz4fnyhZ3kl7DGAnk6s1 d8yKmQW39Xi8ScwcAUz+8yzcah2whN0YT9qGs5imkUhFBzNvVbmQGzBCPtU7/ZDOnR6F iDRw== X-Gm-Message-State: AO0yUKXqpomzgugUR4dYRCPRb7U8LMWPOLex+e0UXT1EwnbQN/fphWSl wQFa1IZQ1QqwfIl/ZeUn+wL2/DhpNxwTCEsu9Ac= X-Received: by 2002:a5b:711:0:b0:b43:8424:2a57 with SMTP id g17-20020a5b0711000000b00b4384242a57mr12162869ybq.25.1679065432224; Fri, 17 Mar 2023 08:03:52 -0700 (PDT) Received: from klab-nyc-kernellabs2.localdomain (pool-71-105-132-214.nycmny.fios.verizon.net. [71.105.132.214]) by smtp.gmail.com with ESMTPSA id n63-20020a37bd42000000b0074269db4699sm1829267qkf.46.2023.03.17.08.03.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2023 08:03:51 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 Mar 2023 11:03:49 -0400 Message-Id: <20230317150349.17890-1-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 2.35.1.655.ga68dfadae5 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] mpegts: Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams 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: Devin Heitmueller Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IgIHvBlemLKk Add the appropriate descriptors to the MPEG-TS demux and mux to ensure that SMPTE 2038 VANC streams are properly preserved when using codec copy (including adding the appropriate PMT descriptors). The focus of this patch is TS input to TS output. A separate patch adds support for output of 2038 VANC over decklink SDI. Thanks to Marton Balint for feedback to preserve ABI compatibility. Signed-off-by: Devin Heitmueller --- libavcodec/codec_desc.c | 6 ++++++ libavcodec/codec_id.h | 1 + libavformat/mpegts.c | 1 + libavformat/mpegtsenc.c | 5 +++++ libavformat/mux.c | 6 ++++-- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index e80ac07700..d912704891 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3627,6 +3627,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("binary data"), .mime_types= MT("application/octet-stream"), }, + { + .id = AV_CODEC_ID_SMPTE_2038, + .type = AVMEDIA_TYPE_DATA, + .name = "smpte_2038", + .long_name = NULL_IF_CONFIG_SMALL("SMPTE ST 2038 VANC in MPEG-2 TS"), + }, { .id = AV_CODEC_ID_MPEG2TS, .type = AVMEDIA_TYPE_DATA, diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 89a4a0cb89..64df9699f4 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -582,6 +582,7 @@ enum AVCodecID { AV_CODEC_ID_DVD_NAV, AV_CODEC_ID_TIMED_ID3, AV_CODEC_ID_BIN_DATA, + AV_CODEC_ID_SMPTE_2038, AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index d97702fcd7..a8fa3c0b28 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -866,6 +866,7 @@ static const StreamType REGD_types[] = { { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3 }, { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC }, { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_KLV }, + { MKTAG('V', 'A', 'N', 'C'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_2038 }, { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA, AV_CODEC_ID_TIMED_ID3 }, { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1 }, { MKTAG('O', 'p', 'u', 's'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_OPUS }, diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 3f201cce1d..0b38555362 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -422,6 +422,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st) case AV_CODEC_ID_TIMED_ID3: stream_type = STREAM_TYPE_METADATA; break; + case AV_CODEC_ID_SMPTE_2038: + stream_type = STREAM_TYPE_PRIVATE_DATA; + break; case AV_CODEC_ID_DVB_SUBTITLE: case AV_CODEC_ID_DVB_TELETEXT: case AV_CODEC_ID_ARIB_CAPTION: @@ -804,6 +807,8 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) case AVMEDIA_TYPE_DATA: if (codec_id == AV_CODEC_ID_SMPTE_KLV) { put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A')); + } else if (st->codecpar->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) { const char *tag = "ID3 "; *q++ = METADATA_DESCRIPTOR; diff --git a/libavformat/mux.c b/libavformat/mux.c index 04de05ec17..0bc9b6b87d 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -304,7 +304,8 @@ FF_ENABLE_DEPRECATION_WARNINGS par->codec_tag = av_codec_get_tag(of->p.codec_tag, par->codec_id); } - if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT) + if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT && + par->codec_id != AV_CODEC_ID_SMPTE_2038) si->nb_interleaved_streams++; } si->interleave_packet = of->interleave_packet; @@ -942,7 +943,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, ++stream_count; } 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_VP9 && + par->codec_id != AV_CODEC_ID_SMPTE_2038) { ++noninterleaved_count; } }