26 lines
865 B
Plaintext
26 lines
865 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
set -e
|
||
|
|
||
|
input="$1"
|
||
|
EXT2="m4a"
|
||
|
|
||
|
if [ -z "$AAX_ACTIVATION_BYTES" ]; then
|
||
|
echo "set AAX_ACTIVATION_BYTES env var"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
json=$(ffprobe -activation_bytes "$AAX_ACTIVATION_BYTES" -i "$input" -loglevel error -print_format json -show_format -show_chapters)
|
||
|
title=$(echo $json | jq -r ".format.tags.title")
|
||
|
count=$(echo $json | jq ".chapters | length")
|
||
|
target=$(echo $json | jq -r ".format.tags | .date + \" \" + .artist + \" - \" + .title")
|
||
|
mkdir "$target"
|
||
|
|
||
|
for i in $(seq -w 1 $count); do
|
||
|
j=$((10#$i))
|
||
|
n=$(($j - 1))
|
||
|
start=$(echo $json | jq -r ".chapters[$n].start_time")
|
||
|
end=$(echo $json | jq -r ".chapters[$n].end_time")
|
||
|
name=$(echo $json | jq -r ".chapters[$n].tags.title")
|
||
|
ffmpeg -activation_bytes "$AAX_ACTIVATION_BYTES" -i $input -ss $start -to $end -metadata title="$title $name" -vn -c:a copy "$target/$i $name.$EXT2"
|
||
|
done
|