Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] libavformat/mpegts.c: fix hardcoded 5-bytes skip for metadata streams.
@ 2023-06-20  5:09 toots
  2023-06-20  7:09 ` Paul B Mahol
  2023-06-21  8:32 ` Anton Khirnov
  0 siblings, 2 replies; 9+ messages in thread
From: toots @ 2023-06-20  5:09 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Romain Beauxis

From: Romain Beauxis <toots@rastageeks.org>

Before the introduction of AV_CODEC_ID_TIMED_ID3 for timed_id3 metadata streams
in mpegts (commit 4a4437c0fbc8f7afe0c533070395a42e56b4ee75), AV_CODEC_ID_SMPTE_KLV
was the only existing codec for metadata.

It seems that this codec has a 5-bytes metadata header[1] that, for some reason,
was always skipped when decoding data packets.

However, when working with a AV_CODEC_ID_TIMED_ID3 streams, this results in the
5 first bytes of the payload being cut-off, which includes essential informations
such as the ID3 tag version.

This patch fixes the issue by keeping the 5-bytes skip only for AV_CODEC_ID_SMPTE_KLV
streams.

To test:
1. download this file: https://www.dropbox.com/s/jy8sih3pe8qskxb/bla.ts?dl=1

This file was download from: http://playertest.longtailvideo.com/adaptive/wowzaid3/playlist.m3u8

2. run this command:
  ffprobe -show_streams -select_streams 0 -show_packets -show_private_data \
          -show_data /path/to/bla.ts

Before:
[PACKET]
codec_type=data
stream_index=0
pts=494646418
pts_time=5496.071311
dts=494646418
dts_time=5496.071311
duration=N/A
duration_time=N/A
size=21
pos=482784
flags=K__
data=
00000000: 0000 0000 1054 4954 3200 0000 0600 0003  .....TIT2.......
00000010: 7465 7374 00                             test.

After:
[PACKET]
codec_type=data
stream_index=0
pts=494646418
pts_time=5496.071311
dts=494646418
dts_time=5496.071311
duration=N/A
duration_time=N/A
size=26
pos=482784
flags=K__
data=
00000000: 4944 3304 0000 0000 0010 5449 5432 0000  ID3.......TIT2..
00000010: 0006 0000 0374 6573 7400                 .....test.

---
 libavformat/mpegts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fb8b0bf8fd..0b3edda817 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1305,7 +1305,7 @@ skip:
                     p += sl_header_bytes;
                     buf_size -= sl_header_bytes;
                 }
-                if (pes->stream_type == 0x15 && buf_size >= 5) {
+                if (pes->st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV && buf_size >= 5) {
                     /* skip metadata access unit header */
                     pes->pes_header_size += 5;
                     p += 5;
-- 
2.39.2 (Apple Git-143)

_______________________________________________
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] 9+ messages in thread

end of thread, other threads:[~2023-06-26 15:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20  5:09 [FFmpeg-devel] [PATCH] libavformat/mpegts.c: fix hardcoded 5-bytes skip for metadata streams toots
2023-06-20  7:09 ` Paul B Mahol
2023-06-20 23:58   ` Romain Beauxis
2023-06-21  0:09     ` James Almer
2023-06-21  8:32 ` Anton Khirnov
2023-06-22 14:19   ` Romain Beauxis
2023-06-24 10:43     ` Anton Khirnov
2023-06-24 10:51       ` Thilo Borgmann
2023-06-26 15:17         ` Romain Beauxis

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