* [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets @ 2023-03-09 17:04 Devin Heitmueller 2023-03-09 17:04 ` [FFmpeg-devel] [PATCH 2/2] Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams Devin Heitmueller 2023-03-16 22:41 ` [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets Marton Balint 0 siblings, 2 replies; 4+ messages in thread From: Devin Heitmueller @ 2023-03-09 17:04 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Devin Heitmueller The original code would strip off the PTS/DTS of any packets which had a stream ID of STREAM_ID_PRIVATE_STREAM_1. While the intent was to apply this to asynchronous KLV packets, it was being applied to any codec that had that same stream ID (including types such as SMPTE 2038). Add a clause to the if() statement to ensure it only gets applied if the codec actually is KLV. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> --- libavformat/mpegtsenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index ceed089587..3f201cce1d 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1455,7 +1455,8 @@ static int get_pes_stream_id(AVFormatContext *s, AVStream *st, int stream_id, in st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) { return STREAM_ID_PRIVATE_STREAM_1; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { - if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */ + if (st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV && + stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */ *async = 1; return stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM; } else { -- 2.35.1.655.ga68dfadae5 _______________________________________________ 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] 4+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams 2023-03-09 17:04 [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets Devin Heitmueller @ 2023-03-09 17:04 ` Devin Heitmueller 2023-03-16 22:40 ` Marton Balint 2023-03-16 22:41 ` [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets Marton Balint 1 sibling, 1 reply; 4+ messages in thread From: Devin Heitmueller @ 2023-03-09 17:04 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Devin Heitmueller 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. Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> --- 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..2830fd85fa 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3608,6 +3608,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "klv", .long_name = NULL_IF_CONFIG_SMALL("SMPTE 336M Key-Length-Value (KLV) metadata"), }, + { + .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_DVD_NAV, .type = AVMEDIA_TYPE_DATA, diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 89a4a0cb89..d6d4b6c44c 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -579,6 +579,7 @@ enum AVCodecID { AV_CODEC_ID_IDF, AV_CODEC_ID_OTF, AV_CODEC_ID_SMPTE_KLV, + AV_CODEC_ID_SMPTE_2038, AV_CODEC_ID_DVD_NAV, AV_CODEC_ID_TIMED_ID3, AV_CODEC_ID_BIN_DATA, 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; } } -- 2.35.1.655.ga68dfadae5 _______________________________________________ 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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams 2023-03-09 17:04 ` [FFmpeg-devel] [PATCH 2/2] Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams Devin Heitmueller @ 2023-03-16 22:40 ` Marton Balint 0 siblings, 0 replies; 4+ messages in thread From: Marton Balint @ 2023-03-16 22:40 UTC (permalink / raw) To: FFmpeg development discussions and patches On Thu, 9 Mar 2023, Devin Heitmueller wrote: > 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. > > Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> > --- > 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..2830fd85fa 100644 > --- a/libavcodec/codec_desc.c > +++ b/libavcodec/codec_desc.c > @@ -3608,6 +3608,12 @@ static const AVCodecDescriptor codec_descriptors[] = { > .name = "klv", > .long_name = NULL_IF_CONFIG_SMALL("SMPTE 336M Key-Length-Value (KLV) metadata"), > }, > + { > + .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_DVD_NAV, > .type = AVMEDIA_TYPE_DATA, > diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h > index 89a4a0cb89..d6d4b6c44c 100644 > --- a/libavcodec/codec_id.h > +++ b/libavcodec/codec_id.h > @@ -579,6 +579,7 @@ enum AVCodecID { > AV_CODEC_ID_IDF, > AV_CODEC_ID_OTF, > AV_CODEC_ID_SMPTE_KLV, > + AV_CODEC_ID_SMPTE_2038, This should go to the end of the data codec list to retain ABI compatibility. Order in codec_desc.c should be the same. Regards, Marton > AV_CODEC_ID_DVD_NAV, > AV_CODEC_ID_TIMED_ID3, > AV_CODEC_ID_BIN_DATA, > 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; > } > } > -- > 2.35.1.655.ga68dfadae5 > > _______________________________________________ > 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". ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets 2023-03-09 17:04 [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets Devin Heitmueller 2023-03-09 17:04 ` [FFmpeg-devel] [PATCH 2/2] Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams Devin Heitmueller @ 2023-03-16 22:41 ` Marton Balint 1 sibling, 0 replies; 4+ messages in thread From: Marton Balint @ 2023-03-16 22:41 UTC (permalink / raw) To: FFmpeg development discussions and patches On Thu, 9 Mar 2023, Devin Heitmueller wrote: > The original code would strip off the PTS/DTS of any packets > which had a stream ID of STREAM_ID_PRIVATE_STREAM_1. While the > intent was to apply this to asynchronous KLV packets, it was > being applied to any codec that had that same stream ID (including > types such as SMPTE 2038). > > Add a clause to the if() statement to ensure it only gets applied > if the codec actually is KLV. Thanks, will apply. Regards, Marton > > Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com> > --- > libavformat/mpegtsenc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > index ceed089587..3f201cce1d 100644 > --- a/libavformat/mpegtsenc.c > +++ b/libavformat/mpegtsenc.c > @@ -1455,7 +1455,8 @@ static int get_pes_stream_id(AVFormatContext *s, AVStream *st, int stream_id, in > st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) { > return STREAM_ID_PRIVATE_STREAM_1; > } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { > - if (stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */ > + if (st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV && > + stream_id == STREAM_ID_PRIVATE_STREAM_1) /* asynchronous KLV */ > *async = 1; > return stream_id != -1 ? stream_id : STREAM_ID_METADATA_STREAM; > } else { > -- > 2.35.1.655.ga68dfadae5 > > _______________________________________________ > 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". ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-16 22:41 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-09 17:04 [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets Devin Heitmueller 2023-03-09 17:04 ` [FFmpeg-devel] [PATCH 2/2] Add support for preserving SMPTE 2038 when transcoding MPEG-TS streams Devin Heitmueller 2023-03-16 22:40 ` Marton Balint 2023-03-16 22:41 ` [FFmpeg-devel] [PATCH 1/2] mpegtsenc: Restrict "async" behavior to KLV async packets Marton Balint
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