Menu

Working with mp4 files over 2GB

Anubis
2014-02-04
2014-02-04
  • Anubis

    Anubis - 2014-02-04

    Hi,

    I've got a small program which I use to extract the play length, width and height of .mp4 files.

    The problem I'm encountering is that for the files over 2GB in file size, the DirectShowLib seems to not find the video stream so I can't get the correct width/height.

    If I open the files using MediaInfo for example, this loads no problem.

    My application is compiled for x64 and I'm using DirectShowLib 2.1.0.

    Is there something I'm missing.

    Below is the code I'm using.

    Thanks
    Anubis

    IMediaDet _MediaDetails = null;
    AMMediaType _MediaType = null;
    
    _MediaDetails = (IMediaDet)new MediaDet();
    
    // CHECK FILE EXISTS AND LOAD
    FileInfo fi = new FileInfo(_FileName);
    if (!fi.Exists)
    {
      throw new Exception("File doesn't exist");
    } // END IF
    DsError.ThrowExceptionForHR(_MediaDetails.put_Filename(_FileName));
    
    // CREATE INFORMATION CONTAINERS
    int _VideoWidth = 0;
    int _VideoHeight = 0;
    
    // LOCATE AND PROCESS VIDEO STREAM
    int _StreamIndex = 0;
    int _StreamCount = 0;
    Guid _StreamType = Guid.Empty;
    _MediaDetails.get_OutputStreams(out _StreamCount);
    string test = DirectShowLib.MediaType.Video.ToString();
    while (_StreamIndex < _StreamCount)
    {
      _MediaDetails.put_CurrentStream(_StreamIndex++);
      _MediaDetails.get_StreamType(out _StreamType);
      if (_StreamType == DirectShowLib.MediaType.Video)
      {
    
        // LOAD MEDIA TYPE
        _MediaType = new AMMediaType();
        _MediaDetails.get_StreamMediaType(_MediaType);
    
        // GET VIDEO INFORMATION
        VideoInfoHeader _VideoInfo = (VideoInfoHeader)Marshal.PtrToStructure(_MediaType.formatPtr, typeof(VideoInfoHeader));
    
        // RELEASE MEDIA TYPE
        DsUtils.FreeAMMediaType(_MediaType);
        _MediaType = null;
    
        // GET VIDEO PARAMETERS
        _VideoWidth = _VideoInfo.BmiHeader.Width;
        _VideoHeight = _VideoInfo.BmiHeader.Height;
    
        // EMPTY OBJECT
        _VideoInfo = null;
    
      } // END IF
    } // END WHILE
    
     
  • snarfle

    snarfle - 2014-02-04

    Are you saying _StreamCount is 0? If not, what stream types do you have?

    Also, it's important to remember the DirectShowLib doesn't actually parse the mp4 files. DSL just provides the interface to MS's functionality.

     

Log in to post a comment.

MongoDB Logo MongoDB