如何在VB.net上设置ffmpeg质量? [英] How to Set ffmpeg quality on VB.net ?

查看:129
本文介绍了如何在VB.net上设置ffmpeg质量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

i需要一些帮助。

i在 下载源代码 Visual Basic .NET中的视频转换器 [ ^ ]



i尝试将flac音频格式转换为mp3。但是,我得到一些问题。

如何设置比特率?因为输出只能是64kbps。

i想要更高一点。





这个源代码:

hello everyone.
i need some lill' help here.
i downloaded the source code in A Video Converter in Visual Basic .NET[^]

i try to convert flac audio format to mp3. but, i get some question.
how to set the bitrate quality ? because the output can just 64kbps only.
i want to try more higher.


this the source code :

Imports System.IO
Public Class Form1
    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.dlgOpen.FileName
        Dim output As String = Me.dlgSave.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 44100 -qscale " & quality & """" + output + """" 'ffmpeg commands -y replace

        '22050
        ' 
        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 = "Proses Kompresi sedang berjalan, silahkan tunggu .... "
        sr = proc.StandardError 'standard error is used by ffmpeg
        Me.btnStart.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 = "Selesai !"
        Me.lblInfo.Text = "Proses Kompresi Selesai !"
        MsgBox("Proses Kompresi Selesai ", MsgBoxStyle.Exclamation)
        Me.btnStart.Enabled = True
        Return 0
    End Function
    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        If txtOpen.Text = "" Or txtOpen.Text <> dlgOpen.FileName Then
            MsgBox("Pilih Data Audio", MsgBoxStyle.Information, "Pilih Data Audio")
            Exit Sub
        ElseIf txtSave.Text = "" Or txtSave.Text <> dlgSave.FileName Then
            MsgBox("Pilih Tempat Keluaran", MsgBoxStyle.Information, "Atur Nama dan Tujuan Keluaran")
            Exit Sub
        End If

        Dim L As Long = FileSystem.FileLen(dlgOpen.FileName)
        Dim B(0 To L - 100) As Byte
        Dim mp3() As Byte = HuffmanCoding.CompressByteArray(B)


        'FileSystem.FileOpen(1, dlgOpen.FileName & ".mp3", OpenMode.Binary, OpenAccess.Write)
        'FileSystem.FilePut(1, mp3)
        'FileSystem.FileClose(1)

        BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub dlgSave_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgSave.FileOk
        dlgSave.OverwritePrompt = True
        dlgSave.DereferenceLinks = True
        dlgSave.CreatePrompt = True
        dlgSave.DefaultExt = ".flac"
        txtSave.Text = dlgSave.FileName
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        dlgSave.ShowDialog()
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        dlgOpen.ShowDialog()
    End Sub

    Private Sub dlgOpen_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgOpen.FileOk
        dlgOpen.CheckFileExists = True
        txtOpen.Text = dlgOpen.FileName

    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        On Error GoTo handle
        BackgroundWorker1.CancelAsync()
        If btnStart.Enabled = False Then
            lblInfo.Text = ("Kompresi Dibatalkan!")
            MsgBox("Kompresi berhasil dibatalkan!", MsgBoxStyle.Exclamation)
            btnStart.Enabled = True
        Else
            MsgBox("Lakukan Kompresi Terlebih Dahulu", MsgBoxStyle.Critical)
        End If

        proc.Kill()
handle:
        Exit Sub
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        startConversion()
    End Sub

End Class







谢谢你的帮助,抱歉,如果我的英文有任何错误:D




thank you for help, sorry if any mistake in my english :D

推荐答案

代码只构建一个命令行来启动外部程序ffmpeg.exe。您所要做的就是了解ffmpeg.exe的命令行选项 [ ^ ]并调整构建命令行的代码。



实际上,这与代码无关。
The code only builds a command line to launch an external program, ffmpeg.exe. All you have to do is learn the command line options for ffmpeg.exe[^] and adjust the code that builds the command line appropriately.

Really, this has nothing to do with the code.


这篇关于如何在VB.net上设置ffmpeg质量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆