Digital Video Forums  

Go Back   Digital Video Forums > Video File Formats > MP4, MKV, MPEG-4 AVC (H.264)

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 16 Jan 2011, 06:48 PM   #1
Junior Member
Junior Member
 
Join Date: Jan 2011
Posts: 3
Default identifying H.264 file type

Hi,

I would like to write a C/C++ program to identify if a certain file type is or is not a h.264 file.

Is there an algorithm for this?

Thank you.
wonder8804 is offline   Reply With Quote
Old 16 Jan 2011, 07:18 PM   #2
Eclectician
 
MilesAhead's Avatar
 
Join Date: Nov 2006
Posts: 2,615
Default

Easiest may be to make calls to the MediaInfo dll

http://mediainfo.sourceforge.net/en

In one of the downloads there should be example code how to call the functions in the dll.
MilesAhead is offline   Reply With Quote
Old 17 Jan 2011, 02:48 AM   #3
Junior Member
Junior Member
 
Join Date: Jan 2011
Posts: 3
Default

Can you guide me on this? Actually, i do not understand what exactly mediainfo is for. I have downloaded it but it only shows what is contained in the file. What i require is the actual code that can be written on C/C++ platform to determine whether the given stream is H.264 or not.

is this algorithm sufficient? I got this from another person.

Set nal_unit_cnt=0

labelA:
Find 0x000001 pattern (must be byte-aligned)

Read next byte nal_byte

Extract forbidden_zero_bit = nal_byte>>7

Extract nal_unit_type = nal_byte &0x1F

If forbidden_zero_bit==0 and nal_unit_type<=19
nal_unit_cnt ++
else
abort: this is not h264 stream
endif

if nal_unit_cnt < 20 (or other threshold)
goto labeA
endif

Thank you.
wonder8804 is offline   Reply With Quote
Old 17 Jan 2011, 07:30 AM   #4
Eclectician
 
MilesAhead's Avatar
 
Join Date: Nov 2006
Posts: 2,615
Default

You don't say what OS you are programming for but if it's Windows download the dll here:

http://mediainfo.sourceforge.net/en/Download/Windows

With the download package there are example programs how to call the functions.
All the stuff you see in the MediaInfo exe gui display is available as function call returns from the dll. Such as video codec, audio codec, display aspect ration etc..

Otherwise to do it yourself you'd have to study all the multimedia file formats to dig out the info on your own.

edit: you have to download the DLL not MediaInfo.exe.

Here's an example of a program written in AutoHotKey that uses the DLL to get the info:

http://skwire.dcmembers.com/wb/pages...e/playtime.php

It should be even easier to do it in C.
MilesAhead is offline   Reply With Quote
Old 17 Jan 2011, 07:56 PM   #5
Junior Member
Junior Member
 
Join Date: Jan 2011
Posts: 3
Default

Am i correct to say that mediainfo is a form of library that can be incorporated or used in C programming?
wonder8804 is offline   Reply With Quote
Old 18 Jan 2011, 09:06 AM   #6
Eclectician
 
MilesAhead's Avatar
 
Join Date: Nov 2006
Posts: 2,615
Default

Quote:
Originally Posted by wonder8804 View Post
Am i correct to say that mediainfo is a form of library that can be incorporated or used in C programming?
Right. See instructions for your compiler how to call functions in DLLs. Some compilers like the C++ in the new Visual Studio dynamically load and call functions for you. Some you can either link statically or load the DLL using LoadLibrary() function. There should be C source code with the download that shows how it's done.
MilesAhead is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Type? hello people General Discussions 29 22 Aug 2005 04:15 AM
Identifying file where Bad Disc sector occurs ZacOz Blank Media and Burning 0 5 Feb 2005 06:18 PM
Nandub - Cannot determine the file type of the avs file?!?!?! techno DivX/XviD Conversion/Encoding 9 5 Nov 2002 10:07 AM



All times are GMT +10. The time now is 08:36 AM.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 1999 - 2018 Digital Digest

Visit DivXLand   Visit dvdloc8.com