Fixing Stuttering Audio With ffmpeg and Quicktime

We’re using ffmpeg to encode videos for flash on several of the sites I’m involved with, and this usually works flawless. From time to time there’s however certain video files that makes something go wrong, usually small issues like stuttering at random places. Today I decided to go bug hunting and try to find out exactly what triggered this behaviour in one of our recent videos.

After quite a bit of debugging and re-encoding the offending video segment (which limits the rate of debug attempts, as you have to wait a couple of minutes ++ for each encode), I decided to try to simply use -acodec copy for the audio codec. The Quicktime file already used AAC as its codec, and the file we were encoding also used AAC. The stuttering disappeared! This indicates that the sound encoding of the process were to blame for the stuttering, so if you’re having a sound related problem, try to copy the input codec to the output source.

As libfaac and libfaad were the two only involved libraries of the encoding and decoding process, the first thing to try were to check if there were any new versions of these libraries available. And lo’ and behold, both libfaac and libfaad had been updated since the versions included in our ubuntu version (no real shocker there, as things in the audio and video codec world moves with a rather high velocity).

I removed the packages (sudo apt-get remove libfaac-dev libfaad-dev) from Ubuntu, downloaded the new libfaac and libfaad versions, compiled (./configure && make) and installed them (sudo make install), and then recompiled ffmpeg with the new libraries in place. ffmpeg then complained about missing, but a quick run of ldconfig (sudo ldconfig) fixed that issue.

Re-encoding the file yet again – and wooho! The offending file now works as it should. This probably also solve the issue we’ve been seeing for several other files too. The new versions of libfaac and libfaad solved the issues we were having.

BTW: There’s a small fix needed to make libfaac compile with gcc4.

iTunes out of Norway?

Apple and the Norwegian Consumer Ombudsman, Forbrukerombudet, have been complaining about each other for quite some time now. The issue that has sparked the controversy is the locked format of Apple iTunes, where music is only available for Apple’s own platform (iPod). The Consumer Ombudsman demands that music sold in the iTunes music shop are made available in a format thatcan be used freely on other devices on the market. Apple had until the 3rd of november to comply with the demands, but have responded that they will not do anything to resolve the issue (Read the letter from Apple here). This has lead the case to now move up higher into the bureaucracy, onto the desk of Markedsrådet. This instance have the right to enforce laws and any decision made here will have to be followed by Apple if they want to keep themselves in the Norwegian market.

I’ve written a bit about the market for digital distribution earlier, and while iTunes have been a great way forward for introducing people to digital purchasing of music, I think that they’d get that position regardless of their use of DRM. They’ve done a few things to loosen up their tight DRM regime, but other providers, such as Amazon, has done a much greater job.

I’m glad to see that the issue is going somewhere serious here in Norway, and I fail to see this as a great threat to the online distribution in Norway. People have made the complaint that this will just lead to Apple pulling out of Norway, leaving our quite small market to itself. If that happens, then we suddently have a large market available for other online ventures, without the threat of Apple going after their market. Imagine the music distribution market in the united states if iTunes suddently decided to stop distributing music. Amazon would laugh all the way to the bank, other ventures would pop up all over the place, and the consumer would probably be better off.

If Apple decides to remove DRM, then it suddenly becomes a viable place for purchasing digital music here in Norway for me. If Apple wins we’re in the same situation as we are today, where they don’t respect the wishes of the consumer organizations anyways.