[Libav-user] Identifying a MP4 file using libav libraries

Sreenath BH bhsreenath at gmail.com
Sat Apr 9 20:28:50 CEST 2016


On 4/9/16, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Sreenath BH <bhsreenath at ...> writes:
>
>> 4. container format is MP4
>
> Please elaborate a little:
> How do you generally identify an mp4 file (without using FFmpeg)?
>
>> "mov,mp4,m4a,3gp,3g2,mj2"
>
> From FFmpeg pov, this string identifies a specific container format.
>
> Carl Eugen
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>

Hi Carl

to answer your question:

I don't know any other way to identify an MP4 file other than using
ffmpeg lbraries/command.

I have just started to look at the file structure of video files, and
see that the first few bytes of video files have 'fields' that
indicate the container type. If I use hexdump -C on video files, I see
the following:

on a mp4 file:
00000000  00 00 00 18 66 74 79 70  6d 70 34 32 00 00 00 00  |....ftypmp42....|
00000010  69 73 6f  6d 6d 70 34 32  00 02 62 25 6d 6f  6f 76
|isommp42..b%moov|

on one sample 3gp file:
00000000  00 00 00 1c 66 74 79 70  33 67 70 34 00 00 02 00  |....ftyp3gp4....|
00000010  69 73 6f 6d 69 73 6f 32  33 67 70 34 00 00 00 08  |isomiso23gp4....|

So I guess if I have two video files, one mp4 and the other 3gp, but
both using H264 and AAC codecs, I can use the above data to identify
them.

I was assuming/hoping that libav would be able to provide this
information since it anyway opens the file and reads all information
available.

So my question now is, is opening the file and reading first few bytes
(around 20 or so) and checking them the way to go?

thanks,
Sreenath


More information about the Libav-user mailing list