Ffmpeg lossless audio conversion?

I have some music files that I would like to convert losslessly to ac3 for DVD output. Is it possible to do this with Ffmpeg (or Mencoder)?

AC3 is not lossless.

Welcome to BlenderArtists.

As an encoder true, but I noticed that ffmpeg has a raw ac3 format. I was hoping that it could be done that way.

What exactly do you want to do (and where does the “lossless” part come in)? Ffmpeg and mencoder (using ffmpeg) can both encode to AC3 (about two years ago the quality was said to be quite bad, don’t know about today).

Raw AC3 has nothing to do with “lossless”. It just means dumping the data stream directly into a file without putting it into a containter format. AC3 is usually placed into an MPEG container, although other container formats like Matroska can be used as well.

If that’s what you are referring to, then yes, you can do that with FFMPEG.

I guess the main thing is that I was hoping to be able to convert m4a files to ac3 files without completely destroying the audio. That’s precisely what Ffmpeg does. Well, Ffmpeg on my machine won’t even deal with m4a files, so I convert to wav, then to ac3 (that’s a different story). The output is riddled with nasty distortion. I’ve had better results going from m4a to mp2 if you can believe that.

faad -o out.wav in.m4a && ffmpeg -i out.wav -acodec ac3 -ab 384 -ar 48000 -ac 2 out.ac3

This seems to work nicely here, what version of ffmpeg are you using?

My Ffmpeg was built from subversion about 5 days ago.

64 bit Linux is having a few troubles at the moment with my current versions of both FAAC and FAAD. From your example:

“Warning: Pulse coding not allowed in short blocks”, repeated…

This is a common problem I’ve heard about in forums about 64 bit builds. And I’ve had a few compiling issues with newer versions. I haven’t really tried too hard though. I’m in the middle of a major art project, you know? The Arch Linux maintainer is looking at it now anyway.

But, m4a to wav to ac3, even at the maximum bitrate, produces what amounts to garbage.

It’s not a 64bit thing as both my faac/d and ffmpeg are. I recently switched from the svn build to s snapshot 'cos of x264 dependancies so can’t test the latest.

What do your wav files sound like, at least that way you can tell if it’s ffmpeg or faad.
You may be better off just building ffmpeg with aac support.

You should be able to just dump the audio stream by using the “-acodec copy” option to tell it to just copy the audio stream into a new container type (in this case a raw ac3) without touching it.

ffmpeg is able to open .m4a files…

Have you tried something like:
“ffmpeg -acodec copy -i audio_file.m4a new_audio_file.ac3”

Thanks everyone for taking the time on this thread.

FishB8, your solution was exactly what I thought was possible when I opened this thread. In fact it’s what I tried (every way I could think of). “ffmpeg -acodec copy -i audio_file.m4a new_audio_file.ac3” produced a file about the right size that doesn’t output sound. If I try the same setup with a wav file, it’s just misc noise; the same results I get from piping out of MPlayer. Either errors or crap.

The fact is that there is something wrong with my setup. I’ll take the time this weekend to build the newer versions of FAAC and FAAD, and see if that helps.

Hey again. I was correct about my system. I changed FAAD2 to a version from CVS, recompiled a bunch of stuff, and Ffmpeg now handles m4a files just fine. This is a known problem. It’s just that Arch Linux won’t add libraries from SVN or CVS to the official branch unless there is no other choice. Fortunately, the user repository is excellent.

I have a question: FishB8, does the above code produce a file that you can hear?