.net根据视频地址获取视频信息

使用ffmpeg.exe获取文件属性信息,ffmpeg是java开发的用于多媒体文件编辑的命令行工具,有多个版本,功能比较强大,C#中可以在进程外异步调用这个工具

首页放置文件ffmpeg.exe于bin下面也可以,然后放置文件夹VideoEncoderAsync与根目录下面;

参考地址:http://www.cnblogs.com/lmjq/archive/2011/09/01/2162240.html

代码:

  public string[] GetVideoTime(string url)

        

            string[] str = new string[3];

            int width = 0;

            int height = 0;

            int time = 0;

            try

            {

                VideoEncoder.Encoder enc = new VideoEncoder.Encoder();

                //ffmpeg.exe的路径,程序会在执行目录(....FFmpeg测试\bin\Debug)下找此文件,

                enc.FFmpegPath = Server.MapPath("~/")+"/bin/Debug/ffmpeg.exe";//F:\mobilepush\trunk\BMobile.OA\FrameWork.web

                //视频路径

                string videoFilePath = "http://video.oss.shuihulu.com/video/a6e911af433a413c8f74577e236fdd12.mp4";

                VideoFile videoFile = new VideoFile(videoFilePath);


                enc.GetVideoInfo(videoFile);


                TimeSpan totaotp = videoFile.Duration;

                width = videoFile.Width;

                height = videoFile.Height;

                time =Convert.ToInt32(totaotp.TotalSeconds);

            }

            catch

            {

            }

            str[0] = time.ToString();

            str[1] = width.ToString();

            str[2] = height.ToString();

            return str;

        }


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值