Hi !
I'm trying to code a little soft in C# (it's new langage for me), and i've a little problem.
In a batch script, with Mediainfo.exe to export data, like framerate, into a text file, you just have to write :
So, i've been searching on how to execute a program with parameters in C#, I found :Code:MediaInfo --inform=Video;%%FrameRate%% "video.mp4" > "framerate.txt"
So i've put :Code:System.Diagnostics.Process.Start("PROGRAM.exe", "COMMAND OPTION");
And of course, it doesn't work. Well, the window open and close very fast, and with a screenshot i've been able to see what's written, and it's good, but the part which doesn't work, is writing into the txt file.Code:System.Diagnostics.Process.Start("MediaInfo.exe", "--inform=Video;%%FrameRate%% c:/test/file.mp4 > c:/test/test.txt");
I don't know what to do to make it work. If I can't write into a txt file, I'd like to put the information in a variable
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 13 of 13
Thread
-
-
Try single percent rather than double.
-
It doesn't change anything, I think it's the ">", which is the command (in batch) to write into a txt file...
-
it doesn't work because "> c:/test/test.txt" isn't part of the command options. It is a redirection of the standard output.
"The greatest trick the Devil ever pulled was convincing the world he didn't exist." -
Is there a way to affect the value display by the execution of the program into a variable?
-
That mediainfo CLI worked for me but it can return only basic info, for example it could not return if video was progressive etc.
, so I used mediainfo.dll from Ripbot264 that can dump txt file with mediainfo listings into a tree structure, not sure where it came from, maybe it is RipBot264 author, Atak Snajpera who modified that DLL.
Code:"%mediainfo%" %1 dumpinfo:"unicodefile.txt" TYPE "unicodefile.txt" > "ascii.txt"
-
I have no clue of C#, but this looks better:
Code:System.Diagnostics.Process.Start("MediaInfo.exe", "--inform=Video;%FrameRate%" "c:/test/file.mp4" > "c:/test/test.txt");
-
that double % is ok there, otherwise it would not work, but that goes for windows batch script, no idea what is legit for C#
-
But why do you call a Batch and not mediainfo directly? What Batch code do you use?
-
a. instead of using the pipe one could specifiy an output file '--Output=file://Text.txt' , see: "mediainfo --help-output"
b. if you call it from a program there should also be a possibility to capture the command line output with your program, which would allow to avoid any temporal files
c. if you call mediainfo inside a programm you could also use the dll,... -
I don't know how to use the dll actualy... If you can show me..
I succeded to do what I wanted but it exports in txt file, it's fine for me but if I can avoid that would be great -
capturing the std:ut with C#: http://stackoverflow.com/questions/285760/how-to-spawn-a-process-and-capture-its-stdout-in-net
C# Wrapper for MediaInfo: http://www.teejeetech.in/2013/01/mediainfo-wrapper-for-net-projects.html -
First of all on my computer this works:
"MediaInfo.exe", "--inform=Video;%%FrameRate%% " "c:/test/file.mp4" > "c:/test/test.txt"
This does not
"MediaInfo.exe", "--inform=Video;%%FrameRate%% c:/test/file.mp4 > c:/test/test.txt"
Also, I just went through the exact same thing creating a program that copies the UTC Encoded date to the Created date of videos. Basically when your program calls a CLI screen, whether you keep the CMD Window open or not, it is starting a separate process and considers it finished and goes on with it's code without waiting for the output from MediaInfo. Tests showed anywhere from 2.0 to 4.5 seconds for Media Info to return information. You can see this if you open a Command window and run the command following on a folder full of videos:
C:\Users\Bud\Desktop\Holder Folder\New Holder>for %a in (*.*) do "MediaInfo.exe" "--Inform=General;Encoded Date = %Encoded_Date%\r\nTagged Date = %Tagged_Date%" "%a" > "%a.txt".
It takes a period for the information to show up and all files to be written and if your program looks for it before it is actually there, which it will, it will fail to find it. You can use the excellent method linked by Selur above or if you have problems getting WaitForExit() to work, build a delay in with a timer to 'wait' until it had finished before proceeding. By that I mean launch the CLI, finish execution until the timer times out and go get the variable or StdOut and obtain what you need.
Similar Threads
-
X264 CLI Syntax Help
By Eva-Unit01 in forum DVD RippingReplies: 9Last Post: 2nd Dec 2011, 18:42 -
CLI of BDinfo??
By RogerTango in forum Blu-ray RippingReplies: 3Last Post: 15th Oct 2011, 03:13 -
x264 CLI
By zammil in forum Video ConversionReplies: 16Last Post: 22nd Jan 2011, 12:22 -
Need help with .vob's + x264 cli
By Frost746 in forum Newbie / General discussionsReplies: 2Last Post: 20th Jul 2010, 22:14 -
CLI to XML
By eon_designs in forum Video ConversionReplies: 1Last Post: 29th Apr 2010, 11:50