#! /bin/sh

# (c) diffie 2026
#
# Feel free to distribute and edit this script without any restrictions.
#
# Usage: find /path/to/music -type f | audiocksum.sh --eta -j5 | tee music_dupes.$(date -I) 
#
# Use with GNU Parallel and GNU coreutils.

parallel "$@" '
	ffmpeg -loglevel 0 -i {} -f u8 fd: | xxh64sum | head -c16
	echo "" {}
' |
LC_ALL=C sort -k 1.1,1.17 --compress="gzip -1" |
uniq -w16 --all-repeated=separate |
cut -d' ' -f2-
