Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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";

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?
Posted
Comments
[no name] 16-Jul-14 12:48pm    
http://www.ffmpeg.org/documentation.html

1 solution

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 stream StandardOutput (and StandardError) 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
 
Share this answer
 
Comments
Vlad Budeac 16-Jul-14 13:27pm    
Thank you for the answer, I read the msdn links and I know how to start the process but can you help me (posting links to older solution if exists) with the parse of the ffprobe output. I mean, how can I set label text with the right parameter?
Sergey Alexandrovich Kryukov 16-Jul-14 14:57pm    
This is something you have to do by yourself. Parsing text is more or less trivial. In this case, refer to FFProbe documentation.
—SA
Vlad Budeac 16-Jul-14 18:26pm    
I made a class following this code
http://jasonjano.wordpress.com/2010/02/09/a-simple-c-wrapper-for-ffmpeg/
but when i write in my main form
VideoClass v1 = new VideoClass(path);
lbl.text = v1.anyProp;

it doesn't work! would you know why?
Sergey Alexandrovich Kryukov 16-Jul-14 19:56pm    
And this is something you should better ask the author of that code. Your code sample doesn't tell much to me. How about writing it all by yourself? Then you would not face such problems and will be able to ask a reasonable question. The problem looks pretty simple: read FFProbe help, run it with proper command line, parse the output according to what you see in it...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900