Getting duration of a video file on AWS S3 Bucket with WMPLib?

I’m trying to get the duration of video files in my .net web application. When the files are local, I can get it to work very well using WMPLib’s WindowsMediaPlayer class (I was using FFprobe but it was causing issues). But then when the file is stored on AWS, it won’t work. I’ve checked all the file permissions and made the bucket’s folders and the file itself public and all that, but I can’t get it to work.

If I put the same file on S3 and on my machine, the local video’s duration returns as 30 seconds, but the S3 video (which should be 30 seconds) comes back as 0 seconds every time.

using WMPLib;  .........  private int GetVideoLength(string s3Path)         {             var localPath = "C://input.avi"             WindowsMediaPlayer wmp = new WindowsMediaPlayer();              var mediainfo = wmp.newMedia(localPath);             var t = mediainfo.duration; // 30 seconds               var mediainfo2 = wmp.newMedia(s3Path);             return mediainfo2.duration; // 0 seconds         } 

I’m not married to using this WindowsMediaPlayer class, but locally it’s the one that seems the most reliable. If I can just get it to work with S3 then it’ll be perfect.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.