Tag Archives: ffmpeg

Alpine x305s vs iTunes

I recently purchased a new headunit for my car audio entertainment. The choice fell on an Alpine x305s model.
It belongs to the “media receiver” category: it can play music files from USB drives and iPods, but not CDs. It has no moving mechanic parts and therefore it’s less likely to break with intense use.

I mostly use it with a 32GB Sandisk USB Cruzer blade drive formatted as FAT32.

It works just fine and browsing the directories is really fast, even when loading thousands of files on the USB drive (the Kendwood headunit that I bought back in 2006 was much slower).

The headunit can read both MP3 and M4A/MP4/AAC-LC files. I copied my whole iTunes Library on the USB drive and tried to play it on the Alpine X305s. Unfortunately for many files I got the infamous “Unsupported file format” error.
I decided to examine these files to find out what they have in common and discover a possible common cause for the problem. It turned out that all these files had an encoding bitrate greater than 320Kbps. I searched the headunit manual and indeed the max supported bitrate for M4A files is 320Kbps.

Apparently at least half of the albums that you can buy on iTunes have a bitrate greater than 320Kbps.

If you are not tech-savvy you might just want to convert these files to MP3 using iTunes and be done with it.

If you are a true audiophile and would like to keep the files in MP4/M4A format then keep on reading.
I put together a simple bash script that you can use on MacOSX/Linux/BSD to find and convert m4a files with a bitrate greater than 320Kbps to 320Kbps.
I assume that you have ffmpeg installed on your machine. It’s available in macports, apt, yum.

TEMPFILE=”$(mktemp /tmp/temp-XXXXXXX).m4a”

if ! [ -d “$BASEDIR” ]; then
echo Syntax: $0 /path
exit 1


for i in $(find $BASEDIR -size +5M -type f -name ‘*.m4a’);do
IFS=” ”
BITRATE=$(ffmpeg -i “$i” 2>&1|grep Duration|grep bitrate|cut -d ‘ ‘ -f 8)
echo $i has bitrate $BITRATE
if [ “$BITRATE” -gt “320” ]; then
ffmpeg -v 5 -y -i “$i” -acodec libfaac -ac 2 -ab 320k \
-map_metadata 0 $TEMPFILE
mv $TEMPFILE “$i”

I recommend working on a copy of your iTunes library and not the original files.
Depending on your installed version of ffmpeg, you might need to adjust the BITRATE= line to extract the value of the bitrate from “ffmpeg -i file.m4a” output.

After running the script against the m4a files on my USB thumb drive, I was able to play all the files on my x305s!


Converting MTS video to AVI

I recently bought a Panasonic Lumix FT-1 compact camera. It’s really a great piece of equipment. It’s one of the most robust of the category: if you want to take your camera to the beach and not care about sand, water this camera is for you.

Photo quality is great, although it’s kinda slow at taking multiple pictures when compared to my other compact camera (Fujifilm Finepix F40d).

The most attractive feature of this camera is video: it can shoot videos in HD at 720p and you can even zoom while shooting. Video lenght is limited only by memory size (files are automatically split in 4GB chunks to overcome the filesystem limit).

The format used by Panasonic for HD is the same as the one used on Blu-Rays. If you want to convert it to something that any player can edit/playback, you’ll need the latest version of ffmpeg.

I checked out r19528 and compiled it with a simple:

That was it! Now copy the MTS files from the memory card to your local hard drive: they are located under the dir /AVCHD/BDMV/STREAM.

Then run:

Enjoy your newly created out.avi !