[Libav-user] AVCHD m2ts magic number?

Hendrik Leppkes h.leppkes at gmail.com
Sat May 27 00:50:11 EEST 2017


On Fri, May 26, 2017 at 11:14 PM, cyril apan
<cyrilapan-at-yahoo.fr at ffmpeg.org> wrote:
>
> There isn't any real magic number for m2ts files. Those files are raw MP4
> Part 12 streams without headers. As such streams usually start with a sync
> byte (value of a sync byte is always 0x47),  you can consider this to be the
> magic number you were after.
>

You must be mixing things up, MPEG-4 Part 12 is the ISO Base Media
Format, aka MP4, it has nothing to do with m2ts.
The base specs for the MPEG-2 Transport stream format are in ITU-T
Rec. H.222.0 / ISO/IEC 13818-1, however the AVCHD m2ts format is
extended beyond this further slightly.

For the topic at hand, identifying mpeg-ts transport streams isn't as
easy as other formats. You need a bit more logic, like looking for the
repeating pattern of 0x47 sync bytes (ie. every 188 or 192 bytes,
depending on your mpeg-ts syntax).
You could look at mpegts_probe in libavformat/mpegts.c - but beware,
its not exactly trivial.

- Hendrik


More information about the Libav-user mailing list