Home > Enterprise >  How to get mov and mp4 video height width without ffmpeg and DirectshowLib
How to get mov and mp4 video height width without ffmpeg and DirectshowLib

Time:01-03

Currently i am using DireshowLib to get .mp4 and .mov file height and width and previously i was also using ffmpeg to get height and width but now we don't want to use this both because of client dineied to use this

So any one can help to get video file height/width.

CodePudding user response:

If you’re on Windows, call MFCreateSourceReaderFromURL then IMFSourceReader. GetNativeMediaType(MF_SOURCE_READER_FIRST_VIDEO_STREAM) then MFGetAttributeSize with MF_MT_FRAME_SIZE argument.

If you don’t want to use C for that, search the internets for C# bindings for the media foundation API. Or write them yourself, you only need a few DLL imported functions (MFStartup, MFShutdown, MFCreateSourceReaderFromURL, MFGetAttributeSize) and COM interfaces (IMFSourceReader, IMFMediaType).

If you’re on Linux, the OS doesn’t natively support any video formats. If you want a pure managed implementation, copy-paste pieces of my library, see the OpenMedia class. That library supports Mpeg4 and MKV containers with h.264 video codec.

  • Related