How to get video duration from mp4, wmv, flv, mov videos

后端 未结 10 696
深忆病人
深忆病人 2020-11-30 07:51

Alright. Actually i need mostly the mp4 format. But if it is possible to get for other types as well that would be nice. I just need to read the duration of the file. How ca

10条回答
  •  日久生厌
    2020-11-30 08:08

    Using Windows Media Player Component also, we can get the duration of the video.
    Following code snippet may help you guys :

    using WMPLib;
    // ...
    var player = new WindowsMediaPlayer();
    var clip = player.newMedia(filePath);
    Console.WriteLine(TimeSpan.FromSeconds(clip.duration));
    

    and don't forget to add the reference of wmp.dll which will be present in System32 folder.

提交回复
热议问题