mono/packages/bot/scripts/extract_audio.sh
2025-08-11 12:25:45 +02:00

27 lines
539 B
Bash

7#!/bin/bash
# Check if a file has been provided
if [ $# -eq 0 ]; then
echo "Usage: $0 input_file.mp4"
exit 1
fi
# Input file
INPUT_FILE="$1"
# Check if the file exists
if [ ! -f "$INPUT_FILE" ]; then
echo "File not found!"
exit 1
fi
# Extract the basename (without extension) from the input file
BASENAME=$(basename "$INPUT_FILE" .mp4)
# Output file
OUTPUT_FILE="${BASENAME}.mp3"
# Extract audio using ffmpeg
ffmpeg -i "$INPUT_FILE" -q:a 0 -map a "$OUTPUT_FILE"
echo "Extraction complete. Output file: $OUTPUT_FILE"