diff --git a/.shell.d/funs_transcode b/.shell.d/funs_transcode index b892c829..3a644ddb 100644 --- a/.shell.d/funs_transcode +++ b/.shell.d/funs_transcode @@ -78,7 +78,8 @@ tc_text_2utf8 () ## For the sake of simplicity we convert everything to OGG. ## You can easily set output folder to current folder with TC_AUDIO_DEST=".". -TC_AUDIO_DEST="/media/data1/Musics/" +# TC_AUDIO_DEST="/media/data1/Musics/" +TC_AUDIO_DEST="$HOME/audio/" ## OGG quality ranges from -1 to 10. ## -q-1 45 kbit/s @@ -108,15 +109,43 @@ tc_audio_scan() echo "void" } -## TODO: cover resolution check. Should be > 100x100. Above <1000x1000 should give a warning. -## TODO: extract cover from tags if checksum does not match any from current folder. + +tc_audio_batch() +{ + + OLDIFS=$IFS + IFS=" +" + + for i in $(find "." \( \ + -iname '*.mp3' -o \ + -iname '*.flac' -o \ + -iname '*.wv' -o \ + -iname '*.aac' -o \ + -iname '*.wav' -o \ + -iname '*.ape' -o \ + -iname '*.mpc' \) ); do + tc_audio_transcode "$@" $i + done + + # for i in *.mp3 ; do tc_audio_transcode "$@" $i ; done + # tc_audio_transcode "$@" "01 James Russo - Winged.mp3" + + IFS=$OLDIFS + unset OLDIFS +} ## This function is supposed to work on a per-album basis. Folders will not be ## accepted as argument. This function will work best if all tracks of a folder ## belong to the same album. Theres is no way to handle covers raliably, so you ## should leave the only covers you want to keep in the working folder. + +## TODO: cover resolution check. Should be > 100x100. Above <1000x1000 should give a warning. +## TODO: extract cover from tags if checksum does not match any from current folder. tc_audio_transcode() { + IFS=${OLDIFS:-$IFS} + _printhelp () { cat < OUTPUT" - echo "[$OUTPUT_FILE]" + echo "[$OUTPUT_FILE.$OUTPUT_FORMAT]" + echo [ $PREVIEW -ne 0 ] && return @@ -418,31 +453,27 @@ EOF return fi - ## COVER ## We copy cover only if it does not already exist. local OUTPUT_COVER local COVER_COUNTER - OUTPUT_COVER="$OUTPUT/" - [ -n "$ALBUM" ] && OUTPUT_COVER="$OUTPUT_COVER$ALBUM - " + OUTPUT_COVER="$OUTPUT/${OUTPUT_ALBUM:+$OUTPUT_ALBUM - }Cover" for i in $(find "." \( \ -iname '*.png' -o \ -iname '*.jpg' \) ); do - OUTPUT_COVER="${OUTPUT_COVER}Cover.${i##*.}" + OUTPUT_COVER="${OUTPUT_COVER}.${i##*.}" COVER_COUNTER=1 - if [ ! "$(sha1sum $OUTPUT_COVER | cut -f1 -d' ')" = "$(sha1sum $i | cut -f1 -d' ')" ]; then + while [ -e "$OUTPUT_COVER" ] && \ + [ ! "$(sha1sum $OUTPUT_COVER | cut -f1 -d' ')" = "$(sha1sum $i | cut -f1 -d' ')" ]; do + OUTPUT_COVER="${OUTPUT_COVER%.*} $COVER_COUNTER.${i##*.}" + COVER_COUNTER=$(($COVER_COUNTER+1)) + done - while [ -e "$OUTPUT_COVER" ]; do - OUTPUT_COVER="${OUTPUT_COVER}Cover $COVER_COUNTER.${i##*.}" - COVER_COUNTER=$(($COVER_COUNTER+1)) - done - - ## DEBUG only. - # echo "cp -nv $i [$OUTPUT_COVER]" - cp -nv "$i" "$OUTPUT_COVER" - fi + ## DEBUG only. + # echo "cp -nv $i [$OUTPUT_COVER]" + cp -nv "$i" "$OUTPUT_COVER" done ## Zsh compatibility. We need it otherwise word splitting of parameter like @@ -452,6 +483,7 @@ EOF [ "$STATUS" = "off" ] && set -o shwordsplit ## TAG/RECODE + # ffmpeg -i "$1" -c:a libvorbis -b:a ${OUTPUT_BITRATE}k \ ffmpeg -i "$1" $OGG_PARAM \ -metadata title="$OUTPUT_TITLE" \ -metadata artist="$OUTPUT_ARTIST" \