Convert mp4 to mp3
Solution 1
You can use the following code to process / execute ffmpeg command in vb.net.
Dim _out As String = ""
Dim _process As New Process()
_process.StartInfo.UseShellExecute = False
_process.StartInfo.RedirectStandardInput = True
_process.StartInfo.RedirectStandardOutput = True
_process.StartInfo.RedirectStandardError = True
_process.StartInfo.CreateNoWindow = True
_process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
_process.StartInfo.FileName = "ffmpeg";
_process.StartInfo.Arguments = " -i input.mp4 -vn -f mp3 -ab 192k output.mp3";
_process.Start()
_process.StandardOutput.ReadToEnd()
_out = _process.StandardError.ReadToEnd()
_process.WaitForExit()
If Not _process.HasExited Then
_process.Kill()
End If
Return _out
In result you will receive ffmpeg output and mp3 audio file. For better encoding performance and parsing ffmpeg output i recommend using ffmpeg wrapper http://www.mediasoftpro.com/media-handler-pro.html
Solution 2
You can just start a process (System.Diagnostics.Process) and hide the ffmpeg window if needed. The console output can be redirected to a StringBuilder or similar.
For the conversion, you can use something like
ffmpeg.exe -i input.mp4 -vn -f mp3 -ab 192k output.mp3
-vn is not required if your mp4 files has no video.
Alex
I like to program in Visual Basic .NET and C# when it comes to desktop, for web i use jQuery, PHP, HTML and CSS.
Updated on June 29, 2022Comments
-
Alex almost 2 years
I am looking for some library or code that will allow me to convert mp4 video to mp3. I want it to be for free and compatible with the latest .NET framework (4).
Also, if possible, I am looking for a free ffmpeg wrapper than I can have in my vb.net application without trial or messageboxes.
If there is no free ffmpeg wrapper, can someone show me how to perform the conversion from mp4 to mp3 using command line and ffmpeg ?