Skip to content

TSPacket does not handle ts files with ID3 tags #76

@a-chaudhari

Description

@a-chaudhari

TSPacket does not accept valid ts files with ID3 tags. It has a hardcoded check for the sync byte 0x47 at position zero. However, this validation is incorrect when there are ID3 tags prepended to the file.

This is an issue when trying to run hls-prepare. Command output below:

audiowmark: hls: failed to read mpegts input file: /tmp/tmplcm43_06/da80482d-2be7-481a-8ae1-c0fd15791a97/da80482d-2be7-481a-8ae1-c0fd15791a97_96_00001.ts
audiowmark: hls: bad packet sync while reading transport (.ts) packet

Here is a hex dump of the first few dozen bytes of such a file. There are 2 ID3 tags prepended before the actual sync byte of 0x47 at offset 0x96

00000000: 4944 3304 0000 0000 003f 5052 4956 0000  ID3......?PRIV..
00000010: 0035 0000 636f 6d2e 6170 706c 652e 7374  .5..com.apple.st
00000020: 7265 616d 696e 672e 7472 616e 7370 6f72  reaming.transpor
00000030: 7453 7472 6561 6d54 696d 6573 7461 6d70  tStreamTimestamp
00000040: 0000 0000 0000 02bf 2049 4433 0400 0000  ........ ID3....
00000050: 0000 4650 5249 5600 0000 3c00 0063 6f6d  ..FPRIV...<..com
00000060: 2e65 6c65 6d65 6e74 616c 7465 6368 6e6f  .elementaltechno
00000070: 6c6f 6769 6573 2e74 696d 6573 7461 6d70  logies.timestamp
00000080: 2e75 7463 0032 3032 362d 3033 2d30 3454  .utc.2026-03-04T
00000090: 3030 3a30 303a 3030 5a47 4000 1000 00b0  00:00:00ZG@.....
000000a0: 0d00 01c1 0000 0001 e1e0 2d50 7804 ffff  ..........-Px...

This is an issue for AWS MediaConvert generated files, and likely other sources as well. Ideally ID3 tags should not fail validation and should be preserved in the final watermarked output. These tags are needed for synchronization and for other uses and should not be stripped out.

I've also attached a m3u8 and 2 .ts files that have ID3 tags.

792bcd1b-4d2d-4dc2-afdb-f156315b28e7_96.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions