Update 2025-04-12_09:56:11
This commit is contained in:
54
2mp3cudaRestoration.sh
Executable file
54
2mp3cudaRestoration.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# Script Version: 03
|
||||
# Description: Simple script to convert audio files to MP3 (192 kbps) using CUDA for acceleration.
|
||||
|
||||
# Set variables
|
||||
# ========
|
||||
INPUT_DIR="$(pwd)"
|
||||
OUTPUT_DIR="$INPUT_DIR/output"
|
||||
BITRATE="192k"
|
||||
|
||||
# Functions
|
||||
# ========
|
||||
convert_to_mp3() {
|
||||
local INPUT_FILE="$1"
|
||||
local OUTPUT_FILE="$2"
|
||||
|
||||
# Convert to MP3 with FFmpeg
|
||||
ffmpeg -hwaccel cuda -i "$INPUT_FILE" -c:a libmp3lame -b:a "$BITRATE" "$OUTPUT_FILE" -y || return 1
|
||||
}
|
||||
|
||||
# Main Process
|
||||
# ========
|
||||
echo "Starting audio conversion process..."
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
SUCCESS_COUNT=0
|
||||
TOTAL_COUNT=0
|
||||
|
||||
shopt -s nullglob
|
||||
for FILE in "$INPUT_DIR"/*; do
|
||||
if [[ -f "$FILE" ]]; then
|
||||
BASENAME=$(basename "$FILE")
|
||||
EXTENSION="${BASENAME##*.}"
|
||||
|
||||
# Skip unsupported extensions
|
||||
if ! [[ "$EXTENSION" =~ ^(wav|flac|opus|m4a|mp3)$ ]]; then
|
||||
echo "Skipping unsupported file: $FILE"
|
||||
continue
|
||||
fi
|
||||
|
||||
OUTPUT_FILE="$OUTPUT_DIR/${BASENAME%.*}.mp3"
|
||||
|
||||
echo "Converting $FILE to $OUTPUT_FILE"
|
||||
if convert_to_mp3 "$FILE" "$OUTPUT_FILE"; then
|
||||
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
|
||||
fi
|
||||
TOTAL_COUNT=$((TOTAL_COUNT + 1))
|
||||
fi
|
||||
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
echo "Audio conversion process completed. Success: $SUCCESS_COUNT/$TOTAL_COUNT"
|
||||
|
Reference in New Issue
Block a user