How to encode and split an audio file in FFmpeg using asplit

1

1

I am trying to turn and split an audio file into two separate mp3 files with different qualities;

  • One at 128k
  • One at 320k

What I 've come up so far is this:

ffmpeg -i myaudiofile.wav [i1]asplit=2[o1][o2] \
-map [o1] -acodec libmp3lame -ar 48000 -ab 192k -ac 2 win1.mp3 \
-map [o2] -acodec libmp3lame -ar 48000 -ab 320k -ac 2 win2.mp3

Unfortunately this doesn't work. Any ideas?

Thanks in advance.

kstratis

Posted 2014-10-29T11:52:17.967

Reputation: 159

"Turn and split"- what does that mean? If you simply need to encode one file into 2 different qualities, consider 2 separate ffmpeg runs on the same file with different encoding parameters. – Rajib – 2014-10-29T16:07:36.750

@Rajib By saying "Turn and split" I mean convert the given wav file to mp3 format and then encode it to 2 different qualities. I just need to do it in exactly one pass. – kstratis – 2014-10-29T16:10:07.963

Answers

3

Use this:

ffmpeg -i myaudiofile.wav -filter_complex "asplit=2[o1][o2]" -map [o1] \
-acodec libmp3lame -ar 48000 -ab 192k -ac 2 win1.mp3 -map [o2] -acodec \
libmp3lame -ar 48000 -ab 320k -ac 2 win2.mp3

You need to specify filter or filter-complex and you dont need input pad because it is default and understood.

Also, note that here you are not really "turning it to mp3 and then converting to two different qualities". You are encoding into mp3 into 2 different qualities.

Rajib

Posted 2014-10-29T11:52:17.967

Reputation: 2 406

@Konos5 What would have been wrong with encoding the wav to an mp3 with one quality, and then encoding the same wav to another mp3 with different qualities? And do you realize that that is essentially what the above command does, it just processes the input data in a different order? – Jamie Hanrahan – 2015-08-15T22:17:01.853

1

Split shouldn't be required.

Use

ffmpeg -i myaudiofile.wav \
-map 0:a -acodec libmp3lame -ar 48000 -ab 192k -ac 2 win1.mp3 \
-map 0:a -acodec libmp3lame -ar 48000 -ab 320k -ac 2 win2.mp3

Gyan

Posted 2014-10-29T11:52:17.967

Reputation: 21 016