[FFmpeg-devel] [PATCH] libavformat/mpegts.c: fix hardcoded 5-bytes skip for metadata streams.

Romain Beauxis toots at rastageeks.org
Thu Jun 22 17:19:36 EEST 2023


Le mer. 21 juin 2023 à 03:32, Anton Khirnov <anton at khirnov.net> a écrit :
>
> Quoting toots at rastageeks.org (2023-06-20 07:09:33)
> > From: Romain Beauxis <toots at 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.
>
> A FATE test for this would be nice.

Here's a patch attached, along with the sample that should go into
fate-suite/mpegts/id3.ts

The output has been verified with a local ffprobe build:

packet|codec_type=data|stream_index=0|pts=126000|pts_time=1.400000|dts=126000|dts_time=1.400000|duration=N/A|duration_time=N/A|size=26|pos=564|flags=K__|data=\n00000000:
4944 3304 0000 0000 0010 5449 5432 0000  ID3.......TIT2..\n00000010: 0006
0000 0374 6573 7400
.....test.\n|side_data|side_data_type=MPEGTS Stream ID|id=189

packet|codec_type=data|stream_index=0|pts=577350|pts_time=6.415000|dts=577350|dts_time=6.415000|duration=N/A|duration_time=N/A|size=26|pos=1316|flags=K__|data=\n00000000:
4944 3304 0000 0000 0010 5449 5432 0000  ID3.......TIT2..\n00000010: 0006
0000 0374 6573 7400
.....test.\n|side_data|side_data_type=MPEGTS Stream ID|id=189

stream|index=0|codec_name=timed_id3|profile=unknown|codec_type=data|codec_tag_string=ID3
|codec_tag=0x20334449|ts_packetsize=188|id=0x100|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=126000|start_time=1.400000|duration_ts=451350|duration=5.015000|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=2|extradata=\n|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
format|filename=id3.ts|nb_streams=1|nb_programs=1|format_name=mpegts|start_time=1.400000|duration=5.015000|size=1504|bit_rate=2399|probe_score=2

> --
> Anton Khirnov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timed_id3_fate_test.patch
Type: application/octet-stream
Size: 2459 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20230622/48bdeecc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: id3.ts
Type: application/octet-stream
Size: 1504 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20230622/48bdeecc/attachment-0001.obj>


More information about the ffmpeg-devel mailing list