You are not logged in.

#1 2005-03-08 23:30:43

rudefyet
Member
From: Columbus, Ohio
Registered: 2004-08-04
Posts: 16

AAC/MPEG-4 support patch for abcde

I got bored to day and made up this patch for abcde that adds support for AAC using the M4A extension.

It uses FAAC as the encoder and also patches abcde to version 2.2.3

I have not tested it yet so bear with me...i'll post my test results later.

You'll have to manually add the "M4AENCOPTS=" variable to the config

usage is: abcde -o m4a

UPDATED: fixed a plethora of typos

another side note is the fact FAAC must be compiled with mpeg-4 support, the Archlinux package for FAAC isn't, so therefore this could be a problem unless you compile FAAC yourself. I submitted a feature request to get mp4 support added.

the following is the 2.2.0 to 2.2.3 update+AAC patch. I will submit a AAC patch for the newest release to the developers of abcde later on.

--- abcde-old-2.2.0    2005-03-08 12:42:14.000000000 -0500
+++ abcde2    2005-03-08 12:11:07.000000000 -0500
@@ -11,7 +11,7 @@
 # Copyright for this work is to expire January 1, 2010, after which it
 # shall be public domain.
 
-VERSION="2.2.0"
+VERSION="2.2.3"
 
 usage ()
 {
@@ -21,7 +21,7 @@
 echo "-1     Encode the whole CD in a single file"
 echo "-a <action1[,action2]...>"
 echo "       Actions to perform (cddb,read,normalize,encode,tag,move,playlist,clean)"
-echo "-A     Experimental actions (retag, transcode)"
+#echo "-A     Experimental actions (retag, transcode)"
 echo "-b     Batch mode: enable album normalization and nogap encoding"
 echo "-c <file>"
 echo "       Specify a configuration file (overrides system and user config files)"
@@ -366,6 +366,9 @@
     mpc)
         run_command tagtrack-$1 true
         ;;
+    m4a)
+        run_command tagtrack-$1 true
+        ;;
     esac
     done
 }
@@ -489,6 +492,10 @@
                 ## FIXME ## to the encoder ends up empty.
                 run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
                 ;;
+            m4a)    
+                # AAC/MPEG-4 format (.m4a) is done locally, with inline tagging.
+                run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $M4AENCODER $M4AENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" -w "$IN" -o "$OUT"
+                ;;
             esac
         done
         # Only remove .wav if the encoding succeeded
@@ -737,6 +744,9 @@
             if [ "$INTERACTIVE" = "y" ]; then
                 while [ "$DONE" != "y" ]; do
                     read ERASEPLAYLIST
+                    if [ "$ERASEPLAYLIST" = "" ]; then
+                        ERASEPLAYLIST=e
+                    fi
                     case $ERASEPLAYLIST in
                         e|E|a|A|k|K) DONE=y ;;
                         *) ;;
@@ -764,7 +774,7 @@
                 ARTISTFILE=$(mungefilename "$TRACKARTIST")
                 # If we want to start the tracks with a given number, we need to modify the
                 # TRACKNUM value before evaluation
-                if [ -n $STARTTRACKNUMBER ] ; then
+                if [ -n "$STARTTRACKNUMBER" ] ; then
                     # Get the trackpadding from the current track
                     CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
                     TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - 1 ))
@@ -843,7 +853,7 @@
                 cdparanoia|debug)
                     if [ "$WEHAVEACD" = "y" ]; then
                         vecho "Querying the CD for audio tracks..."
-                        TRACKS=$( $CDROMREADER -Q 2>&1 | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 |  awk '{print $1}' | tr -d "." | tr 'n' ' ' )
+                        TRACKS=$( $CDROMREADER -d $CDROM -Q --verbose 2>&1 | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 |  awk '{print $1}' | tr -d "." | tr 'n' ' ' )
                         CDPARANOIAAUDIOTRACKS="$TRACKS"
                     else
                         if [ -f "$ABCDETEMPDIR/status" ] && checkstatus cdparanoia-audio-tracks ; then
@@ -1354,7 +1364,7 @@
         EDITCDDB=n
     fi
     if [ "$EDITCDDB" = "y" ]; then
-        CDDBDATAMD5SUM=$($MD5SUM "$CDDBDATA" | cut -d " " -f 1);
+        CDDBDATAMD5SUM=$($MD5SUM "$CDDBDATA" | cut -d" " -f1);
         
         # Use the debian sensible-editor wrapper to pick the editor that the
         # user has requested via their $EDITOR environment variable
@@ -1387,7 +1397,7 @@
 
     # Some heuristics first. Look at Disc Title, and if it starts with
     # "Various", then we'll assume Various Artists
-    if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2 -d= | egrep -ci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then
+    if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2- -d= | egrep -ci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then
         echo "Looks like a Multi-Artist CD" >&2
         VARIOUSARTISTS=y
     else
@@ -1470,7 +1480,7 @@
     echo "variousartiststyle=$VARIOUSARTISTSTYLE" >> "$ABCDETEMPDIR/status"
 
     if [ "$EDITCDDB" = "y" ] && [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then
-        if [ $CDDBDATAMD5SUM != "" ]  && [ $CDDBDATAMD5SUM != $($MD5SUM "$CDDBDATA" | cut -d " " -f 1) ]; then
+        if [ $CDDBDATAMD5SUM != "" ]  && [ $CDDBDATAMD5SUM != $($MD5SUM "$CDDBDATA" | cut -d" " -f1) ]; then
             # This works but does not have the necessary error checking
             # yet. If you are familiar with the CDDB spec
             # (see http://www.freedb.org/src/latest/DBFORMAT) 
@@ -1577,7 +1587,7 @@
     WAVDATA="$ABCDETEMPDIR/track$UTRACKNUM.wav"
     OUTDATA="$ABCDETEMPDIR/track$UTRACKNUM.$OUTPUTTYPE"
     if [ -r "$CDDBDATA" ]; then
-        TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d [:cntrl:])
+        TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2- -d= | tr -d [:cntrl:])
         echo "Grabbing track $UTRACKNUM: $TRACKNAME..." >&2
     else
         echo "Grabbing track $UTRACKNUM..." >&2
@@ -1692,6 +1702,7 @@
 SPEEXENCODERSYNTAX=default
 MPPENCODERSYNTAX=default
 NORMALIZERSYNTAX=default
+M4AENCODERSYNTAX=default
 
 OUTPUTFORMAT='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
 # Use the following VAOUTPUTFORMAT to revert to 2.0.x VA format:
@@ -1738,6 +1749,7 @@
 SPEEXENC=speexenc
 # mpp (Musepack)
 MPPENC=mppenc
+M4AENC=faac
 
 ID3=id3
 ID3V2=id3v2
@@ -1773,6 +1785,7 @@
 SPEEXENCOPTS=
 # mpc
 MPPENCOPTS=
+M4AENCOPTS=
 
 ID3OPTS=
 ID3V2OPTS=
@@ -2039,6 +2052,7 @@
                 ;;
         spx) [ "$SPEEXENCODERSYNTAX" = "default" ] && SPEEXENCODERSYNTAX=speexenc ;;
         mpc) [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc ;;
+        m4a) [ "$M4AENCODERSYNTAX" = "default" ] && M4AENCODERSYNTAX=faac ;;
         *) echo "abcde error: Invalid OUTPUTTYPE defined" >&2
            exit 1
            ;;
@@ -2100,6 +2114,12 @@
         MPPENCODER="$MPPENC"
         ;;
 esac
+case "$M4AENCODERSYNTAX" in
+    faac)
+        M4AENCODEROPTS="$M4AENCOPTS"
+        M4AENCODER="$M4AENC"
+        ;;
+esac
 
 # and which tagger
 
@@ -2144,7 +2164,7 @@
     ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} 
     ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} 
     ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} 
-    ${NEEDVORBISGAIN+$VORBISGAIN}
+    ${NEEDVORBISGAIN+$VORBISGAIN} $M4AENCODER 
 do
     # Cut off the command-line options we just added in
     X=$(echo $X | cut -d' ' -f2)
@@ -2207,37 +2227,6 @@
     esac
 fi
 
-if [ "$STRIPDATATRACKS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
-    case "$CDROMREADERSYNTAX" in
-        cdparanoia|debug) 
-            # cdparanoia can query the CD, so let's process the TRACKQUEUE list with the results.
-            if checkstatus cdparanoia-audio-tracks; then
-                CDTRACKQUEUE=$( cat $ABCDETEMPDIR/cdparanoia-audio-tracks )
-            else
-                ## FIXME ##
-                vecho "Querying the CD to obtain a list of valid audio tracks..."
-                $CDROMREADER -Q > $ABCDETEMPDIR/cdparanoia-query 2>&1
-                # Obtain a list of valid audio tracks from the results of the query
-                CDTRACKQUEUE=$( cat $ABCDETEMPDIR/cdparanoia-query | egrep '^[[:space:]]+[[:digit:]]' | awk '{print $1}' | tr -d "." | tr 'n' ' ' )
-            fi
-            # Obtain the track padding value from the before-processing list and pad the CD list
-            TRACKNUMPADDING=$( echo $TRACKQUEUE | awk '{print $1}' | tr -d " n" | wc -c )
-            for TRACK in $CDTRACKQUEUE ; do
-                TRACKNUM=$(printf %0.${TRACKNUMPADDING}d $(expr ${TRACK} + 0 ))
-                PADNEWTRACKQUEUE=$(echo $PADNEWTRACKQUEUE $TRACKNUM)
-            done
-            CDTRACKQUEUE=$PADNEWTRACKQUEUE
-            # Now, compare if the values in the list are valid tracks in the CD
-            for TRACK in $TRACKQUEUE; do
-                if echo $CDTRACKQUEUE | grep $TRACK >/dev/null ; then
-                    NEWTRACKQUEUE="$NEWTRACKQUEUE $TRACK"
-                fi
-            done
-            TRACKQUEUE="$NEWTRACKQUEUE"
-        ;;
-    esac
-fi
-
 # Create playlist if needed (backgroundable) and start reading in tracks
 
 (
@@ -2446,7 +2435,7 @@
 #            TRACKNUM=$(printf %0.${TRACKNUMPADDING}d $(expr ${UTRACKNUM} + 0))
             TRACKNUM=$UTRACKNUM
                 CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
-            TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d [:cntrl:] | sed 's/ +$//')
+            TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d [:cntrl:] | sed 's/ +$//')
             splitvarious
         fi
     fi

the patches can also be found here http://www2.rudefyet.com:8080/patch

please post any other issues you have


Compaq R3000Z + Arch = Secks

Offline

#2 2005-03-08 23:57:43

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,366
Website

Re: AAC/MPEG-4 support patch for abcde

very nice! do the abcde-devs know about it?


The impossible missions are the only ones which succeed.

Offline

#3 2005-03-09 00:38:06

rudefyet
Member
From: Columbus, Ohio
Registered: 2004-08-04
Posts: 16

Re: AAC/MPEG-4 support patch for abcde

not yet, i'm going to work all the kinks out before i submit it

as of right now I noticed some major typos, on my part, that cause it to fail...i'm working on that right now


Compaq R3000Z + Arch = Secks

Offline

Board footer

Powered by FluxBB