Join many MP3, OGG, and FLAC files into one WAV or FLAC
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Join Many Mp3, Ogg, And Flac Files Into One Wav Or Flac
00:20 Accepted Answer Score 9
00:31 Answer 2 Score 4
00:42 Answer 3 Score 11
01:18 Answer 4 Score 1
02:01 Thank you
--
Full question
https://superuser.com/questions/170400/j...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #audio #mp3 #flac #ogg
#avk47
ANSWER 1
Score 11
Assuming you want to merge them alphabetically, by filename:
for f in ./*.{ogg,flac,mp3}; do echo "file '$f'" >> inputs.txt; done
ffmpeg -f concat -i inputs.txt output.wav
The for loop puts all the filenames in a file called inputs.txt, one-per-line, and the second one uses ffmpeg's concat demuxer to merge the files. It is possible to use printf instead of the loop like so:
printf "file '%s'\n" ./*.{ogg,flac,mp3} > inputs.txt
Assuming a modern shell, you can also use command substitution to do the whole thing in a single line.
ffmpeg -f concat -i <(printf "file '%s'\n" ./*.{ogg,flac,mp3}) output.wav
ACCEPTED ANSWER
Score 9
You can do this with ffmpeg
and sox
:
for i in *.mp3 *.ogg *.flac
do
ffmpeg -i "$i" "$i.wav"
done
sox *.wav combined.wav
ANSWER 3
Score 4
If you start with only lossless files, you can use use shntool:
shntool join *.flac
ANSWER 4
Score 1
It seems that the Sound Juicer that comes with Ubuntu writes broken FLAC files, which result in no MD5 signature in the file. MAKE A COPY of the directory containing the files you want to concatenate, then run the script below.
echo fixing broken FLAC files
find . -type f|grep .flac$ |while read file
do
flac -f --decode "$file" -o temp.wav
flac -f -8 temp.wav -o "$file"
done
rm temp.wav
Then runshntool join *.flac
as above.