Click here to Skip to main content
15,888,009 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi all

i want to write the program which can convert .TS file to .MP4 file by using FFMEG.exe, but I meet some problem with coding below.

1.I try to write code command into cmd.exe by give commend control into ffmeg.exe to convert .TS to .MP4 at any folder I need but I don't know how? and when it finish convert .mp4, it can auto to close the cmd screen.

2.I try to create one button click to browse my current folder where I being running the application from. I still can't find any solution about it yet.

I really hope someone can't help me about it.

What I have tried:

VB.NET
Imports System.Threading
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim FileName1 As String = System.IO.Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName) 'Get only Flie name without extension
        Dim FileName2 As String = OpenFileDialog1.FileName
        Dim programName As String = "ffmpeg.exe"

        System.Diagnostics.Process.Start(Application.StartupPath & "\" & programName)
        Process.Start("cmd.exe", "/k ffmpeg -i " & FileName2 & " -c:v libx264 " & FileName1 & ".mp4")

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim R1 As DialogResult = OpenFileDialog1.ShowDialog()
        Dim path1 As String = OpenFileDialog1.FileName 'Get part file
        Dim FileName1 As String = System.IO.Path.GetFileNameWithoutExtension(OpenFileDialog1.FileName) 'Get only Flie name without extension

        If R1 = Windows.Forms.DialogResult.OK Then
            txt1.Text = path1
        End If
        Button1.Enabled = True
        TextBox1.Text = FileName1
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Button1.Enabled = False

    End Sub

    Private Sub bFolder_Click(sender As Object, e As EventArgs) Handles bFolder.Click
        Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyComputer))
    End Sub
End Class
Posted
Updated 26-Apr-21 22:27pm
v2

In addition to Richards answer, see this CodeProject article: FFMPEG Video Converter with Progressbar VB.NET[^]

You can use the Application.StartupPath Property[^] to get the directory where your application is running.
 
Share this answer
 
v2
Comments
Mr.Kim2050 27-Apr-21 6:26am    
for this FFMPEG Video Converter with Progressbar VB.NET can convert .TS to .MP4 ?
RickZeeland 27-Apr-21 8:31am    
I never tried this project, so I can't tell, it was more to show how you can call ffmpeg. Good luck!
Mr.Kim2050 27-Apr-21 10:31am    
may i know how to write the code which i can click to browse into application which i being running in Bin\Debug folder ? i have try this code but it show only main folder or root folder only which is not point into Bin\Debug folder i need. pls help me if you know

Private Sub bFolder_Click(sender As Object, e As EventArgs) Handles bFolder.Click
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyComputer))
End Sub
You can use FolderBrowserDialog Class (System.Windows.Forms) | Microsoft Docs[^].

If you want the cmd window to close when it finishes then use the /c option.
 
Share this answer
 
Comments
Mr.Kim2050 27-Apr-21 6:17am    
can you help to write the full statement for me to see ?
Richard MacCutchan 27-Apr-21 6:19am    
Do you mean change /k to /c?
Mr.Kim2050 27-Apr-21 6:56am    
could you help me to full statement to control the cmd.exe , when it start to process to convert .TS to .MP4, let it create into any specific folder we need, example i want to create mp4 into folder name "Down" and when it finish create file, it auto close the cmd.exe


Process.Start("cmd.exe", "/k ffmpeg -i " & FileName2 & " -c:v libx264 " & FileName1 & ".mp4")
Richard MacCutchan 27-Apr-21 7:07am    
If you type the command into a simple cmd window yourself, you can see, and check, exactly what you need.
Mr.Kim2050 27-Apr-21 7:14am    
what is difference between /K and /C ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900