Opus support

This commit is contained in:
Vincent Riquer 2013-03-28 22:30:05 +01:00
parent 49031cde33
commit a0f9157b9e
4 changed files with 87 additions and 3 deletions

6
README
View File

@ -21,6 +21,10 @@ Optional:
http://www.vorbis.com/ http://www.vorbis.com/
* ogginfo (Ogg Vorbis tags support) * ogginfo (Ogg Vorbis tags support)
* oggenc (Ogg Vorbis destination) * oggenc (Ogg Vorbis destination)
* opus-tools
http://opus-codec.org/
* opusinfo (Opus tags support)
* opusenc (Opus destination)
* LAME MP3 Encoder * LAME MP3 Encoder
http://lame.sourceforge.net/ http://lame.sourceforge.net/
* lame (MP3 destination) * lame (MP3 destination)
@ -29,7 +33,7 @@ Optional:
* metaflac (FLAC tags support) * metaflac (FLAC tags support)
* Musepack * Musepack
http://www.musepack.net/ http://www.musepack.net/
* mpcdec (Musepack tags support, Musepack decoding) * mpcdec (Musepack decoding)
================== ==================
Using the software Using the software

60
atom
View File

@ -190,6 +190,9 @@ getConfigDestination() {
fi fi
unset expr unset expr
case "${destinationformat["$destination"]}" in case "${destinationformat["$destination"]}" in
'opus')
destinationquality["$destination"]="$value"
;;
'mp3') 'mp3')
destinationquality["$destination"]="$value" destinationquality["$destination"]="$value"
;; ;;
@ -199,6 +202,24 @@ getConfigDestination() {
;; ;;
esac esac
;; ;;
'loss')
expr='^[0-9]*$'
if ! [[ $value =~ $expr ]]
then
echo "Invalid loss value: $value" >&2
exit $EQUALITY
fi
unset expr
case "${destinationformat["$destination"]}" in
'opus')
destinationloss["$destination"]="$value"
;;
*)
echo "$Invalid parameter \"$key\" for format \"${destinationformat["$destination"]}\"" >&2
exit $EFMTINVPARM
;;
esac
;;
'channels') 'channels')
expr='^[0-9]*$' expr='^[0-9]*$'
if ! [[ $value =~ $expr ]] if ! [[ $value =~ $expr ]]
@ -1207,6 +1228,45 @@ encodeFile::mp3() {
progressSpin progressSpin
} }
encodeFile::opus() {
opusencopts=(opusenc --music --quiet)
opusencopts+=(--bitrate ${destinationquality[$destination]})
[ -n "${destinationlost["$destination"]}" ] \
&& opusencopts+=(--expect-loss "${destinationlost["$destination"]}")
[ -n "$albumartist" ] && opusencopts+=(--comment "ALBUMARTIST=$albumartist")
[ -n "$album" ] && opusencopts+=(--comment "ALBUM=$album")
[ -n "$artist" ] && opusencopts+=(--artist "$artist")
[ -n "$composer" ] && opusencopts+=(--comment "COMPOSER=$composer")
[ -n "$disc" ] && opusencopts+=(--comment "DISCNUMBER=$disc")
[ -n "$genre" ] && opusencopts+=(--comment "GENRE=$genre")
[ -n "$performer" ] && opusencopts+=(--comment "PERFORMER=$performer")
[ -n "$title" ] && opusencopts+=(--title "$title")
[ -n "$track" ] && opusencopts+=(--comment "TRACKNUMBER=${track%/*}")
[ -n "${track#*/}" ] && opusencopts+=(--comment "TRACKTOTAL=${track#*/}")
[ -n "$year" ] && opusencopts+=(--comment "DATE=$year")
opusencopts+=(-o "$destdir/$destfile.ogg" "$tempdir/$tmpfile.wav")
encodetaskid=$(
Insert tasks <<-EOInsert
key ${fileid}opusenc$destination
requires ${soxtaskid:-$decodetaskid}
required ${soxtaskid:-$decodetaskid}
fileid $destfileid
filename $destdir/$destfile.ogg
$(
for key in ${!opusencopts[@]}
do
echo "cmd_arg$key ${opusencopts[key]}"
done
)
cleanup $tempdir/$tmpfile.wav
source_file $fileid
status 0
rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"
EOInsert
)
progressSpin
}
encodeFile::vorbis() { encodeFile::vorbis() {
oggencopts=(oggenc -Q -q ${destinationquality[$destination]}) oggencopts=(oggenc -Q -q ${destinationquality[$destination]})
[ -n "$albumartist" ] && oggencopts+=(-c "ALBUMARTIST=$albumartist") [ -n "$albumartist" ] && oggencopts+=(-c "ALBUMARTIST=$albumartist")

View File

@ -50,8 +50,8 @@ Sections:
Common parameters: Common parameters:
Mandatory parameters: Mandatory parameters:
* path: Where files will be written * path: Where files will be written
* format: ogg or mp3. Other formats may appear in the future - feel free to * format: ogg, opus or mp3. Other formats may appear in the future - feel
implement your preferred format. A good candidate is Opus (RFC 6716). free to implement your preferred format.
Optional parameters: Optional parameters:
* normalize <yes>/<no>: Normalize output files. * normalize <yes>/<no>: Normalize output files.
@ -90,6 +90,17 @@ Sections:
more info. This is the only mode supported and planned. Still, if you want more info. This is the only mode supported and planned. Still, if you want
to be able to use bitrate settings, feel free to fork and file a pull to be able to use bitrate settings, feel free to fork and file a pull
request. request.
Opus parameters:
Please note that Opus supports only the following sample-rates: 8000,
12000, 16000, 24000, and 48000 Hz. So don't set resampling on an Opus
destination to any other value or files will be resampled twice.
* bitrate <bitrate>: Set (VBR) bitrate to <bitrate>. Note that while Opus
allows for decimal values, AtOM does not. The reason for this is simple:
we do numeric comparisons, and Bash only manipulates integers.
* loss <percent>: If you intend to stream the resulting files over an
unreliable protocol, you may want to make use of Opus' Forward Error
Correction algorythm. See the Opus-codec.org website for details.
Default: 0
MP3 parameters: MP3 parameters:
* bitrate <bitrate>: Set ABR to <bitrate>. Again, if you want CBR or any * bitrate <bitrate>: Set ABR to <bitrate>. Again, if you want CBR or any
other mode supported by lame, please fork and file a pull request. other mode supported by lame, please fork and file a pull request.

View File

@ -24,6 +24,15 @@ frequency 44100
copy_mime-type image/* copy_mime-type image/*
copy_mime-type text/* copy_mime-type text/*
[Opus]
path /mnt/Musique-opus
format opus
bitrate 96
normalize yes
frequency 48000
copy_mime-type image/*
copy_mime-type text/*
[MP3] [MP3]
path /mnt/Musique-mp3.test path /mnt/Musique-mp3.test
format mp3 format mp3