[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[abcde] Dirty first patch to support ogg+mp3 encoding in abcde.





Hi.

I have done a (very dirty) patch to support encoding of mp3 and ogg
files from the same wavs.

It does not support playlists or distributed encoding, but works.

I will clean it a bit soon.

J



-- Attached file included as plaintext by Listar --

--- abcde.orig	2002-01-28 07:56:51.000000000 +0200
+++ abcde	2002-11-27 16:07:23.000000000 +0200
@@ -221,85 +221,97 @@
 {
 	COMMENTOUTPUT="$(eval echo ${COMMENT})"
 	run_command '' echo "Tagging track $1 of $TRACKS: $TRACKNAME..."
-	if [ "$OUTPUTTYPE" = "mp3" ]; then
-		# Amazingly, id3 and id3v2 have identical -a, -A, -c, -t, and -T switches
-		# ...except id3v2's -c is completely broken (there's a bug in id3lib
-		# v3.7.x keeping -c from being properly implemented)
-		if [ "$ID3TAGV" = "2" ]; then
-			run_command tagtrack-$1 $TAGGER $TAGGEROPTS -A "$DALBUM" -a "$TRACKARTIST" \
-				-t "$TRACKNAME" -T "$1" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
-		else
-			run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
-				-A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -T "$1" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
-		fi
-	else
-		# vorbiscomment can't do in-place modification, mv the file first
-		if [ -f "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" -a ! -f "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE" ]; then
-			mv "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE"
-		fi
-		(
-		# These are from http://www.xiph.org/ogg/vorbis/doc/v-comment.html
-		echo ARTIST=$TRACKARTIST
-		echo ALBUM=$DALBUM
-		echo TITLE=$TRACKNAME
-		echo TRACKNUMBER=$1
-		if [ "$(eval echo ${COMMENT})" != "" ]; then
-			echo $DESCRIPTION=$COMMENTOUTPUT;
-		fi
-		) | run_command tagtrack-$1 $VORBISCOMMENT -w \
-			"$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
-		# Doublecheck that the commented file was created successfully before wiping the original
-		if [ -f "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" ]; then
-			rm -f "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE"
-		else
-			mv "$ABCDETEMPDIR/track$1.uncommented.$OUTPUTTYPE" "$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
-		fi
-	fi
+	for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
+	do
+		case "$OUTPUT" in
+		mp3)
+			# Amazingly, id3 and id3v2 have identical -a, -A, -c, -t, and -T switches
+			# ...except id3v2's -c is completely broken (there's a bug in id3lib
+			# v3.7.x keeping -c from being properly implemented)
+			if [ "$ID3TAGV" = "2" ]; then
+				run_command tagtrack-$1 $TAGGER $TAGGEROPTS -A "$DALBUM" -a "$TRACKARTIST" \
+					-t "$TRACKNAME" -T "$1" "$ABCDETEMPDIR/track$1.$OUTPUT"
+			else
+				run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
+					-A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -T "$1" "$ABCDETEMPDIR/track$1.$OUTPUT"
+			fi
+			;;
+		ogg)
+			# vorbiscomment can't do in-place modification, mv the file first
+			if [ -f "$ABCDETEMPDIR/track$1.$OUTPUT" -a ! -f "$ABCDETEMPDIR/track$1.uncommented.$OUTPUT" ]; then
+				mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$ABCDETEMPDIR/track$1.uncommented.$OUTPUT"
+			fi
+			(
+			# These are from http://www.xiph.org/ogg/vorbis/doc/v-comment.html
+			echo ARTIST=$TRACKARTIST
+			echo ALBUM=$DALBUM
+			echo TITLE=$TRACKNAME
+			echo TRACKNUMBER=$1
+			if [ "$(eval echo ${COMMENT})" != "" ]; then
+				echo $DESCRIPTION=$COMMENTOUTPUT;
+			fi
+			) | run_command tagtrack-$1 $VORBISCOMMENT -w \
+				"$ABCDETEMPDIR/track$1.uncommented.$OUTPUT" "$ABCDETEMPDIR/track$1.$OUTPUT"
+			# Doublecheck that the commented file was created successfully before wiping the original
+			if [ -f "$ABCDETEMPDIR/track$1.$OUTPUT" ]; then
+				rm -f "$ABCDETEMPDIR/track$1.uncommented.$OUTPUT"
+			else
+				mv "$ABCDETEMPDIR/track$1.uncommented.$OUTPUT" "$ABCDETEMPDIR/track$1.$OUTPUT"
+			fi
+			;;
+		esac
+	done
 }
 
-# do_encode [tracknumber] [hostname]
+# do_encode [tracknumber] [hostname] [outputtype]
 # If no hostname is specified, encode locally
 # variables used:
 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE
 do_encode ()
 {
+	OUTPUT=$3
 	IN="$ABCDETEMPDIR/track$1.wav"
-	OUT="$ABCDETEMPDIR/track$1.$OUTPUTTYPE"
+	OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
 	run_command '' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
-	case "$OUTPUTTYPE" in
+#	echo $@
+#	echo $OUTPUT
+#	echo $ENCODERSYNTAX
+#	echo $ENCODERSYNTAXMP3
+#	echo $ENCODERSYNTAXOGG
+	case "$3" in
 	mp3)
 		case "$2" in
 		%local*%)
-			case "$ENCODERSYNTAX" in
-			lame|gogo) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS "$IN" "$OUT" ;;
-			bladeenc) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS -quit "$IN" ;;
-			l3enc|xingmp3enc) run_command encodetrack-$1 nice $ENCNICE $ENCODER "$IN" "$OUT" $ENCODEROPTS ;;
-			mp3enc) run_command encodetrack-$1 nice $ENCNICE $ENCODER -if "$IN" -of "$OUT" $ENCODEROPTS ;;
+			case "$ENCODERSYNTAXMP3" in
+			lame|gogo) run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $ENCODERMP3 $ENCODEROPTSMP3 "$IN" "$OUT" ;;
+			bladeenc) run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $ENCODERMP3 $ENCODEROPTSMP3 -quit "$IN" ;;
+			l3enc|xingmp3enc) run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $ENCODERMP3 "$IN" "$OUT" $ENCODEROPTSMP3 ;;
+			mp3enc) run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $ENCODERMP3 -if "$IN" -of "$OUT" $ENCODEROPTSMP3 ;;
 			esac
 			;;
-		*)
-			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1
-			;;
+#		*)
+#			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTSMP3 "$2" "$IN" "$OUT" >/dev/null 2>&1
+#			;;
 		esac
 		;;
 	ogg)
 		case "$2" in
 		%local*%)
-			case "$ENCODERSYNTAX" in
-			vorbize) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS -w "$OUT" "$IN" ;;
-			oggenc) run_command encodetrack-$1 nice $ENCNICE $ENCODER $ENCODEROPTS -o "$OUT" "$IN" ;;
+			case "$ENCODERSYNTAXOGG" in
+			vorbize) run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $ENCODEROGG $ENCODEROPTSOGG -w "$OUT" "$IN" ;;
+			oggenc) run_command encodetrack-$OUTPUT-$1 nice $ENCNICE $ENCODEROGG $ENCODEROPTSOGG -o "$OUT" "$IN" ;;
 			esac
 			;;
-		*)
-			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1
-			;;
+#		*)
+#			run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1
+#			;;
 		esac
 		;;
 	esac
 	# Only remove .wav if the encoding succeeded
-	if checkerrors encodetrack-$1; then :; else
-		rm -f "$IN"
-	fi
+#	if checkerrors encodetrack-$OUTPUTTYPE-$1; then :; else
+#		rm -f "$IN"
+#	fi
 }
 
 # do_move [tracknumber]
@@ -330,7 +342,10 @@
 	OUTPUTFILEDIR=$(dirname "$OUTPUTDIR/$OUTPUTFILE")
 	# mkdir -p shouldn't return an error if the directory already exists
 	mkdir -p "$OUTPUTFILEDIR"
-	run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUTTYPE" "$OUTPUTDIR/$OUTPUTFILE"
+	for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
+	do
+		run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
+	done
 }
 
 # do_playlist
@@ -514,6 +529,7 @@
 		clean) DOCLEAN=y;;
 		esac
 	done
+
 }
 
 # do_cddbquery
@@ -889,7 +905,8 @@
 CDROMREADERSYNTAX=cdparanoia
 OUTPUTTYPE=ogg
 ENCODERSYNTAX=default
-OUTPUTFORMAT='${ARTISTFILE}/${TRACKFILE}.$OUTPUTTYPE'
+#OUTPUTFORMAT='${ARTISTFILE}/${TRACKFILE}.$OUTPUTTYPE'
+OUTPUTFORMAT='${ARTISTFILE}/${TRACKFILE}'
 VAOUTPUTFORMAT=${OUTPUTFORMAT}
 PLAYLISTFORMAT='${ARTISTFILE}_-_${ALBUMFILE}.m3u'
 PLAYLISTDATAPREFIX=''
@@ -1029,48 +1046,65 @@
 		;;
 esac
 
+# Determine what formats we want the output in, using the $OUTPUTTYPE
+# variable, and setting the following:
+OUTPUTTYPEMP3=n
+OUTPUTTYPEOGG=n
+for OUTPUTTYPES in $(echo $OUTPUTTYPE | tr , \ )
+do
+	case $OUTPUTTYPES in
+	mp3) OUTPUTTYPEMP3=y;;
+	ogg) OUTPUTTYPEOGG=y;;
+	esac
+done
+
 # If nothing has been specified, use oggenc for oggs and lame for mp3s
 if [ "$ENCODERSYNTAX" = "default" ]; then
-	if [ "$OUTPUTTYPE" = "ogg" ]; then
-		ENCODERSYNTAX=oggenc
-	else
-		ENCODERSYNTAX=lame
+	if [ "$OUTPUTTYPEOGG" = "y" ]; then
+		ENCODERSYNTAXOGG=oggenc
+	fi
+	if [ "$OUTPUTTYPEMP3" = "y" ]; then
+		ENCODERSYNTAXMP3=lame
 	fi
 fi
 
-# decide which encoder
-case "$ENCODERSYNTAX" in
+# decide which encoder for mp3
+case "$ENCODERSYNTAXMP3" in
 	lame)
-		ENCODEROPTS="$LAMEOPTS"
-		ENCODER="$LAME"
+		ENCODEROPTSMP3="$LAMEOPTS"
+		ENCODERMP3="$LAME"
 		;;
 	gogo)
-		ENCODEROPTS="$GOGOOPTS"
-		ENCODER="$GOGO"
+		ENCODEROPTSMP3="$GOGOOPTS"
+		ENCODERMP3="$GOGO"
 		;;
 	bladeenc)
-		ENCODEROPTS="$BLADEENCOPTS"
-		ENCODER="$BLADEENC"
+		ENCODEROPTSMP3="$BLADEENCOPTS"
+		ENCODERMP3="$BLADEENC"
 		;;
 	l3enc)
-		ENCODEROPTS="$L3ENCOPTS"
-		ENCODER="$L3ENC"
+		ENCODEROPTSMP3="$L3ENCOPTS"
+		ENCODERMP3="$L3ENC"
 		;;
 	xingmp3enc)
-		ENCODEROPTS="$XINGMP3ENCOPTS"
-		ENCODER="$XINGMP3ENC"
+		ENCODEROPTSMP3="$XINGMP3ENCOPTS"
+		ENCODERMP3="$XINGMP3ENC"
 		;;
 	mp3enc)
-		ENCODEROPTS="$MP3ENCOPTS"
-		ENCODER="$MP3ENC"
+		ENCODEROPTSMP3="$MP3ENCOPTS"
+		ENCODERMP3="$MP3ENC"
 		;;
+esac
+
+# decide which encoder for ogg
+case "$ENCODERSYNTAXOGG" in
 	vorbize)
-		ENCODEROPTS="$VORBIZEOPTS"
-		ENCODER="$VORBIZE"
+		ENCODEROPTSOGG="$VORBIZEOPTS"
+		ENCODEROGG="$VORBIZE"
 		;;
 	oggenc)
-		ENCODEROPTS="$OGGENCOPTS"
-		ENCODER="$OGGENC"
+		ENCODEROPTSOGG="$OGGENCOPTS"
+		ENCODEROGG="$OGGENC"
 		;;
 esac
 
@@ -1096,11 +1130,11 @@
 
 # Don't check for stuff if it's not needed
 if [ "$REMOTEHOSTS" ]; then NEEDDISTMP3=y; fi	
-if [ "$OUTPUTTYPE" = "mp3" ]; then NEEDTAGGER=y; fi
-if [ "$OUTPUTTYPE" = "ogg" ]; then NEEDCOMMENTER=y; fi
+if [ "$OUTPUTTYPEMP3" = "y" ]; then NEEDTAGGER=y; fi
+if [ "$OUTPUTTYPEOGG" = "y" ]; then NEEDCOMMENTER=y; fi
 
 # Make sure a buncha things exist
-for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $ENCODER $WGET \
+for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $ENCODERMP3 $ENCODEROGG $WGET \
 	${NEEDDISTMP3+$DISTMP3} ${NEEDCOMMENTER+$VORBISCOMMENT} seq
 do
 	# Cut off the command-line options we just added in
@@ -1255,7 +1289,13 @@
 	(
 	if [ "$DOENCODE" = "y" ]; then
 		if checkstatus readtrack-$UTRACKNUM; then
-			if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
+			if [ $OUTPUTTYPEMP3 = "y" ] ; then
+				if checkstatus encodetrack-mp3-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION mp3 ; fi
+			fi
+			if [ $OUTPUTTYPEOGG = "y" ] ; then
+				if checkstatus encodetrack-ogg-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION ogg ; fi
+			fi
+			echo encodetrack-$UTRACKNUM >> "$ABCDETEMPDIR/status"
 		fi
 	fi
 	if [ "$DOTAG" = "y" ]; then
@@ -1281,8 +1321,20 @@
 		do
 			CHECKTRACK="$(checkstatus encodetracklocation-$LOCATION)"
 			# "How can he give us a status update, if he's DEAD?"
-			if checkstatus encodetrack-$CHECKTRACK; then
-				continue
+			if [ $OUTPUTTYPEMP3 = "y" -a $OUTPUTTYPEOGG = "n" ] ; then
+				if checkstatus encodetrack-mp3-$CHECKTRACK; then
+					continue
+				fi
+			elif [ $OUTPUTTYPEOGG = "y" -a $OUTPUTTYPEMP3 = "n" ] ; then
+				if checkstatus encodetrack-ogg-$CHECKTRACK; then
+					continue
+				fi
+			else
+				if checkstatus encodetrack-ogg-$CHECKTRACK; then
+					if checkstatus encodetrack-mp3-$CHECKTRACK; then
+						continue
+					fi
+				fi
 			fi
 			# Nothing to see here please go quietly back to your homes
 			if [ -z "$CHECKTRACK" ]; then continue; fi


To unsubscribe: echo unsubscribe | mail abcde-request@whimsica.lly.org