banner

check out my other open source projects here

vid2mp3

A simple command-line utility to extract audio from video files and convert it to MP3 format.

vid2mp3 is designed to be small, dependency-light, and easy to integrate into scripts, Makefiles, and automation workflows.


features

  • Convert video files to MP3
  • Supports common video formats (via ffmpeg)
  • Simple CLI interface
  • Suitable for batch processing
  • No Go runtime dependencies at execution time

requirements

  • ffmpeg must be installed and available on $PATH

Verify installation:

ffmpeg -version

installation

using go install

go install github.com/tiagomelo/vid2mp3/cmd/vid2mp3@latest

The binary will be installed into:

$(go env GOPATH)/bin

Make sure it is on your PATH:

export PATH="$(go env GOPATH)/bin:$PATH"

usage

basic usage

vid2mp3 input.mp4

This generates:

input.mp3

in the same directory.


specify output file

vid2mp3 -o output.mp3 input.mp4

batch conversion

for f in *.mp4; do
  vid2mp3 "$f"
done

examples

Convert a video downloaded from the web:

vid2mp3 lecture.mp4

Convert and rename output:

vid2mp3 -o podcast.mp3 recording.mkv

Use inside a Makefile:

extract-audio:
	vid2mp3 assets/video.mp4

how it works

Internally, vid2mp3 invokes ffmpeg with the appropriate arguments to:

  • strip video streams
  • extract audio
  • encode it as MP3

This keeps the implementation simple and reliable by relying on a proven media tool.


error handling

  • Fails fast if ffmpeg is not available
  • Propagates ffmpeg errors directly to stderr
  • Returns non-zero exit codes on failure (script-friendly)

development

run locally

go run ./cmd/vid2mp3/vid2mp3.go input.mp4

unit tests

make test

unit tests coverage report

make coverage