我需要一些帮助,我的代码卡住了。 所以我使用ffmpeg.exe将音频转换器flac设为mp3 我从这个源代码中获得了参考 - > converter
当我在我的代码上实现时,我收到错误。 当我点击“PictureBox3 / Mulai convert”时,ffmpeg无法启动压缩。 我的代码出了什么问题?仅供参考,我在列表框底部设置输出的位置。
这是我的来源:
Public Class LossLesstoLossy
Dim proc As New Process 'make it global so dat we can kill it from outside
Function startConversion()
Control.CheckForIllegalCrossThreadCalls = False
Dim input As String = Me.OpenFileDialog1.FileName
Dim output As String = Me.SaveFileDialog1.FileName
Dim exepath As String = Application.StartupPath + "\bin\ffmpeg.exe"
'Dim quality As Integer = TrackBar1.Value * 2
Dim startinfo As New System.Diagnostics.ProcessStartInfo
Dim sr As StreamReader
Dim cmd As String = " -i """ + input + """ -ar 22050 -qscale " & +output + """" 'ffmpeg commands -y replace
'22050
'quality & " -y """
Dim ffmpegOutput As String
' all parameters required to run the process
startinfo.FileName = exepath
startinfo.Arguments = cmd
startinfo.UseShellExecute = False
startinfo.WindowStyle = ProcessWindowStyle.Hidden
startinfo.RedirectStandardError = True
startinfo.RedirectStandardOutput = True
startinfo.CreateNoWindow = True
proc.StartInfo = startinfo
proc.Start() ' start the process
'Me.lblInfo.Text = "Conversion in progress... Please wait..."
sr = proc.StandardError 'standard error is used by ffmpeg
Me.PictureBox3.Enabled = False
Do
'If BackgroundWorker1.CancellationPending Then 'check if a cancellation request was made
'Exit Function
'End If
ffmpegOutput = sr.ReadLine
'Me.txtProgress.Text = ffmpegOutput
Loop Until proc.HasExited And ffmpegOutput = Nothing Or ffmpegOutput = ""
'Me.txtProgress.Text = "Finished !"
'Me.lblInfo.Text = "Completed!"
MsgBox("Completed!", MsgBoxStyle.Exclamation)
Me.PictureBox3.Enabled = True
Return 0
End Function
Dim paths As String()
Dim filenames As String()
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
OpenFileDialog1.Filter = "*.flac|*.flac"
If (OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then
filenames = OpenFileDialog1.FileNames
'paths = OpenFileDialog1.FileNames
For i As Integer = 0 To filenames.Length - 1
ListBox1.Items.Add(filenames(i))
Next
End If
'If
'OpenFileDialog1.CheckFileExists = True
'ListBox1.Text = OpenFileDialog1.FileName
'End If
End Sub
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
pemutarmusik.URL = ListBox1.SelectedItem
'Label2.Text = pemutarmusik.currentMedia.getItemInfo("title")
End Sub
Private Function Directory() As Object
Throw New NotImplementedException
End Function
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
If ListBox1.Text = "" Or ListBox1.Text <> OpenFileDialog1.FileName Then
MsgBox("File Audio Tidak Tersedia untuk Di Kompresi", MsgBoxStyle.Information, "Select a file")
Exit Sub
'ElseIf txtSave.Text = "" Or TextBox1.Text <> SaveFileDialog1.FileName Then
'MsgBox("Select your output filename", MsgBoxStyle.Information, "Select a file")
'Exit Sub
End If
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click
AboutBox1.ShowDialog()
End Sub
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
End Sub
Private Sub Label1_Click_1(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
bukafolder.ShowDialog()
TextBox1.Text = bukafolder.SelectedPath
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs)
End Sub
Private Sub descr_Click(sender As Object, e As EventArgs)
End Sub
Private Sub descr1_Click(sender As Object, e As EventArgs)
End Sub
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
Form2.ShowDialog()
'pemutarmusik.close()
End Sub
Private Sub mskform2(sender As Object, e As MouseEventArgs) Handles PictureBox5.MouseDown
pemutarmusik.close()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'startConversion()
End Sub
Private Sub bukafolder_HelpRequest(sender As Object, e As EventArgs) Handles bukafolder.HelpRequest
'bukafolder.OverwritePrompt = True
'bukafolder.DereferenceLinks = True
'bukafolder.CreatePrompt = True
'bukafolder.DefaultExt = ".flac"
'bukafolder.Text = dlgSave.FileName
End Sub
Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
SaveFileDialog1.OverwritePrompt = True
SaveFileDialog1.DereferenceLinks = True
SaveFileDialog1.CreatePrompt = True
SaveFileDialog1.DefaultExt = ".mp3"
TextBox1.Text = SaveFileDialog1.FileName
End Sub
Private Sub LossLesstoLossy_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub GroupBox1_Enter_1(sender As Object, e As EventArgs) Handles GroupBox1.Enter
End Sub
End Class
希望你能帮助我,我真的很懒,这个问题:(
抱歉我的源代码上有很多命令:D,我希望你能理解我的问题。
谢谢
如果你想快速编译代码,我在这里给出链接 - &gt; Audio Converter
谢谢