[Libav-user] AVCHD m2ts magic number?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] AVCHD m2ts magic number?

Gonzalo Garramuño
I have my viewer that currently does not support m2ts files. This is
because I check for a magic number to be present. However, with the m2ts
files, I don't know what magic number to check.  I downloaded several
samples and they all have different magic numbers.

Does anyone care to shine what is the format for m2ts (AVCHD) files?   I
googled for the specs, but did not turn out anything of use.

--
Gonzalo Garramuño

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: AVCHD m2ts magic number?

cyril apan-2

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.

Cheers,

Cyril APAN.

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: AVCHD m2ts magic number?

Gonzalo Garramuño

El 26/05/17 a las 18:14, cyril apan escribió:
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.

Thanks, however the file from another thread (ffmpeg-user) does not follow that sync byte.

https://drive.google.com/file/d/0BxP5-S1t9VEEcUtGa1d2U3VuZjQ/view?usp=sharing

-- 
Gonzalo Garramuño

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: AVCHD m2ts magic number?

cyril apan-2
As said before, m2ts files are raw mp4 streams. In your case, the stream has probably been started to be dumped in the middle of the related broadcast and the 4 first bytes are the end of a frame, then the 5th byte takes the typical value of a sync byte (0x47), which gets repeated further down the stream.

You can't really use the simple magical number method to recognise those streams...

Cheers,

Cyril APAN.



_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: AVCHD m2ts magic number?

Hendrik Leppkes
In reply to this post by cyril apan-2
On Fri, May 26, 2017 at 11:14 PM, cyril apan
<[hidden email]> 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
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: AVCHD m2ts magic number?

cyril apan-2



>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.
Oops, thanks for correcting me :)

Cheers,

Cyril APAN.

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: AVCHD m2ts magic number?

Power Pan
In reply to this post by Gonzalo Garramuño


On Sat, May 27, 2017 at 4:29 AM, Gonzalo Garramuño <[hidden email]> wrote:
I have my viewer that currently does not support m2ts files. This is because I check for a magic number to be present. However, with the m2ts files, I don't know what magic number to check.  I downloaded several samples and they all have different magic numbers.

Does anyone care to shine what is the format for m2ts (AVCHD) files?   I googled for the specs, but did not turn out anything of use.


But why AV AMP could recognize this raw audio output and decode correctly ? 
 
--
Gonzalo Garramuño

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user


_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user