Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux convert with ffmpeg #19

Open
micheleb62 opened this issue May 16, 2023 · 1 comment
Open

linux convert with ffmpeg #19

micheleb62 opened this issue May 16, 2023 · 1 comment

Comments

@micheleb62
Copy link

hello, do you think it could work well?


#!/bin/bash

Batch convert all .mp3 files in the current directory to 432Hz with ffmpeg

Options

suffix="false" # Append the -432Hz suffix or not

oldIFS=$IFS
IFS=$'\n'
set -f # Deal with blanks and special characters in file names of the file command and in for loop

found=($(find . -name "*.mp3")) # Find the files in the current directory

IFS=$oldIFS
set +f
filename=""

for file in "${found[@]}"; do # Iterate the found files

Math:

We want to convert from 441Hz to 432Hz, the difference is 9Hz which are 2,040816327 % of 441Hz.

Parameters:

asetrate contains the desired pitch (frequency) but changes the playback speed

atempo ajusts the resulting playback speed, which should remain the same

aresample keeps the pitch change by correct rate of (re)sampling

mv "$file" "$file.tmp"

if $suffix == "true"; then
filename="${file%.mp3}-432Hz.mp3"
else
filename="$file"
fi

ffmpeg -loglevel 8 -i "$file.tmp" -af asetrate=43200,atempo=1.00,aresample=43200 "$filename"
rm "$file.tmp"
echo "Pitched $filename"
done

@mysteryx93
Copy link
Owner

something like that could work;

but you won't know the exact source pitch, and the audio conversion quality won't be as good as the converter app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants