Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
25th March 2010, 03:06 | #1 | Link |
Quality Whore
Join Date: Dec 2009
Location: Scotland
Posts: 14
|
x264 to program communication?
Hi, developing a program to convert videos (mostly bluray) to x264+flac/mp3 video/audio.
I really only have one step left and that is how to get x264 program to hide on open and send the data (frames, fps, kbits, eta) to my main program. VB.NET is preferred but C and C# are acceptable solutions. |
25th March 2010, 13:40 | #3 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
You probably don't want to use a C interface as it's much harder than .NET, you can find a sample in MSDN:
http://msdn.microsoft.com/en-us/libr...=VS.90%29.aspx A short sample using lamba subs and implicit line continuation so you need the VB.NET 2010 compiler: Code:
Dim s = Sub() Using p As New Process AddHandler p.ErrorDataReceived, Sub(sendingProcess As Object, outLine As DataReceivedEventArgs) If outLine.Data <> "" Then BeginInvoke(Sub() Text = outLine.Data) End Sub p.StartInfo.FileName = "D:\Projekte\StaxMedia\trunk\StaxRip\bin\Applications\x264\x264.exe" p.StartInfo.Arguments = "--preset fast --tune film --crf 18 --sar 16:11 --output ""D:\Video\Samples\DVD\Pulp Fiction\VTS_01_1 temp files\VTS_01_1_CompCheck.h264"" ""D:\Video\Samples\DVD\Pulp Fiction\VTS_01_1 temp files\VTS_01_1_CompCheck.avs""" p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardError = True p.StartInfo.CreateNoWindow = True p.Start() p.BeginErrorReadLine() p.WaitForExit() End Using End Sub s.BeginInvoke(Nothing, Nothing) Since it waits for the process to exit a worker thread is used to prevent the main thread to block (and the window to freeze). The handler receiving the output marshals the output back to the main thread since cross thread calls changing controls are illegal, this is also done asynchronously as it's more efficient. The compiler translates lamdas to objects so you have to be careful as object creation is slower than just calling a procedure, the event handler in the sample will be called very often.
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists Last edited by stax76; 25th March 2010 at 15:43. |
25th March 2010, 21:16 | #4 | Link | |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
Quote:
Once you have redirected all console output, you can parse the obtained text in order to extract frames, fps, kbits, eta and so on... This article is what helped me a lot to implement that properly with my applications: http://support.microsoft.com/?scid=k...90351&x=8&y=14 Here is my implementation: http://code.google.com/p/mulder/sour...RunProcess.pas (That all of course only applies if you want to use x264 as a separate console process, not if you want to use the library)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 25th March 2010 at 21:35. |
|
25th March 2010, 22:41 | #5 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
That looks slightly more difficult.
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
Tags |
communication, converter, program, vb.net, x264 |
Thread Tools | Search this Thread |
Display Modes | |
|
|