davidrenne / nothingBurgerYourMP3s

MIT License
2 stars 1 forks source link

Get rid of Python tools. Have it all in GoLang. #2

Open allensuvorov opened 8 months ago

allensuvorov commented 8 months ago

Cool project. I got it working on a test run. Here is what I understand:

davidrenne commented 8 months ago

Yea now if we just prep exactly what that CBO python script is doing in go and pass the exact flags, it will be a great contribution. No go engineer wants python installed if they dont have to.

Plus the added benefits of just doing a go install and I will update this to accept better argument handlers and documentation for help on the arguments.

It does support flac too, so if you have a flac file or get one online to test, you basically can process one file for each test run and keep copying the file into your test directory.

Thanks Allen for the contribution, I just havent had the need to use this again lately, but its a super simple conversion and port and chat gpt is a base contributor 😉

davidrenne commented 8 months ago

The maintainer of the python abandoned his script

https://github.com/MadaooQuake/cboMP3/pull/1

It works well with setting up the ffmpeg flags.

If you wanna go over a call about his code lmk.

If you cant get this working in 2 weeks of spare time, we should re-review your coding knowledge.

I can definitely teach you a bit about maybe the channels I got going on to process 10 at a time.

Once we are done collaborating, I will add it to make it a flag as far as how many go routines are spiking your CPU processing thousands of songs concurrently.

allensuvorov commented 8 months ago

Ok, hope my dizzy %) brain is getting closer to seeing the full picture:

  1. We want to move to our Go code the functionality of cbo_mp3.py, specifically - working with the flags. And we have some great GPT prompts+results for that already.
  2. Also, as of now, cbo_mp3.py uses ffmpy to makes calls to ffmpeg to actually process the files and change bitrate. So we need to replace ffmpy as well.
  3. Plus, cbo_mp3.py uses another python dependency - mutagen. Which we also want to replace.

Basically we need to teach our Go code to make direct calls to the locally installed ffmpeg, without those 3 python dependencies:

If that's so, I could start with reviewing what it takes to make a call to ffmpeg from our Go function. Right?

Really appreciate your guidance and this opportunity for a collaboration with you. Hope after I am done nursing my cold you will also have some time and we can jump on a call.

And the fact this project is based on concurrency is also exciting.

allensuvorov commented 8 months ago

Quick update. Playing around, I got nothing Burger working with this function calling ffmpeg directly. Had to make it write to a new file name, otherwise it's pretty simple.

Just wanted to see it working without all the python libs.

func convertTo128kbps(inputFile string) error {
    inputFileName := filepath.Base(inputFile)
    outputFileName := "new_" + inputFileName
    outputFile := filepath.Join(filepath.Dir(inputFile), outputFileName)
    cmd := exec.Command("ffmpeg", "-i", inputFile, "-b:a", "128k", outputFile)
    cmd.Stdout = os.Stdout
    cmd.Stderr = os.Stderr
    err := cmd.Run()
    if err != nil {
        return fmt.Errorf("error converting file: %w", err)
    }
    return nil
}
davidrenne commented 8 months ago

Cool check chat gpt output. It's very close to what and how cbo handles it. Cbo does read the current bit rate On a file and only processes files over your desired rate. Not sure how it flags variable bit rate vs static.

Cbo does a lot more with sending different flags for flac files and there's something else too. Can remember. Read the code a bit and we can get on a discord call to review the ais code.