功能需求如上题,我们来具体的操作一下:
1.先在ubuntu上面安装FFmpeg:sudo apt install ffmpeg

2.进入有flac音频文件的目录使用下述命令:
ffmpeg -i test.FLAC -c:a libmp3lame -q:a 2 output.mp3

3.如果没有什么意外的话,你就能看到你的文件夹里面已经有转化好的mp3文件了

批量处理脚本创建一个叫:flac_to_mp3.sh的文件,放置好flac文件与设置好目录,然后保存
bash
#!/bin/bash
# 指定要转换的FLAC文件目录路径
flac_directory="/path/to/flac/files"
# 指定输出MP3文件目录路径
mp3_directory="/path/to/output/mp3/files"
# 创建输出目录(如果不存在)
mkdir -p "$mp3_directory"
# 遍历FLAC文件目录
for file in "$flac_directory"/*.flac; do
if [ -f "$file" ]; then
filename=$(basename "$file")
filename="${filename%.*}"
output_file="$mp3_directory/${filename}.mp3"
# 执行转换命令
ffmpeg -i "$file" -c:a libmp3lame -q:a 2 "$output_file"
echo "已转换 $filename"
fi
done
echo "批量转换完成"
运行脚本即可完成批量转换
