Combine Two Audio Files with a Command Line Tool

combine two audio files with a command line tool

I don't know for sure if sox can do all that (esp start time), but I think so: http://sox.sourceforge.net/

Certainly it would be my "goto" tool for that, short of writing my own.

What is the best way to merge mp3 files?

As Thomas Owens pointed out, simply concatenating the files will leave multiple ID3 headers scattered throughout the resulting concatenated file - so the time/bitrate info will be wildly wrong.

You're going to need to use a tool which can combine the audio data for you.

mp3wrap would be ideal for this - it's designed to join together MP3 files, without needing to decode + re-encode the data (which would result in a loss of audio quality) and will also deal with the ID3 tags intelligently.

The resulting file can also be split back into its component parts using the mp3splt tool - mp3wrap adds information to the IDv3 comment to allow this.

How to overlay/downmix two audio files using ffmpeg

stereo + stereo → stereo

Normal downmix

Normal downmix

Use the amix filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amix=inputs=2:duration=longest output.mp3

Or the amerge filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amerge=inputs=2 -ac 2 output.mp3

Downmix each input into specific output channel

Downmix each input into specific output channel

Use the amerge and pan filters:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex "amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3" output.mp3

mono + mono → stereo

mono + mono → stereo

Use the join filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex join=inputs=2:channel_layout=stereo output.mp3

Or amerge:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amerge=inputs=2 output.mp3

mono + mono → mono

mono + mono → mono

Use the amix filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amix=inputs=2:duration=longest output.mp3

More info and examples

See FFmpeg Wiki: Audio Channels

How to programatically combine two aac files into one?

I created a freeware program called "Chapter and Verse" to concatenate m4a (AAC) files into a single m4b audiobook file with chapter marks and metadata.

If you have already ripped the CD's to AAC using itunes (which you say you have) then the rest is easy with my software. I wrote it for this exact reason and scenario. You can download it from www.lodensoftware.com

After trying to work with SlideShow Assembler, the QT SDK and a bunch of other command line tools, I ended up building my own application based on the publicly available MP4v2 library. The concatenating of files and adding of chapters is done using the MP4v2 library.

There are quite a few nuances in building an audiobook properly formatted for the iPod. The information is hard to find. Working with Apple documentation and open libraries has its own challenges as well.

Best of Luck.

Merge M4A files in Terminal

Yeah, ffmpeg doesn't work, contrary to what the internet echo chamber will tell you. At least not that way. It's incredible how many have to drool their wisdumb and waste everyone's time.

Here. Prove me wrong with a link, but this is what you want and this is the only place you'll see it. Tres simple.

ffmpeg -i file1.m4a -acodec copy file1.aac

ffmpeg -i file2.m4a -acodec copy file2.aac

cat file1.aac file2.aac >>filenew.aac

ffmpeg -i filenew.aac -acodec copy -bsf:a aac_adtstoasc filenew.m4a

I compiled my own ffmpeg for the extra libs, so I hope that that is one of the default ones. If not, it's definitely worth the hassle. I haven't been able to validate the above on a second system, but on my old Hardy Heron Ubuntu grunt system the joined file has all the right m4a meta data and tags and there is no change in audio quality.



Related Topics



Leave a reply



Submit