使用ffmpeg.exe获取文件属性信息,ffmpeg是java开发的用于多媒体文件编辑的命令行工具,有多个版本,功能比较强大,C#中可以在进程外异步调用这个工具
首页放置文件ffmpeg.exe于bin下面也可以,然后放置文件夹VideoEncoderAsync与根目录下面;
参考地址:http://www.c
代码:
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
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;
}