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.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th March 2010, 03:06   #1  |  Link
Yiu
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.
Yiu is offline   Reply With Quote
Old 25th March 2010, 12:40   #2  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
The best way is to use libx264 because you get full control.
If you don't know/want to build/link to libx264 and you are using x264.exe, please read the reference of CreateProcess on MSDN.
roozhou is offline   Reply With Quote
Old 25th March 2010, 13:40   #3  |  Link
stax76
Registered Lurker
 
Join Date: Jun 2002
Posts: 6,430
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)
It's a bit difficult to understand where and why you need asynchronous calls.
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.

Last edited by stax76; 25th March 2010 at 15:43.
stax76 is offline   Reply With Quote
Old 25th March 2010, 21:16   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,135
Quote:
Originally Posted by Yiu View Post
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.
What you need to do is redirecting the STDOUT/STDERR of x264.exe to your host application.

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)
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 25th March 2010 at 21:35.
LoRd_MuldeR is offline   Reply With Quote
Old 25th March 2010, 22:41   #5  |  Link
stax76
Registered Lurker
 
Join Date: Jun 2002
Posts: 6,430
That looks slightly more difficult.
stax76 is offline   Reply With Quote
Reply

Tags
communication, converter, program, vb.net, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:26.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.