none
create an video converter with visual basic .net

Answers

  • Hi,

     I made a few of them using FFMPEG as the work horse for converting the videos and built VB form projects that control FFMPEG using a Process. You can download FFMPEG here http://ffmpeg.zeranoe.com/builds/. You can download the Static 32 or 64 bit version. You can then try out the example code below by copying the code below to a new form project and adding 3 buttons to the form. Now save the project and then you can copy the ffmpeg.exe file (from the unzipped ffmpeg folder that you downloaded) and paste it in the (Debug) folder in your VB projects folder. Now you should be able to debug (Run) the program and select a video by pressing the Open button. Then press the Convert button and select a folder and a name for the converted video to be saved. This example is only for converting to an avi format and i have only used some basic settings for converting the video so you will need to read the help documents that come with FFMPEG and do some google searching and experimenting to get use to the different commands that you can use for getting different formats, cutting video, joining video, and other things that can be done.

    Public Class Form1
        Dim InputVideo As String = ""
        Dim WithEvents proc As New Process
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Button1.Text = "Open Video"
            Button2.Text = "Convert"
            Button3.Text = "Stop"
            Button2.Enabled = False
            Button3.Enabled = False
            proc.StartInfo.FileName = System.IO.Path.Combine(Application.StartupPath, "ffmpeg.exe")
            proc.StartInfo.UseShellExecute = False
            proc.StartInfo.CreateNoWindow = True
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            proc.StartInfo.RedirectStandardInput = True
            proc.EnableRaisingEvents = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ofd As New OpenFileDialog
            ofd.Title = "Open Video"
            ofd.Multiselect = False
            ofd.Filter = "Video Files|*.flv;*.mp4;*.wmv;*.avi"
            If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
                InputVideo = ofd.FileName
                Button2.Enabled = True
            End If
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim sfd As New SaveFileDialog
            sfd.Title = "Save Video As..."
            sfd.FileName = "Untitled"
            sfd.DefaultExt = "avi"
            sfd.AddExtension = True
            If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
                Button1.Enabled = False
                Button2.Enabled = False
                Button3.Enabled = True
    
                Dim saveas As String = Chr(34) & sfd.FileName & Chr(34)
                InputVideo = "-i " & Chr(34) & InputVideo & Chr(34)
                Dim VidBitRate As String = " -b:v 1000k"
                Dim VidFrameRate As String = " -r 29.97"
                Dim AudBitRate As String = " -b:a 128k"
                Dim AudSampleRate As String = " -ar 44100"
    
                proc.StartInfo.Arguments = InputVideo & " -c:v mpeg4" & VidBitRate & VidFrameRate & " -g 300 -bf 2 -c:a libmp3lame" & AudBitRate & AudSampleRate & " -y " & saveas
                proc.Start()
            End If
        End Sub
    
        Private Sub proc_Exited(ByVal sender As Object, ByVal e As System.EventArgs) Handles proc.Exited
            MessageBox.Show("Finished converting video.")
            ReSetButtons()
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            proc.StandardInput.WriteLine("q")
            ResetButtons()
        End Sub
    
        Private Delegate Sub ResetButtonsDel()
        Private Sub ResetButtons()
            If Me.InvokeRequired Then
                Dim D As New ResetButtonsDel(AddressOf ResetButtons)
                Me.Invoke(D)
                Exit Sub
            End If
            Button1.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = False
        End Sub
    End Class

    In my converters i used comboboxes with the most common bitrates, framerates, samplerates, and other settings to be able to select the settings i want before converting. Like i say you will need to study the help documents and do a lot of experimenting to get use to using all the different command arguments for FFMPEG.


    Wednesday, August 28, 2013 11:21 PM

All replies

  • Hi

    How can i create an  video converter with visual basic.net?


    That's not a very simple thing to do since their are few if any resources for doing so on the net. Basically you need to study every video format there is and figure out how to make that data convert into another format including the audio portion of the video.

    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    Wednesday, August 28, 2013 9:37 PM
  • Hi,

     I made a few of them using FFMPEG as the work horse for converting the videos and built VB form projects that control FFMPEG using a Process. You can download FFMPEG here http://ffmpeg.zeranoe.com/builds/. You can download the Static 32 or 64 bit version. You can then try out the example code below by copying the code below to a new form project and adding 3 buttons to the form. Now save the project and then you can copy the ffmpeg.exe file (from the unzipped ffmpeg folder that you downloaded) and paste it in the (Debug) folder in your VB projects folder. Now you should be able to debug (Run) the program and select a video by pressing the Open button. Then press the Convert button and select a folder and a name for the converted video to be saved. This example is only for converting to an avi format and i have only used some basic settings for converting the video so you will need to read the help documents that come with FFMPEG and do some google searching and experimenting to get use to the different commands that you can use for getting different formats, cutting video, joining video, and other things that can be done.

    Public Class Form1
        Dim InputVideo As String = ""
        Dim WithEvents proc As New Process
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Button1.Text = "Open Video"
            Button2.Text = "Convert"
            Button3.Text = "Stop"
            Button2.Enabled = False
            Button3.Enabled = False
            proc.StartInfo.FileName = System.IO.Path.Combine(Application.StartupPath, "ffmpeg.exe")
            proc.StartInfo.UseShellExecute = False
            proc.StartInfo.CreateNoWindow = True
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            proc.StartInfo.RedirectStandardInput = True
            proc.EnableRaisingEvents = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ofd As New OpenFileDialog
            ofd.Title = "Open Video"
            ofd.Multiselect = False
            ofd.Filter = "Video Files|*.flv;*.mp4;*.wmv;*.avi"
            If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
                InputVideo = ofd.FileName
                Button2.Enabled = True
            End If
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim sfd As New SaveFileDialog
            sfd.Title = "Save Video As..."
            sfd.FileName = "Untitled"
            sfd.DefaultExt = "avi"
            sfd.AddExtension = True
            If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
                Button1.Enabled = False
                Button2.Enabled = False
                Button3.Enabled = True
    
                Dim saveas As String = Chr(34) & sfd.FileName & Chr(34)
                InputVideo = "-i " & Chr(34) & InputVideo & Chr(34)
                Dim VidBitRate As String = " -b:v 1000k"
                Dim VidFrameRate As String = " -r 29.97"
                Dim AudBitRate As String = " -b:a 128k"
                Dim AudSampleRate As String = " -ar 44100"
    
                proc.StartInfo.Arguments = InputVideo & " -c:v mpeg4" & VidBitRate & VidFrameRate & " -g 300 -bf 2 -c:a libmp3lame" & AudBitRate & AudSampleRate & " -y " & saveas
                proc.Start()
            End If
        End Sub
    
        Private Sub proc_Exited(ByVal sender As Object, ByVal e As System.EventArgs) Handles proc.Exited
            MessageBox.Show("Finished converting video.")
            ReSetButtons()
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            proc.StandardInput.WriteLine("q")
            ResetButtons()
        End Sub
    
        Private Delegate Sub ResetButtonsDel()
        Private Sub ResetButtons()
            If Me.InvokeRequired Then
                Dim D As New ResetButtonsDel(AddressOf ResetButtons)
                Me.Invoke(D)
                Exit Sub
            End If
            Button1.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = False
        End Sub
    End Class

    In my converters i used comboboxes with the most common bitrates, framerates, samplerates, and other settings to be able to select the settings i want before converting. Like i say you will need to study the help documents and do a lot of experimenting to get use to using all the different command arguments for FFMPEG.


    Wednesday, August 28, 2013 11:21 PM
  • If you are very experienced, I'd say it is possible but a big and challenging task.

    If not, take the advice of IronRazers and create a "Front End" for ffmpeg or Handbrake.

    Thursday, August 29, 2013 3:42 AM