我如何获得一个MP4视频文件的尺寸是多少? [英] How do I get the dimensions of a mp4 video file?

查看:933
本文介绍了我如何获得一个MP4视频文件的尺寸是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,将接受并保存MP4视频文件。我需要能够获得视频的尺寸为好。这将运行ASP.NET 2.0的服务器上运行,所以任何外部库必须能够被放置在Bin文件夹,因为他们不能在服务器上安装。

I have a form that will accept and save a MP4 video file. I need to be able to get the dimensions of the video as well. This will be running on a server running ASP.NET 2.0 so any external libs must be able to be placed in the Bin folder as they can not be installed on the server.

任何想法如何得到这些信息?如果相同的lib会让我转code中的视频为FLV,这将是一个巨大的奖金。

Any ideas how to get the information? If the same lib would let me transcode the video to flv that would be a huge bonus.

更新:服务器是XP Service Pack 2的使用.NET框架(2,0,50727,0)

Update: The server is XP Service Pack 2 with .NET Framework (2,0,50727,0)

推荐答案

有几个方法可以做到这一点,但每本身没有图书馆,将与C#适用于任何/所有的MP4视频文件。那是没有什么是100%可靠的。

There are a few ways to do this, but no library per-se that will work with C# for any/all .mp4 video files. That is nothing that is 100% reliable.

两者都是命令行选项(在某种意义上)。基本上,你会做所有正在运行使用的System.Diagnostics.Process ASP.NET应用程序的过程。

Both are command line options (in a sense). Basically, what you'd be doing is running a process from your ASP.NET application using System.Diagnostics.Process.

在他们的是使用的ffmpeg 。与ffmpeg的,如果你只是给它一个文件(作为命令行参数,如果将返回有关该文件的各种元数据,这些信息可以分析提取尺寸。

On of them is to use ffmpeg. With ffmpeg if you just give it a file (as a command line argument if will return various metadata about the file. This information can be parsed to extract the dimensions.

另一种方法是使用 MediaInfo 。它是一个很好的工具。但同样,你将不得不使用命令行版本(CLI版本)和pretty多给它的文件名作为命令行参数。它有一个otion生产和XML响应,因此您可以轻松地分析这个问题和其他信息,如果能提供。

The other is to use MediaInfo. It's a great tool for this. But again, you'll have to use the Command line version (CLI version) and pretty much give it the file name as a command line argument. It has an otion to produce and xml response so you can easily parse this and other information if can provide.

ffmpeg的可以转code你的视频,以及。虽然我没有看到转码从MP4的地步。 FLV?

ffmpeg can transcode your video as well. Though I don't see the point of transcoding from mp4. flv?

这篇关于我如何获得一个MP4视频文件的尺寸是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆