CUE 引导的音频分轨
XiaO / 2023-06-06
CUE 文件编码
CUE 文件是一种用于描述数据结构和数据验证规则的配置文件格式,本质上依旧是一个文本文件,所以,有可能同样遇到编码问题。即,如果文件使用的编码格式与打开文件所用工具的编码格式不匹配,就会导致乱码。所以,应先使用编码转换工具对该 cue 文件的编码格式进行转码,防止乱码产生。
对该文件进行编码转换以后,可用任一文本编辑工具打开该文件,对所述部分进行编辑。
shntool 分轨
brew install shntool ffmpeg
在 Automator 的 Workflow 中添加如下脚本,以便快捷转换。 该脚本将音频文件转换为 flac 格式,而后使用 shntool 对 flac 文件 进行分割,将分割后的文件存储于原文件夹中。
#!/bin/bash
export PATH="/usr/local/bin:$PATH"
for f in "$@"
do
file_path=${f%/*}
file=$(basename "$f")
file_name=${file%.*}
file_extension=${file##*.}
# Changes the current directory to the directory where the input file is located using cd "$file_path"
cd "$file_path" || exit 1
if [[ "$file_extension" == "ape" ]]; then
# Convert APE to FLAC
ffmpeg -i "${file_name}.ape" "${file_name}.flac"
input_file="${file_name}.flac"
else
input_file="$f"
fi
# Split the input file into tracks
shnsplit -f "${file_name}.cue" -t "%t" "$input_file"
# Return to the previous working directory
cd - || exit 1
done
if [ -n "$file_path" ]; then
open "$file_path"
fi
具体的命令参数可参见如下,进行修改。
-t fmt Name output files in user-specified format based on CUE sheet
fields. The following formatting strings are recognized:
%p Performer
%a Album
%t Track title
%n Track number
-f file Specifies a file from which to read split point data. If not given, then split points are read from the terminal.
-o str Specify output file format extension, encoder and/or arguments.
下载安装该 Workflow,即可在服务中使用。