Yo everyone.
Its been a while since I posted here as i've moved away from VB for the last few months. Anyway, seen as the support is so good here, I was wondering if anybody here could help me with a small issue i'm having with ripping MP3 files out of a MP4 video using ffmpeg.
Here's my code so far, but for some reason it doesn't want to work for me
If I open up a command prompt and type:Code:Imports System.IO Public Class Form1 Dim process As New Process Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork With process.StartInfo .FileName = "ffmpeg.exe" .Arguments = "ffmpeg.exe -i " & CurDir() & "/test.mp4" & " -ab 128k " & CurDir() & "/test.mp3" ' Must be set to false in order to redirect output .UseShellExecute = False ' ffmpeg uses StandardError instead of StandardOutput .RedirectStandardError = True ' Uncomment this when code is working to hide the DOS window '.CreateNoWindow = True End With process.Start() Dim outputReader As StreamReader = process.StandardError Dim output As String While Not process.HasExited output = outputReader.ReadLine() BackgroundWorker1.ReportProgress(0, output) Threading.Thread.Sleep(500) End While End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Enable the ability to stop ffmpeg BackgroundWorker1.WorkerSupportsCancellation = True ' Lets you get ffmpeg output info BackgroundWorker1.WorkerReportsProgress = True ' Start the background worker. This method prevents form from locking BackgroundWorker1.RunWorkerAsync() End Sub Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged ' Show the output in a RichTextbox Dim output As String = e.UserState.ToString RichTextBox1.Text &= output & Environment.NewLine RichTextBox1.SelectionStart = RichTextBox1.Text.Length End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'cancel process.Kill() End Sub End Class
The conversion works fine.Code:ffmpeg.exe -i test.mp4 -ab 128k test.mp3
Quite confused with this one, and spent hours trying to get it to work.
Any help would be greatly appreciated.
If anyone would like me to upload the whole project, including "ffmpeg.exe", i'll gladly do that (The upload will be about 30mb though).
Thanks all![]()





Reply With Quote