What's the best way to get video metadata from a video file in ASP.Net MVC using C#?

后端 未结 4 1450
囚心锁ツ
囚心锁ツ 2020-12-05 05:36

I\'ve been searching on Google and StackOverflow for a good couple of hours. There seems to be a lot of similar questions on StackOverflow but they are all about 3-5 years o

4条回答
  •  不思量自难忘°
    2020-12-05 06:23

    ffmpeg also offers a special application ffprobe for reading metadata. We wrote a wrapper for .net and provided a nuget package, you can find it here: Alturos.VideoInfo

    PM> Install-Package Alturos.VideoInfo
    

    Example:

    var videoFilePath = "myVideo.mp4";
    
    var videoAnalyer = new VideoAnalyzer();
    var analyzeResult = videoAnalyer.GetVideoInfo(videoFilePath);
    var videoInfo = analyzeResult.VideoInfo;
    //videoInfo.Format.Filename = "myVideo.mp4"
    //videoInfo.Format.NbStreams = 1
    //videoInfo.Format.NbPrograms = 0
    //videoInfo.Format.FormatName = "mov,mp4,m4a,3gp,3g2,mj2"
    //videoInfo.Format.FormatLongName = "QuickTime / MOV"
    //videoInfo.Format.StartTime = 0
    //videoInfo.Format.Duration = 120 //seconds
    //videoInfo.Format.Size = 2088470 //bytes
    //videoInfo.Format.BitRate = 139231
    //videoInfo.Format.ProbeScore = 100
    //videoInfo.Format.Tags["encoder"] = Lavf57.76.100
    //videoInfo.Streams[0].CodecType = "video" //Video, Audio
    //videoInfo.Streams[0]...
    

提交回复
热议问题