Results 1 to 8 of 8

Thread: [RESOLVED] How to pass value from form to custom class? Please help

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Peter Porter's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    581

    Resolved [RESOLVED] How to pass value from form to custom class? Please help

    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:
    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
    Process Class:
    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 Class
    Code:
    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
    How can I pass this integer from the main form to this process class? Please help
    Last edited by Peter Porter; May 15th, 2015 at 09:00 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width