Sure, I can help you with that! The issue is that the find command is not correctly interpreting the output of basename when using -print0. Instead of using -print0, you can use -print and pipe the output to xargs with the -I option, like this:
find "$input_folder" -type f -name "*.flac" -print | xargs -I {} sh -c '
input_file="$0"
output_folder="$1"
output_file="${output_folder}/$(basename "${input_file%.flac}.m4a")"
ffmpeg -i "$input_file" -c:a aac -strict -2 -b:a 256k -map_metadata 0 -id3v2_version 3 -c:v copy "$output_file"
' {} "$input_folder" "$output_folder"
This should correctly pass the output of basename to xargs and create the output files in the specified directory.
Additionally, I noticed that you are using nproc to set the number of CPU cores to use. However, nproc is not a standard Linux command, and it may not be available on all systems. Instead, you can use the htop command to see the number of CPU cores, like this:
find "$input_folder" -type f -name "*.flac" -print | xargs -I {} sh -c '
input_file="$0"
output_folder="$1"
output_file="${output_folder}/$(basename "${input_file%.flac}.m4a")"
ffmpeg -i "$input_file" -c:a aac -strict -2 -b:a 256k -map_metadata 0 -id3v2_version 3 -c:v copy "$output_file"
' {} "$input_folder" "$output_folder" $(htop -p 0 | grep -c 'Core')
This will use the number of CPU cores reported by htop to set the number of parallel processes.
I hope this helps! Let me know if you have any further questions.