Convert .m4a files to .mp3 format (with tags)

A Perl utility I wrote to convert .m4a files to .mp3 format. It will also pull the tags over from m4a format. If there are no m4a tags, the script will die. (But of course you can just comment that part out.)

Here is the direct link to the script:

Note: I’ve updated the code to reflect my more current programming style. If I had time to re-do this, I’d have used IPC::Open3 or something else for IPC, instead of the system call used.

#! /usr/bin/perl
# name:
# description: Convert m4a file to mp3 format. Attempts to convert tags.
# developer: Nathan G. Marley
# date: 2011Sep10
# ========================================================================

use strict;
use warnings;
use feature qw(say);
use Carp;
use MP4::Info;
use MP3::Tag;
use Getopt::Long;

if ( !@ARGV ) {
croak("usage: $0 <...>\n");


sub main {

for my $file ( @ARGV ) {
my $m4atags = get_m4a_tags( $file );
my $mp3file = convert_m4a_2_mp3( $file );
my $rc = tag_mp3_file( $mp3file , $m4atags );



sub get_m4a_tags {
my $filename = shift;
my $taginfo;

my $tag = get_mp4tag($filename)
or carp("No TAG info");

for my $t ( @m4atags ) {
$taginfo->{ $t } = $tag->{$t};

return $taginfo;

sub convert_m4a_2_mp3 {
my $m4afile = shift;
my $mp3file;

($mp3file = $m4afile) =~ s/\.m4a$/.mp3/;

if ( -e $mp3file ) {
carp("error: MP3 file '$mp3file' already exists.");

my $faad_opts = "-q -o -";
my $lame_opts = "-S -v -V 0";
my $cmd = "faad $faad_opts \"$m4afile\" | lame $lame_opts - \"$mp3file\"";

my $rc = system($cmd) >> 8;
if ( 0 != $rc ) {
croak("error: Couldn't convert m4a file to mp3 format");

return $mp3file;

sub tag_mp3_file {
my ( $mp3file , $tags ) = (@_)[0,1];

my $mp3 = MP3::Tag->new($mp3file);

# scan file for existing tags

if (exists $mp3->{ID3v1}) {

if (exists $mp3->{ID3v2}) {

$mp3->title_set ( $tags->{TITLE} );
$mp3->artist_set( $tags->{ARTIST} );
$mp3->album_set ( $tags->{ALBUM} );
$mp3->year_set ( $tags->{YEAR} );
$mp3->genre_set ( $tags->{GENRE} );
$mp3->track_set ( $tags->{TRACKNUM} );

$mp3->update_tags(); # Commit to file


Saga of the Date Palms… Parte 1

So my wife & I have been on a date kick lately. Not the kind of dates you go on, but the kind you eat.

Since we’ve been going really green the past 3 months and now have a strong interest in self-sustainability, we’ve been trying to sprout and grow just about every seed we can get our hands on. We have a particular interest in growing seeds that came from food that we’ve eaten. There’s just something about growing & eating your own food which came from food that you ate… something about taking it full-circle that really feels empowering & let’s us know we can grow our own food without depending on others.

Anyway, after discovering “fresh” dates (not dried & pitted), I thought the date pits (aka “date seeds”, “date stones”, whatever) looked interesting and wondering if it was possible to sprout them.

It is.

Here’s the article I found on how to germinate a date seed:

We followed the steps (including using the vermiculite, which you can find at Lowe’s) and here are the results:

Germinated Date Pits

Sprouted Date Pits

The small white knobs sticking out of the middle of the pits are the sprouts. We’re going to leave them in the vermiculite for a few more days & then pot them. Meanwhile, we’ll be soaking another batch of date palm seeds for the next round.

We just got back from a weekend trip from Oklahoma and checked them, so the fact that these were sprouted came as a bit of a surprise to us. We started soaking the pits on 24th August of this year (2011) and let them soak for 24 hours. Then we started them in the vermiculite and 12 days later (6th September) these were sprouted.

Facebook account deletion link

In case anyone is looking for it:

This is the official Facebook delete account link. You can permanently delete your account by visiting this & entering your password & a (Re-)Capcha.

Be aware that it will be gone forever — this doesn’t just de-activate it. For now, there is still a 14-day grace period, so if you log back in within 14 days, the account deletion request will be cancelled.