commit 78f71a0fb11f6a36d264c50b733071905cdae57d Author: Sebastian Hugentobler Date: Thu Jun 22 09:43:42 2023 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..765efc1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +.DS_Store +*.pkg.tar.zst +*.pkg.tar.zst.sig diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..b58fc2a --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,22 @@ +# Maintainer: Sebastian Hugentobler + +pkgname=aax-tools +pkgver=0.1.0 +pkgrel=2 +pkgdesc="Ffmpeg incantations to get something useful from aax files." +arch=("any") +url="https://code.vanwa.ch" +license=('MIT') +depends=("ffmpeg") +source=( + "aax-to-chapter" + "aax-to-m4a" +) +sha256sums=("ff999cb350c5587824e2d513969f1d87e8879b8892716082ea9108a7347fc50a" "74018431b8838944e41afe9144cca79917ff834b0c2e100a6f9ef28c52fdf45c") + +package() { + cd "$srcdir/" + + install -Dm 755 aax-to-chapter "$pkgdir/usr/bin/aax-to-chapter" + install -Dm 755 aax-to-m4a "$pkgdir/usr/bin/aax-to-m4a" +} diff --git a/aax-to-chapter b/aax-to-chapter new file mode 100755 index 0000000..eb12e70 --- /dev/null +++ b/aax-to-chapter @@ -0,0 +1,25 @@ +#!/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 diff --git a/aax-to-m4a b/aax-to-m4a new file mode 100755 index 0000000..e2d1044 --- /dev/null +++ b/aax-to-m4a @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +set -e + +input="$1" +output="$2" +EXT="m4a" + +if [ -z "$AAX_ACTIVATION_BYTES" ]; then + echo "set AAX_ACTIVATION_BYTES env var" + exit 1 +fi + +ffmpeg -activation_bytes "$AAX_ACTIVATION_BYTES" -threads 0 -i "$input" -vn "$output.$EXT"