DEV Community

Yusuf Turhan Papurcu
Yusuf Turhan Papurcu

Posted on

Transform Audio Files Bit Rate

I download music for car stereo but it’s not support 160k bit rate files. And this audio files little big (like ~700MB).

So i decided write a program for this. In short project link is here. You must add your files to “input” and double-click main. Your transformed files saved in “out”.

For long let’s code some go code and run it.

First we need ffmpeg library in Windows. You can install from here. Extract it and go bin folder. Copy “ffmpeg.exe” to project folder. And open input and out folders. Then open the main.go file. I use baisic way for this. OS/Exec is used in here.

package main

import (
    "fmt"
    "os"
    "os/exec"
    "path/filepath"
)

func main() {
    err := filepath.Walk("./input", func(path string, info os.FileInfo, err error) error {
        name := info.Name()
        cmd := exec.Command("powershell", "./ffmpeg.exe", "-i", "'./input/"+name+"'", "-b", "128k", "'./out/"+name+"'")
        if err := cmd.Run(); err != nil {
            fmt.Println("Error: ", err)
        }
        return nil
    })
    if err != nil {
        panic(err)
    }

}
Enter fullscreen mode Exit fullscreen mode

And build it with go build . Now we can publish it as a folder. Zip it and upload Google Drive.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay