Can mp4 audio/video be converted to m4b using ffmpeg command line tool.(in vb.net)

I've spent the last few days trying various query combinations to find an answer but to no avail.

What I have found is that m4a/m4b is the same container as mp4, the difference being m4a/m4b contains no video signal.

When I tried to convert mp4 directly to m4b, I ended up with an output m4b much larger than the original mp4 and the m4b still contained video.

I am using a code example from CodeProject. I am able to convert from mp4 to mp3 and from mp3 to m4b but mp4 to m4b still contains the video portion of the file.

So, can ffmpeg input mp4 and convert it to m4b or m4a directly or is it a 2 step process, mp4 to mp3 then mp3 to m4b? If it is a 1 step process, could you point me in the direction of the documentation so I can learn how to do it.



To do this with just ffmpeg, try using -vn to not include video on output:

ffmpeg -i INPUT -c:a aac -c:b 128k -vn -f mp4 OUTPUT.m4b

This outputs just the audio of the mp4 in an m4b file.

Here's stream selection in the ffmpeg documentation.

Stream Selection

| improve this answer | |
  • Since I'm using this in code I had to make some modifications just to be able to use it. – Don6558 Jul 22 '19 at 19:12
  • Since I'm using this in code I had to make some modifications just to be able to use it. It did not work until I removed the -f and -c:a aac commands. The working line for me so far is: ffmpeg -i input -ar 22050 -b:a 56k -vn Output . This outputs a very small file of the type I specified in Output. I have yet to figure out why this iteration works and yours won't. Does it have to do with expecting multiple files/streams? I will continue to study the ffmpeg help document. Thank you very much for your help. You gave me the jumping off point I needed to start figuring this out. – Don6558 Jul 22 '19 at 19:30
  • @Don6558 Interesting, I'm certainliy not familiar with using ffmpeg in vb.net but -c:a aac is specifying the audio codec as aac which you may not need and -f mp4 is forcing the output format to the mp4/m4a/m4v family of formats. Glad I could help and at least point you in the right direction. – Naqros Jul 23 '19 at 3:17

This might be a bit late but if it helps I've got a working PowerShell script that I use to create chapterized m4b files which I am assuming you are trying to do since you list m4b.

I use the following command for mp3 format files

ffmpeg -f concat -safe 0 -i list.txt -vn -y -b:a 64k -acodec aac -ac 2 temp.m4a

If its already in AAC format (MP4) it's even simpler

ffmpeg -f concat -safe 0 -i list.txt -c copy temp.m4a

list.txt is a simple list of all the files to combine into a single m4a, 1 file per line. I found this to work much better than trying to do it using INPUT and listing all the files on the command line. That method always seemed to break for me.

Once this is done you can inject the chapters and rename to m4b all in a single command line.

ffmpeg -i "ffmetadata.txt" -i "temp.m4a" -map_metadata 1 -codec copy "$artist - $albumSanitized.m4b"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.