#!/usr/bin/env bash
set -e # fail if there's any error
set -u
my_file=$1
my_new="$(echo $(dirname "$my_file")/$(basename "$my_file" .flac).m4a)"
echo "$my_file"
ffmpeg -y -v 0 -i "$my_file" -acodec alac "$my_new"
# only gets here if the conversion didn't fail
#rm "$my_file"
选择:
我以为我可以在一个命令中让它工作,但它不会转义特殊字符,例如[.
看起来很有希望……
#!/usr/bin/env bash
set -e # exit immediately on error
set -u # error if a variable is misspelled
while read -r my_file; do
# ./foo/bar.flac => ./foo/bar.m4a
my_new="$(dirname "$my_file")/$(basename "$my_file" .flac).m4a"
ffmpeg -i "$my_file" -acodec alac "$my_new"
# safe because of set -e, but still do a test run
#rm "$my_file"
done <<< "$(find . -type f -name '*.flac')"
好的,我可能有点快在这里问,但为了将来参考,这里是答案:
应该将标志传递
-acodec alac
给ffmpeg
FLAC 和 ALAC 之间的无损转换:ffmpeg -i track.flac -acodec alac track.m4a
而对于转换整个目录...
用法
flac-to-alac.sh
:flac-to-alac-ffmpeg.sh
:选择:
我以为我可以在一个命令中让它工作,但它不会转义特殊字符,例如
[
.看起来很有希望……