illustrate
Products            Buy            Support Forum            Registrations            Professional            About           
 

Ffmpeg

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MJS61

    • May 2025
    • 2

    #1

    Ffmpeg

    Will there be an option to ever use FFMPEG instead of LAME. I have compared both and find files sound better with FFMPEG. I have created a script to use but like the convenience of dbpoweramp as I am a huge fan and a long time supporter. Here is my PowerShell script if interested to see.

    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -AssemblyName System.Drawing

    $form = New-Object System.Windows.Forms.Form
    $form.Text = "Audio Converter - Multi Format"
    $form.Size = New-Object System.Drawing.Size(750, 490)
    $form.StartPosition = "CenterScreen"
    $form.Font = New-Object System.Drawing.Font("Segoe UI", 10)
    $form.BackColor = [System.Drawing.Color]::NavajoWhite

    # Source folder controls
    $lblSrc = New-Object System.Windows.Forms.Label -Property @{ Text = "Source Folder:"; Location = '20,20'; Size = '120,24' }
    $txtSrc = New-Object System.Windows.Forms.TextBox -Property @{ Location = '150,20'; Size = '400,24' }
    $btnBrowse = New-Object System.Windows.Forms.Button -Property @{ Text = "Browse"; Location = '570,19'; Size = '100,26'; BackColor = 'LimeGreen' }

    # Output folder controls (OPTIONAL)
    $lblOut = New-Object System.Windows.Forms.Label -Property @{ Text = "Output Folder (optional):"; Location = '20,50'; Size = '170,24' }
    $txtOut = New-Object System.Windows.Forms.TextBox -Property @{ Location = '200,50'; Size = '350,24' }
    $btnOutBrowse = New-Object System.Windows.Forms.Button -Property @{ Text = "Browse"; Location = '570,49'; Size = '100,26'; BackColor = 'Gold' }

    $lblSample = New-Object System.Windows.Forms.Label -Property @{ Text = "Sample Rate:"; Location = '20,90'; Size = '120,24' }
    $comboSample = New-Object System.Windows.Forms.ComboBox -Property @{ Location = '150,90'; Size = '100,24'; DropDownStyle = 'DropDownList' }
    $comboSample.Items.AddRange(@("44100", "48000")); $comboSample.SelectedIndex = 1

    $lblBitrate = New-Object System.Windows.Forms.Label -Property @{ Text = "Bitrate:"; Location = '270,90'; Size = '60,24' }
    $comboBitrate = New-Object System.Windows.Forms.ComboBox -Property @{ Location = '340,90'; Size = '100,24'; DropDownStyle = 'DropDownList' }
    $comboBitrate.Items.AddRange(@("93k", "128k", "256k", "320k")); $comboBitrate.SelectedIndex = 3

    $chkVBR = New-Object System.Windows.Forms.CheckBox -Property @{ Text = "Use VBR"; Location = '460,90'; Size = '100,24'; Checked = $false }
    $chkMeta = New-Object System.Windows.Forms.CheckBox -Property @{ Text = "Copy Metadata"; Location = '150,120'; Size = '160,24'; Checked = $true }

    $lblFormat = New-Object System.Windows.Forms.Label -Property @{
    Text = "Output Format:"
    Location = '20, 160'
    Size = '120,24'
    Font = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Bold)
    }

    $comboFormat = New-Object System.Windows.Forms.ComboBox
    $comboFormat.Location = New-Object System.Drawing.Point(150, 160)
    $comboFormat.Size = New-Object System.Drawing.Size(210, 28)
    $comboFormat.Font = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Regular)
    $comboFormat.FlatStyle = [System.Windows.Forms.FlatStyle]::Standard
    $comboFormat.BackColor = [System.Drawing.Color]::White
    $comboFormat.ForeColor = [System.Drawing.Color]::Black
    $comboFormat.DropDownWidth = 250
    $comboFormat.Items.AddRange(@("MP3", "FLAC", "ALAC", "APE", "OGG", "OPUS", "WAV", "WMA"))
    $comboFormat.SelectedIndex = 0

    $radID3v1 = New-Object System.Windows.Forms.RadioButton -Property @{ Text = "ID3v1"; Location = '400,160'; Size = '70,24' }
    $radID3v2 = New-Object System.Windows.Forms.RadioButton -Property @{ Text = "ID3v2.3"; Location = '470,160'; Size = '90,24'; Checked = $true }

    $panel = New-Object System.Windows.Forms.Panel -Property @{ Location = '20,200'; Size = '700,170'; AutoScroll = $true; BorderStyle = 'Fixed3D' }
    $list = New-Object System.Windows.Forms.ListBox -Property @{ Dock = 'Top'; Height = 170 }
    $list.Add_SelectedIndexChanged({ $list.TopIndex = $list.Items.Count - 1 })
    $panel.Controls.Add($list)

    $btnConvert = New-Object System.Windows.Forms.Button -Property @{ Text = "Convert"; Location = '20,390'; Size = '100,34'; BackColor = 'LimeGreen' }
    $btnReset = New-Object System.Windows.Forms.Button -Property @{ Text = "Reset"; Location = '130,390'; Size = '100,34'; BackColor = 'LimeGreen' }

    $lblFooter = New-Object System.Windows.Forms.Label
    $lblFooter.Text = "Form Created By: Mark Snyder - All Rights Reserved!"
    $lblFooter.Location = New-Object System.Drawing.Point(370, 420)
    $lblFooter.Size = New-Object System.Drawing.Size(350, 18)
    $lblFooter.ForeColor = [System.Drawing.Color]::Black
    $lblFooter.Font = New-Object System.Drawing.Font("Segoe UI", 7, [System.Drawing.FontStyle]::Regular)
    $lblFooter.TextAlign = 'MiddleRight'

    $form.Controls.AddRange(@(
    $lblSrc, $txtSrc, $btnBrowse,
    $lblOut, $txtOut, $btnOutBrowse,
    $lblSample, $comboSample,
    $lblBitrate, $comboBitrate,
    $chkVBR, $chkMeta,
    $lblFormat, $comboFormat,
    $radID3v1, $radID3v2,
    $panel, $btnConvert, $btnReset,
    $lblFooter
    ))

    $fd = New-Object System.Windows.Forms.FolderBrowserDialog
    $btnBrowse.Add_Click({ if ($fd.ShowDialog() -eq 'OK') { $txtSrc.Text = $fd.SelectedPath } })

    $fdOut = New-Object System.Windows.Forms.FolderBrowserDialog
    $btnOutBrowse.Add_Click({ if ($fdOut.ShowDialog() -eq 'OK') { $txtOut.Text = $fdOut.SelectedPath } })

    $btnReset.Add_Click({ $btnConvert.Enabled = $true; $list.Items.Clear(); $list.Items.Add("Ready for another batch.") })

    function Get-FFmpeg($srcPath) {
    $tryFFmpeg = Join-Path $srcPath 'ffmpeg.exe'
    if (Test-Path $tryFFmpeg) { return $tryFFmpeg }
    $ffDlg = New-Object System.Windows.Forms.OpenFileDialog
    $ffDlg.Filter = "ffmpeg.exe|ffmpeg.exe"
    $ffDlg.Title = "Locate ffmpeg.exe"
    if ($ffDlg.ShowDialog() -eq 'OK') { return $ffDlg.FileName }
    return $null
    }

    $btnConvert.Add_Click({
    $src = $txtSrc.Text.Trim()
    $outDir = $txtOut.Text.Trim()
    if (-not (Test-Path $src)) {
    [System.Windows.Forms.MessageBox]::Show("Select a valid source folder.")
    return
    }

    # If output folder is blank, use source folder
    if (-not $outDir) { $outDir = $src }
    elseif (-not (Test-Path $outDir)) {
    [System.Windows.Forms.MessageBox]::Show("Output folder does not exist.")
    return
    }

    $ffmpegPath = Get-FFmpeg $src
    if (-not (Test-Path $ffmpegPath)) {
    [System.Windows.Forms.MessageBox]::Show("ffmpeg.exe not found.")
    return
    }

    $inputFiles = Get-ChildItem -LiteralPath $src -File | Where-Object {
    $_.Extension -match '^\.(flac|wav|m4a|aiff|ogg|ape|mp3|wma|opus)$'
    }
    if ($inputFiles.Count -eq 0) {
    $list.Items.Add("No supported audio files found.")
    return
    }

    $btnConvert.Enabled = $false
    $list.Items.Clear()
    $list.Items.Add("Converting files...")

    foreach ($f in $inputFiles) {
    $srcFile = $f.FullName
    $format = $comboFormat.SelectedItem.ToLower()
    $ext = switch ($format) {
    "mp3" { ".mp3" }
    "flac" { ".flac" }
    "alac" { ".m4a" }
    "ape" { ".ape" }
    "ogg" { ".ogg" }
    "opus" { ".opus" }
    "wav" { ".wav" }
    "wma" { ".wma" }
    }

    # Skip if file already has the output extension
    if ($f.Extension -ieq $ext) {
    $list.Items.Add("Skipped (already $ext): $($f.Name)")
    continue
    }

    $outFileName = [System.IO.Path]::GetFileNameWithoutExtension($f.Name) + $ext
    $dest = Join-Path $outDir $outFileName
    $args = @('-i', "`"$srcFile`"", '-ar', $comboSample.SelectedItem, '-ac', '2', '-vn', '-y')

    switch ($format) {
    "mp3" {
    if ($chkVBR.Checked) {
    $args += @('-qscale:a', '2')
    } else {
    $args += @('-ab', $comboBitrate.SelectedItem)
    }
    if ($radID3v2.Checked) { $args += @('-id3v2_version', '3') }
    elseif ($radID3v1.Checked) { $args += @('-write_id3v1', '1') }
    $args += @('-c:a', 'libmp3lame')
    }
    "flac" { $args += @('-c:a', 'flac') }
    "alac" { $args += @('-c:a', 'alac') }
    "ape" { $args += @('-c:a', 'ape') }
    "ogg" { $args += @('-c:a', 'libvorbis') }
    "opus" { $args += @('-c:a', 'libopus') }
    "wav" { $args += @('-c:a', 'pcm_s16le') }
    "wma" { $args += @('-c:a', 'wmav2') }
    }

    if ($chkMeta.Checked) { $args += @('-map_metadata', '0') }
    $args += "`"$dest`""

    try {
    $process = Start-Process -FilePath $ffmpegPath -ArgumentList $args -NoNewWindow -Wait -PassThru
    if ($process.ExitCode -eq 0 -and (Test-Path $dest)) {
    $kb = [math]::Round((Get-Item $dest).Length / 1KB, 1)
    $list.Items.Add("✓ Converted to $($ext): $(Split-Path $dest -Leaf) ($kb KB)")
    } else {
    $list.Items.Add("✗ Failed: $($f.Name)")
    }
    } catch {
    $list.Items.Add("✗ Exception: $($f.Name) - $_")
    }
    $list.TopIndex = $list.Items.Count - 1
    }

    $list.Items.Add("✓ All conversions complete.")
    $btnConvert.Enabled = $true
    $list.TopIndex = $list.Items.Count - 1
    })

    [void]$form.ShowDialog()
  • Spoon
    Administrator
    • Apr 2002
    • 45067

    #2
    >$args += @('-c:a', 'libmp3lame')

    FFMPEG uses Lame also.
    Spoon
    www.dbpoweramp.com

    Comment

    • MJS61

      • May 2025
      • 2

      #3
      I meant to mention that FFMPEG has encoder options to make the quality better and doesn't appear you can do that with dbpoweramp using LAME

      Comment

      • Spoon
        Administrator
        • Apr 2002
        • 45067

        #4
        Lame is lame, what options are you specifically using?
        Spoon
        www.dbpoweramp.com

        Comment

        Working...