identifying H.264 file type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wonder8804
    Junior Member
    Junior Member
    • Jan 2011
    • 3

    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.
  • MilesAhead
    Eclectician
    • Nov 2006
    • 2615

    #2
    Easiest may be to make calls to the MediaInfo dll

    MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files


    In one of the downloads there should be example code how to call the functions in the dll.

    Comment

    • wonder8804
      Junior Member
      Junior Member
      • Jan 2011
      • 3

      #3
      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.

      Comment

      • MilesAhead
        Eclectician
        • Nov 2006
        • 2615

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

        MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files


        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:



        It should be even easier to do it in C.

        Comment

        • wonder8804
          Junior Member
          Junior Member
          • Jan 2011
          • 3

          #5
          Am i correct to say that mediainfo is a form of library that can be incorporated or used in C programming?

          Comment

          • MilesAhead
            Eclectician
            • Nov 2006
            • 2615

            #6
            Originally Posted by wonder8804
            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.

            Comment

            Working...