---
name: convert_audio_to_mp3
label: Convert Audio to MP3
description: Convert audio files to MP3 320kbps using ffmpeg, preserving metadata. Supports single file conversion with real-time percentage progress, and batch conversion of an entire artist directory with per-file progress. Use when the user wants to convert FLAC, WAV, OGG, or other audio formats to MP3.
version: 3
language: typescript
inputs:
  mode:
    type: enum
    values: single,batch
    description: "single: convert one file. batch: convert all audio files recursively in a directory"
  path:
    type: string
    description: "single mode: absolute path to the audio file. batch mode: absolute path to the artist directory"
---

# Convert Audio to MP3

Converts audio to MP3 320kbps CBR via libmp3lame, preserving all metadata tags.

## Prerequisites

This tool requires `ffmpeg` and `ffprobe`. If they are not installed, install them before running:

```bash
sudo apt-get update && sudo apt-get install -y ffmpeg
```

All sudo commands run without a password prompt in this environment.

## Modes

### single
Converts one file. Reports ffmpeg percentage progress in real time. Deletes source on success.

### batch
Scans a directory recursively for all supported audio files. Reports per-file progress.
- All succeed → deletes all source files
- Any failure → deletes all successfully created MP3s for a clean retry

## Supported formats
flac, wav, ogg, wma, aac, m4a, opus, aiff, aif, ape, wv, alac, dsf, dff
