I have a process class that needs a fps integer from the main form. This integer changes between 24 to 30fps. I tried to pass this integer by making it publically shared on form1, but the ffmpeg process wouldn't start because it didn't recieve it. I know this is the problem because when I manually enter this integer to the process class arguments, ffmpeg starts.
Form1:
Process Class:Code:Public Class Form1 Public shared fps As Single Dim proc2 As New VideoProcess Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Record.Click fps = 30 'starts ffmpeg process for captured frames proc2.Start() End Sub
Code:Public Class VideoProcess Inherits Process Dim dir As String = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) Public Sub New() StartInfo.FileName = dir & "\" & "\Captured\ffmpeg.exe" StartInfo.Arguments = String.Format("-f image2pipe -r " & Form1.fps & " -i pipe:.bmp -pix_fmt yuv420p -c:v libx264 -crf 18 -g 1 -y -r " & Form1.fps & " " & dir & "\Captured\Temp.mp4") StartInfo.UseShellExecute = False StartInfo.WindowStyle = ProcessWindowStyle.Hidden StartInfo.RedirectStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.CreateNoWindow = True End Sub End Class
Niya gave me the idea of adding a custom property to the process class, but that also didn't work. Should've!
Code:Public Class Form1 Dim proc2 As New VideoProcess Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Record.Click 'starts ffmpeg process for captured frames proc2.FPS = 30 proc2.Start() End Sub End ClassHow can I pass this integer from the main form to this process class? Please helpCode:Public Class VideoProcess Inherits Process Dim dir As String = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) Public Property FPS As Integer Public Sub New() StartInfo.FileName = dir & "\" & "\Captured\ffmpeg.exe" StartInfo.Arguments = String.Format("-f image2pipe -r " & Me.FPS.ToString & " -i pipe:.bmp -pix_fmt yuv420p -c:v libx264 -crf 18 -g 1 -y -r " & Me.FPS.ToString & " " & dir & "\Captured\Temp.mp4") StartInfo.UseShellExecute = False StartInfo.WindowStyle = ProcessWindowStyle.Hidden StartInfo.RedirectStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.CreateNoWindow = True End Sub End Class




Reply With Quote
