This article explains how C # reads the width and height of the video. Share to everyone for your reference. The implementation method is as follows:
READ: Read using ffmpeg, so you need to download FFmpeg first. There are many online resources.
You can read out the frame height and frame width information of the video by executing a cmd command via FFmpeg.
The effect is as follows:
You can see the frame height and frame width obtained in the Blue Line box.
The next thing is easy. Construct a command, and then execute it on OK. I haven't tested all the video formats, and I'm guessing that common formats should all be supported.
The code to execute the command is as follows:
The code is as follows:
<summary>
Execute a command
</summary>
<param name= "command" > Command</param> to execute
<param name= "Output" > Outputs </param>
<param name= "error" > Error </param>
public static void ExecuteCommand (String command,out string Output,out string error)
{
Try
{
Create a process
Process PC = new process ();
Pc. startinfo.filename = command;
Pc. Startinfo.useshellexecute = false;
Pc. Startinfo.redirectstandardoutput = true;
Pc. Startinfo.redirectstandarderror = true;
Pc. Startinfo.createnowindow = true;
Start process
Pc. Start ();
Preparing to read out the output stream and error stream
String outputdata = String. Empty;
String errordata = String. Empty;
Pc. Beginoutputreadline ();
Pc. Beginerrorreadline ();
Pc. Outputdatareceived + = (ss, ee) = =
{
Outputdata + = ee. Data;
};
Pc. Errordatareceived + = (ss, ee) = =
{
ErrorData + = ee. Data;
};
Waiting to exit
Pc. WaitForExit ();
Close process
Pc. Close ();
Return stream Results
output = Outputdata;
Error = ErrorData;
}
catch (Exception)
{
output = null;
Error = NULL;
}
}
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
C # Methods for reading information such as width and height of a video
This address: http://www.paobuke.com/develop/c-develop/pbk23307.html
Related content C # dynamic types, and creation of dynamic objects, merging 2 objects, map instance C # for loop, while loop execution method LZW compression algorithm C # source C # ComboBox linkage operation (three-tier architecture)
C # implicit/Display Implementation interface methods three types of scenario analysis of C # thread synchronization in C # using a lambda expression custom comparer to implement two list merge instances process and threading details of C # Network Programming Foundation
C # Methods for reading information such as width and height of a video