From 147e24a59067556340ad6993ce92d25b7a6e0eb6 Mon Sep 17 00:00:00 2001 From: "andrew@andrews-corner.org" Date: Fri, 14 Dec 2012 12:06:15 +0000 Subject: [PATCH] Adds opus encoding support, thanks to Tomasz Golinski for the patch. Closes issue 70. git-svn-id: http://abcde.googlecode.com/svn/trunk@374 a0fa61bc-5347-0410-a1a9-7f54aa4e1825 --- abcde | 70 +++++++++++++++++++++++++++++++++++++++++++++++--- abcde.1 | 38 +++++++++++++++------------ abcde.conf | 11 ++++++-- changelog | 2 ++ debian/control | 2 +- 5 files changed, 100 insertions(+), 23 deletions(-) diff --git a/abcde b/abcde index 5993b05..d0585f6 100755 --- a/abcde +++ b/abcde @@ -51,7 +51,7 @@ echo "-m Modify playlist to include CRLF endings, to comply with some player echo "-n No lookup. Don't query CDDB, just create and use template" echo "-N Noninteractive. Never prompt for anything" echo "-o " -echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis" +echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a,opus). Defaults to vorbis" echo "-p Pad track numbers with 0's (if less than 10 tracks)" echo "-P Use UNIX pipes to read+encode without wav files" echo "-q " @@ -515,6 +515,9 @@ do_replaygain() vorbis|ogg) OUTPUT=$OGGOUTPUTCONTAINER ;; + opus) + OUTPUT=$OPUSOUTPUTCONTAINER + ;; flac) OUTPUT=$FLACOUTPUTCONTAINER ;; @@ -898,6 +901,10 @@ do_tag () ;; esac ;; + opus) + run_command tagtrack-$OUTPUT-$1 true + ;; + flac) ( echo ARTIST="$TRACKARTIST" @@ -1018,6 +1025,9 @@ do_encode () vorbis|ogg) TEMPARG="PIPE_$OGGENCODERSYNTAX" ;; + opus) + TEMPARG="PIPE_$OPUSENCODERSYNTAX" + ;; flac) TEMPARG="PIPE_$FLACENCODERSYNTAX" ;; @@ -1060,6 +1070,9 @@ do_encode () vorbis|ogg) OUTPUT=$OGGOUTPUTCONTAINER ;; + opus) + OUTPUT=$OPUSOUTPUTCONTAINER + ;; flac) OUTPUT=$FLACOUTPUTCONTAINER ;; @@ -1115,6 +1128,32 @@ do_encode () ;; esac ;; + opus) + case "$2" in + %local*%) + case "$OPUSENCODERSYNTAX" in + opusenc) + + if [ "$(eval echo ${COMMENT})" != "" ]; then + case "$COMMENT" in + *=*) ;; + *) COMMENT="COMMENT=$COMMENT" ;; + esac + fi + # Tag the file at encode time, as it can't be done after encoding. + if [ "$DOTAG" = "y" ]; then + $RUN_COMMAND nice $EFFECTIVE_NICE $OPUSENCODER $OPUSENCODEROPTS --artist "$TRACKARTIST" --comment album="$DALBUM" --title "$TRACKNAME" --comment track="$1" --comment genre="$CDGENRE" --comment year="$CDYEAR" ${COMMENT:+--comment "$COMMENT"} "$IN" "$OUT" + else + $RUN_COMMAND nice $EFFECTIVE_NICE $OPUSENCODER $OPUSENCODEROPTS "$IN" "$OUT" + fi + ;; + esac + ;; + *) + $RUN_COMMAND nice $DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1 + ;; + esac + ;; flac) case "$2" in %local*%) @@ -1397,6 +1436,9 @@ do_move () vorbis|ogg) OUTPUT=$OGGOUTPUTCONTAINER ;; + opus) + OUTPUT=$OPUSOUTPUTCONTAINER + ;; flac) OUTPUT=$FLACOUTPUTCONTAINER ;; @@ -1478,6 +1520,9 @@ do_playlist () vorbis|ogg) OUTPUT=$OGGOUTPUTCONTAINER ;; + opus) + OUTPUT=$OPUSOUTPUTCONTAINER + ;; flac) OUTPUT=$FLACOUTPUTCONTAINER ;; @@ -3149,6 +3194,7 @@ ENCODERSYNTAX=default MP3ENCODERSYNTAX=default OGGENCODERSYNTAX=default +OPUSENCODERSYNTAX=default FLACENCODERSYNTAX=default SPEEXENCODERSYNTAX=default MPCENCODERSYNTAX=default @@ -3199,6 +3245,8 @@ MP3ENC=mp3enc # ogg VORBIZE=vorbize OGGENC=oggenc +#opus +OPUSENC=opusenc # flac FLAC=flac # speex @@ -3249,6 +3297,8 @@ MP3GAINOPTS="-a -k" VORBIZEOPTS= OGGENCOPTS= VORBISGAINOPTS="--album" +#opus +OPUSENCOPTS= # flac FLACOPTS= FLACGAINOPTS="--add-replay-gain" @@ -3285,7 +3335,7 @@ ACTIONS=cddb,read,encode,tag,move,clean # This option is basically for Debian package dependencies: # List of preferred outputs - by default, run with whatever we have in the path -DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeenc,spx:speex,m4a:faac +DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeenc,spx:speex,m4a:faac:opus # List of preferred cdromreaders - by default, run whichever we have in the path DEFAULT_CDROMREADERS="cdparanoia icedax cdda2wav" @@ -3730,6 +3780,7 @@ if echo "$OUTPUTTYPE" | grep ":" > /dev/null 2>&1 ; then for OUTPUT in "$(echo "$OUTPUTTYPE" | tr \ \|| tr , \ | tr \| \ )"; do case "$OUTPUT" in vorbis:*|ogg:*) OGGENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; + opus:*) OPUSENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; mp3:*) MP3ENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; flac:*) FLACENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; spx:*) SPEEXENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; @@ -3757,6 +3808,10 @@ do [ "$DOREPLAYGAIN" = "y" ] && NEEDVORBISGAIN=y OGGOUTPUTCONTAINER=ogg ;; + opus) + [ "$OPUSENCODERSYNTAX" = "default" ] && OPUSENCODERSYNTAX=opusenc + OPUSOUTPUTCONTAINER=opus + ;; mp3) [ "$MP3ENCODERSYNTAX" = "default" ] && MP3ENCODERSYNTAX=lame [ "$DOTAG" = "y" ] && NEEDTAGGER=y @@ -3833,6 +3888,12 @@ case "$OGGENCODERSYNTAX" in OGGENCODER="$OGGENC" ;; esac +case "$OPUSENCODERSYNTAX" in + opusenc) + OPUSENCODEROPTS="${OPUSENCODEROPTSCLI:-$OPUSENCOPTS}" + OPUSENCODER="$OPUSENC" + ;; +esac case "$FLACENCODERSYNTAX" in flac) FLACENCODEROPTS="${FLACENCODEROPTSCLI:-$FLACOPTS}" @@ -3965,6 +4026,7 @@ PIPERIPPER_flac="-c " PIPE_lame="-" PIPE_bladeenc="-" PIPE_oggenc="-" +PIPE_opusenc="-" PIPE_flac="-" # Figure out if we can use pipes with the ripper/encoder combination @@ -3976,6 +4038,8 @@ if [ "$USEPIPES" = "y" ]; then PIPEENCODERSVARCHECK="PIPE_$MP3ENCODERSYNTAX" ;; vorbis|ogg) PIPEENCODERSVARCHECK="PIPE_$OGGENCODERSYNTAX" ;; + opus) + PIPEENCODERSVARCHECK="PIPE_$OPUSENCODERSYNTAX" ;; flac) PIPEENCODERSVARCHECK="PIPE_$FLACENCODERSYNTAX" ;; spx) @@ -4003,7 +4067,7 @@ fi # Make sure a buncha things exist for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \ - $OGGENCODER $FLACENCODER $SPEEXENCODER $MPCENCODER \ + $OGGENCODER $OPUSENCODER $FLACENCODER $SPEEXENCODER $MPCENCODER \ $AACENCODER $CDDBTOOL \ ${NEEDATOMICPARSLEY+$ATOMICPARSLEY} \ ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \ diff --git a/abcde.1 b/abcde.1 index 5d67311..a7679a7 100644 --- a/abcde.1 +++ b/abcde.1 @@ -10,7 +10,7 @@ tagging or commenting it, is very involved. .BR abcde is designed to automate this. It will take an entire CD and convert it into a compressed audio format - Ogg/Vorbis, MPEG Audio Layer III, Free Lossless -Audio Codec (FLAC), Ogg/Speex, MPP/MP+(Musepack) and/or M4A (AAC) format(s). +Audio Codec (FLAC), Ogg/Speex, MPP/MP+(Musepack), M4A (AAC) or Opus format(s). With one command, it will: .TP .B * @@ -23,7 +23,7 @@ Grab an audio track (or all the audio CD tracks) from your CD Normalize the volume of the individual file (or the album as a single unit) .TP .B * -Compress to Ogg/Vorbis, MP3, FLAC, Ogg/Speex, MPP/MP+(Musepack) and/or M4A format(s), all in one CD read +Compress to Ogg/Vorbis, MP3, FLAC, Ogg/Speex, MPP/MP+(Musepack), M4A and/or Opus format(s), all in one CD read .TP .B * Comment or ID3/ID3v2 tag @@ -136,8 +136,8 @@ Non interactive mode. Do not ask anything from the user. Just go ahead. .TP .B \-o [filetype][:filetypeoptions] Select output type. Can be "vorbis" (or "ogg"), "mp3", "flac", "spx", "mpc", -"m4a" or "wav". Specify a comma-delimited list of output types to obtain all -specified types. See the OUTPUTTYPE configuration variable. One can pass +"m4a", "wav" or "opus". Specify a comma-delimited list of output types to obtain +all specified types. See the OUTPUTTYPE configuration variable. One can pass options to the encoder for a specific filetype on the command line separating them with a colon. The options must be escaped with double-quotes. .TP @@ -214,11 +214,11 @@ A list of tracks you want \fBabcde\fR to process. If this isn't specified, \fBab will process the entire CD. Accepts ranges of track numbers - "abcde 1-5 7 9" will process tracks 1, 2, 3, 4, 5, 7, and 9. .SH OUTPUT -Each track is, by default, placed in a separate file named after the track -in a subdirectory named after the artist under the current directory. -This can be modified using the OUTPUTFORMAT and VAOUTPUTFORMAT -variables in your \fIabcde.conf\fR. Each file is given an extension identifying -its compression format, 'vorbis' for '.ogg', '.mp3', '.flac', '.spx', '.mpc', '.aac' or '.wav'. +Each track is, by default, placed in a separate file named after the track in a +subdirectory named after the artist under the current directory. This can be +modified using the OUTPUTFORMAT and VAOUTPUTFORMAT variables in your +\fIabcde.conf\fR. Each file is given an extension identifying its compression +format, 'vorbis' for '.ogg', '.mp3', '.flac', '.spx', '.mpc', '.aac', '.wav' or '.opus'. .SH CONFIGURATION \fBabcde\fR sources two configuration files on startup - \fI/etc/abcde.conf\fR and \fI$HOME/.abcde.conf\fR, in that order. @@ -321,6 +321,10 @@ point we only have \'mpcenc\' available, from musepack.net. Specifies the style of encoder to use for M4A (AAC) encoder. We support \'faac\' as \'default\' but support is there for neroAacEnc as well. .TP +.B OPUSENCODERSYNTAX +Specifies the style of encoder to use for the Opus encoder. At this point only +\'opusenc\' is available for Opus encoding. +.TP .B NORMALIZERSYNTAX Specifies the style of normalizer to use. Valid options are \'default\' and \'normalize'\ (and both run \'normalize-audio\'), since we only support it, @@ -357,7 +361,7 @@ with \fBdistmp3\fR (DISTMP3NICE). .B PATHNAMES The following configuration file options specify the pathnames of their respective utilities: LAME, TOOLAME, GOGO, BLADEENC, L3ENC, XINGMP3ENC, MP3ENC, -VORBIZE, OGGENC, FLAC, SPEEXENC, MPCENC, AACENC, ID3, EYED3, METAFLAC, +VORBIZE, OGGENC, FLAC, SPEEXENC, MPCENC, AACENC, OPUSENC, ID3, EYED3, METAFLAC, CDPARANOIA, CDDA2WAV, CDDAFS, CDDISCID, CDDBTOOL, EJECT, MD5SUM, DISTMP3, VORBISCOMMENT, NORMALIZE, CDSPEED, MP3GAIN, VORBISGAIN, MPPGAIN, MKCUE, MKTOC, CUE2DISCID (see option "\-X"), DIFF and HTTPGET. @@ -366,9 +370,9 @@ CUE2DISCID (see option "\-X"), DIFF and HTTPGET. If you wish to specify command-line options to any of the programs \fBabcde\fR uses, set the following configuration file options: LAMEOPTS, TOOLAMEOPTS, GOGOOPTS, BLADEENCOPTS, L3ENCOPTS, XINGMP3ENCOPTS, MP3ENCOPTS, VORBIZEOPTS, OGGENCOPTS, -FLACOPTS, SPEEXENCOPTS, MPCENCOPTS, AACENCOPTS, ID3OPTS, EYED3OPTS, MP3GAINOPTS, -CDPARANOIAOPTS, CDDA2WAVOPTS, CDDAFSOPTS, CDDBTOOLOPTS, EJECTOPTS, DISTMP3OPTS, -NORMALIZEOPTS, CDSPEEDOPTS, MKCUEOPTS, VORBISCOMMMENTOPTS, METAFLACOPTS, +FLACOPTS, SPEEXENCOPTS, MPCENCOPTS, AACENCOPTS, OPUSENCOPTS, ID3OPTS, EYED3OPTS, +MP3GAINOPTS, CDPARANOIAOPTS, CDDA2WAVOPTS, CDDAFSOPTS, CDDBTOOLOPTS, EJECTOPTS, +DISTMP3OPTS, NORMALIZEOPTS, CDSPEEDOPTS, MKCUEOPTS, VORBISCOMMMENTOPTS, METAFLACOPTS, DIFFOPTS, FLACGAINOPTS, VORBISGAINOPTS and HTTPGETOPTS. .TP .B CDSPEEDVALUE @@ -400,9 +404,9 @@ over 100MB for a machine that can encode music as fast as it can read it). Specifies the encoding format to output, as well as the default extension and encoder. Defaults to "vorbis". Valid settings are "vorbis" (or "ogg") (Ogg/Vorbis), "mp3" (MPEG-1 Audio Layer III), "flac" (Free Lossless Audio -Codec), "spx" (Ogg/Speex), "mpc" (MPP/MP+ (Musepack)), "m4a" (for M4A (AAC)) or -"wav" (Microsoft Waveform). Values like "vorbis,mp3" encode the tracks in both -Ogg/Vorbis and MP3 formats. For example +Codec), "spx" (Ogg/Speex), "mpc" (MPP/MP+ (Musepack)), "m4a" (for M4A (AAC)), +"wav" (Microsoft Waveform) or "opus" (Opus Interactive Audio Codec). Values +like "vorbis,mp3" encode the tracks in both Ogg/Vorbis and MP3 formats. For example .br OUTPUTTYPE=vorbis,flac .br @@ -551,7 +555,7 @@ Will extract the files contained in singletrack using the embedded cuesheet. \fBabcde\fR requires the following backend tools to work: .TP .B * -An Ogg/Vorbis, MP3, FLAC, Ogg/Speex, MPP/MP+(Musepack) or M4A encoder (oggenc, vorbize, lame, gogo, bladeenc, l3enc, mp3enc, flac, speexenc, mpcenc, faac, neroAacEnc) +An Ogg/Vorbis, MP3, FLAC, Ogg/Speex, MPP/MP+(Musepack), M4A encoder or Opus encoder (oggenc, vorbize, lame, gogo, bladeenc, l3enc, mp3enc, flac, speexenc, mpcenc, faac, neroAacEnc, opusenc). .TP .B * An audio CD reading utility (cdparanoia, icedax, cdda2wav, dagrab) diff --git a/abcde.conf b/abcde.conf index c2051a9..ab2c45a 100644 --- a/abcde.conf +++ b/abcde.conf @@ -61,7 +61,8 @@ # speexenc - the only encoder for SPEEXENCODERSYNTAX # mpcenc - encoder for MPCENCODERSYNTAX # faac, neroAacEnc - for AACENCODER -# default is a valid option for oggenc, lame, flac, speexenc, mpcenc and faac. +# opusenc - for OPUSENCODER +# default is a valid option for oggenc, lame, flac, speexenc, mpcenc, faac and opus. # Currently this affects the default location of the binary, the variable # to pick encoder command-line options from, and where the options are # given. @@ -71,6 +72,7 @@ #SPEEXENCODERSYNTAX=default #MPCENCODERSYNTAX=default #AACENCODERSYNTAX=default +#OPUSENCODERSYNTAX=default # Specify the syntax of the normalize binary here - so far only 'normalize' # is supported. @@ -129,6 +131,7 @@ #SPEEXENC=speexenc #MPCENC=mpcenc #AACENC=faac +#OPUSENC=opusenc #ID3=id3 #EYED3=eyeD3 @@ -196,6 +199,10 @@ #OUTPUTTYPE="m4a" #ATOMICPARSLEY='AtomicParsley' +# OPUS +# For the encoder options look at: opusenc -h. +#OPUSENCOPTS='--bitrate 128' + #ID3OPTS= #EYED3OPTS="--set-encoding=utf16-LE" #CDPARANOIAOPTS= @@ -245,7 +252,7 @@ # you can specify that here #WAVOUTPUTDIR=`pwd` -# OUTPUTTYPE can be either "ogg", "mp3", "flac" or "spx", or a combination +# OUTPUTTYPE can be either "ogg", "mp3", "flac", "spx", "opus" or a combination # of them separated with ",": "ogg,mp3". #OUTPUTTYPE=ogg diff --git a/changelog b/changelog index 4e2e782..fc786cd 100644 --- a/changelog +++ b/changelog @@ -12,6 +12,8 @@ abcde 2.5.5 UNRELEASED patch. * Allow aac encoding with neroAacEnc. Thanks to atheren for the patch. Closes issue 8. + * Allow opus encoding with opusenc. Thanks to Tomasz Golinski for the + patch. Closes issue 70. -- Steve McIntyre <93sam@debian.org> Tue, 27 Nov 2012 17:34:55 +0000 diff --git a/debian/control b/debian/control index d166810..21d713f 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Vcs-Svn: http://abcde.googlecode.com/svn/trunk/ Package: abcde Architecture: all -Depends: ${misc:Depends}, cd-discid, wget, cdparanoia | icedax, vorbis-tools (>= 1.0beta4-1) | lame | flac | bladeenc | speex | musepack-tools +Depends: ${misc:Depends}, cd-discid, wget, cdparanoia | icedax, vorbis-tools (>= 1.0beta4-1) | lame | flac | bladeenc | speex | musepack-tools | opus-tools Recommends: vorbis-tools, libmusicbrainz-discid-perl, libwebservice-musicbrainz-perl, libdigest-sha-perl, mailx Suggests: eject, distmp3, id3 (>= 0.12), id3v2, eyed3, normalize-audio, vorbisgain, mkcue, mp3gain, atomicparsley Description: A Better CD Encoder -- 2.20.1