你好我需要一些使用Ffmpeg的说法,我想要一个代码来获取媒体文件信息 [英] Hello I Need A Some Istructions To Use Ffmpeg, I Would Like A Code To Get Media File Info
本文介绍了你好我需要一些使用Ffmpeg的说法,我想要一个代码来获取媒体文件信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var player = new WindowsMediaPlayer();
var clip = player.newMedia(file.FullName);
lblLenght_.Text = (TimeSpan.FromSeconds(clip.duration)).ToString();
ShellFile shellFile = ShellFile.FromFilePath(file.FullName);
lblFPS_.Text = (shellFile.Properties.System.Video.FrameRate.Value / 1000).ToString();
lblHeight_.Text = shellFile.Properties.System.Video.FrameHeight.Value.ToString() + " px";
lblWidth_.Text = shellFile.Properties.System.Video.FrameWidth.Value.ToString() + " px";
lblResolution_.Text = shellFile.Properties.System.Video.FrameWidth.Value.ToString() + "x" + shellFile.Properties.System.Video.FrameHeight.Value.ToString() + " px";
blBitrate_.Text = (shellFile.Properties.System.Video.TotalBitrate.Value / 1000).ToString() + " kb/s";
但问题是ShellFile仅支持几种格式,所以我发现了一些FFMPEG或ffprobe用途,但我不知道如何使用它。有人可以发布解决方案或一些链接来学习如何使用它来解决我的问题吗?
but the problem is that ShellFile supports only a few formats, so I found some FFMPEG or ffprobe uses but I don't know how to work with it. Can someone post the solution or some link to learn how to use it about my problem?
推荐答案
做简单的步骤,不要看FFMPeg应用程序,而是在FFProbe。您可以随时下载其源代码并查看其功能。然后,您可以使用适当的命令行参数将FFProbe作为单独的进程启动,重定向其输出流StandardOutput
(以及StandardError
)并使用您的应用程序进行选择。
或者,使用FFMpeg / Libavcodec库在您的过程中执行此操作。然后,您可能需要使用P / Invoke或C ++ / CLI。您可以使用一些可用的.NET包装器。
请参阅:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs .110%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput(v = vs.110)的.aspx [ ^ ](参见本页代码示例),
http://msdn.microsoft.com/en-us/library/system.diagnostics.proc ess.standarderror(v = vs.110).aspx [ ^ ]。
另请参阅我过去使用FFMpeg和.NET包装器,以及P / Invoke或C ++ / CLI的使用:
如何在C#中将图像转换为视频 [ ^ ],
HTML5和Mime,流式传输视频? [ ^ ],
如何使用Directshow修剪视频!? [ ^ ]。
-SA
Do on simple step, look not at FFMPeg application, but at FFProbe. You can always download its source code and see what it does. Then, you can either start FFProbe as a separate process with appropriate command-line parameters, redirect its output streamStandardOutput
(andStandardError
) and pick it up with your applications.
Alternatively, use FFMpeg/Libavcodec library to do it in your process. Then you may need to use P/Invoke or C++/CLI. You can use some of available .NET wrappers.
Please see:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput(v=vs.110).aspx[^] (see the code sample on this page),
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror(v=vs.110).aspx[^].
See also my past answers on using FFMpeg and the .NET wrappers, and the use of P/Invoke or C++/CLI:
how to convert image to video in C#[^],
HTML5 and Mime, Streaming a video?[^],
How to trim the video using Directshow!?[^].
—SA
这篇关于你好我需要一些使用Ffmpeg的说法,我想要一个代码来获取媒体文件信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文