[#] (De)Kodowanie muzyki

( Ostatnio zmieniony śr., 06/08/2008 - 21:35 )
 

Przydatne programy:

Mplayer – http://www.mplayerhq.hu
Lame  – http://lame.sourceforge.net/
Faad  – http://www.audiocoding.com/
Oggenc  – http://directory.fsf.org/OggEnc.html

http://pl.wikipedia.org/wiki/Vorbis
http://www.mplayerhq.hu/…formats.html

* midi > ogg ( TiMidity++ )

Odtworzenie midi:

timidity pliczek.mid

Konwersja

timidity -Ov pliczek.mid

lub

timidity -Ov *.mid

gdzie:

-Ow   = .wav
-Ov   = .ogg
-Ou   = .au
-Or   = .sw

* mp3 > ogg

mplayer file.mp3 -ao pcm:file="dump.wav" && oggenc -q 5 dump.wav -o file.mp3
mv file.mp3 file.ogg
rm dump.wav

mp3_to_ogg.sh

#!/bin/bash
#
# mp3 to ogg
if [ -z "$1" ]; then
 echo Usage: $0 directory
 exit
fi

cd $1
# strip spaces
for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
# remove uppercase
for i in *.[Mm][Pp][3]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
# encode
for i in *.mp3; do mplayer $i -ao pcm:file="dump.wav" && oggenc -q 5 dump.wav -o $i; done
# convert file names
for i in *.mp3; do mv "$i" "`basename "$i" .mp3`.ogg"; done
# cleanup
rm dump.wav

* ogg > mp3

mplayer file.ogg -ao pcm:file="dump.wav" && lame -m s dump.wav -o file.ogg
mv file.ogg file.mp3
rm dump.wav

ogg_to_mp3.sh

#!/bin/bash
#
# ogg to mp3
if [ -z "$1" ]; then
 echo Usage: $0 directory
 exit
fi

cd $1
# strip spaces
for i in *.ogg; do mv "$i" `echo $i | tr ' ' '_'`; done
# remove uppercase
for i in *.[Oo][Gg][Gg]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
# encode
for i in *.ogg; do mplayer $i -ao pcm:file="dump.wav" && lame -m s dump.wav -o $i; done
# convert file names
for i in *.ogg; do mv "$i" "`basename "$i" .ogg`.mp3"; done
# cleanup
rm dump.wav

* wma > mp3

mplayer file.wma -ao pcm:file="dump.wav" && lame -m s dump.wav -o file.wma
mv file.wma file.mp3
rm dump.wav

wma_to_mp3.sh

#!/bin/bash
#
# wma to mp3
if [ -z "$1" ]; then
 echo Usage: $0 directory
 exit
fi

cd $1
# strip spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done
# remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
# encode
for i in *.wma; do mplayer $i -ao pcm:file="dump.wav" && lame -m s dump.wav -o $i; done
#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done
# cleanup
rm dump.wav

* wma > ogg

mplayer file.wma -ao pcm:file="dump.wav" && oggenc -q 5 dump.wav -o file.wma
mv file.wma file.ogg
rm dump.wav

wma_to_mp3.sh

#!/bin/bash
#
# wma to ogg
if [ -z "$1" ]; then
 echo Usage: $0 directory
 exit
fi

cd $1
# strip spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done
# remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
# encode
for i in *.wma; do mplayer $i -ao pcm:file="dump.wav" && oggenc -q 5 dump.wav -o $i; done
# convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.ogg"; done
# cleanup
rm dump.wav

* m4a > mp3

faad -o - file.m4a | lame -h -b 192 - file.mp3

m4a_to_mp3.sh

#!/bin/bash
#
# m4a to mp3
if [ -z "$1" ]; then
 echo Usage: $0 directory
 exit
fi

cd $1
# strip spaces
for i in *.m4a; do mv "$i" `echo $i | tr ' ' '_'` ; done
# remove uppercase
for i in *.[Mm][4][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
# encode
for i in *.m4a; do faad -o - "$i" | lame -h -b 192 - "${i%m4a}mp3"; done

* m4a > ogg

faad file.m4a -o dump.wav && oggenc -b 192 dump.wav -o file.m4a
mv file.m4a file.ogg
rm dump.wav

m4a-to_ogg.sh

#!/bin/bash
#
# m4a to ogg
if [ -z "$1" ]; then
 echo Usage: $0 directory
 exit
fi

cd $1
# strip spaces
for i in *.m4a; do mv "$i" `echo $i | tr ' ' '_'`; done
# remove uppercase
for i in *.[Mm][4][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
# encode
for i in *.m4a; do faad $i -o dump.wav && oggenc -b 192 dump.wav -o $i; done
# convert file names
for i in *.m4a; do mv "$i" "`basename "$i" .m4a`.ogg"; done
# cleanup
rm dump.wav

aac/m4a/mp4/any to ogg

for nam in *.mp4; do
 nice mplayer -ao pcm "$nam" -ao pcm:file="$nam.wav" && \
 nice oggenc -q5 "$nam.wav" -o "$(basename "$nam" .mp4).ogg";
 rm "$nam.wav";
done

aac/m4a to mp3

faad -w inputfile.aac | lame - outputfile.mp3

aac/m4a to wav

mplayer -ao pcm inputfile.m4a -ao pcm:file="outfile.wav"

wav to mp3

wav_to_mp3.sh

#!/bin/bash
#
# wav2mp3
#
for i in *.wav; do
   #out=$(ls $i | sed -e 's/.wav//g')
   #out=$(echo $i | sed -e 's/.wav$//')
   #lame -h -b 192 "$i" "$out.mp3"
   lame -h -b 192 "$i" "${i%.wav}.mp3"
done

wav to ogg

wav_to_ogg.sh

#!/bin/bash
#
# wav2ogg
#
for i in *.wav; do
   oggenc $i
   # or use oggenc -o output.ogg input.wav
done

aac2mp3

aac_to_mp3.sh

#!/bin/bash

#
# $Id: aac2mp3,v 1.2 2005/08/22 15:32:34 rali Exp $
#

#
# Convert one or more AAC/M4A files to MP3.  Based on a script example
# I found at: http://gimpel.gi.funpic.de/Howtos/convert_aac/index.html
#

ME=`basename ${0}`

AAC2WAV="/usr/bin/mplayer"
WAV2MP3="/usr/bin/lame"

EXT="m4a"
BITRATE="192"

do_usage() {            # explanatory text
  echo "usage: ${ME} [-b nnn] [-e ext] [-f] [-c] [-r] [-v] [-h] [file list]"
  echo "       Convert music from AAC format to MP3"
  echo "  -l /path/app  Specify the location of lame(1)"
  echo "  -m /path/app  Specify the location of mplayer(1)"
  echo "  -b nnn        bitrate for mp3 encoder to use"
  echo "  -e ext        Use .ext rather than .m4a extension"
  echo "  -f            Force overwrite of existing file"
  echo "  -c            Delete original AAC|M4A file(s)"
  echo "  -s            Keep intermediate .wav file(s)"
  echo "  -v            Verbose output"
  echo "  -h            This information"
  exit 0
  }

do_error() {
  echo "$*"
  exit 1
  }

file_overwrite_check() {
  if [ "$FORCE" != "yes" ]
  then
    test -f "${1}" && do_error "${1} already exists."
  else
    test -f "${1}" && echo "  ${1} is being overwritten."
  fi
  }

create_wav() {  # use mplayer(1) to convert from AAC to WAV
  file_overwrite_check "${2}"

  test $VERBOSE && echo -n "Creating intermediate WAV file"

  ${AAC2WAV} -really-quiet -ao pcm "${1}" -ao pcm:file="${2}"
  if [ $? -ne 0 ]
  then
    echo ""
    echo "Conversion to WAV (${AAC2WAV}) failed."
    do_cleanup
    do_error "Exiting"
  fi

  test $VERBOSE && echo ".  OK"
  }

create_mp3() {  # use lame(1) to convert from WAV to MP3
  file_overwrite_check "${2}"

  test $VERBOSE && echo -n "Creating output MP3 file"

  ${WAV2MP3} -h -b ${BITRATE} -S "${1}" "${2}"
  if [ $? -ne 0 ]
  then
    echo ""
    echo "Conversion to MP3 (${WAV2MP3}) failed."
    do_cleanup
    do_error "Exiting"
  fi

  test $VERBOSE && echo ".  OK"
  }

do_cleanup() {  # Delete intermediate and (optionally) original file(s)
  test $VERBOSE && echo -n "Deleting intermediate file"
  test ${SAVEWAV} || rm -f "${2}"
  test ${RMM4A}   && rm -f "${1}"
  test $VERBOSE && echo ".  OK"
  }

do_set_bitrate() {
  test $VERBOSE && echo -n "Setting output bitrate to: $1 kbps"
  BITRATE=$1
  test $VERBOSE && echo ".  OK"
  }

GETOPT=`getopt -o l:m:b:e:cfhrv -n ${ME} -- "$@"`
if [ $? -ne 0 ]
then
  do_usage
fi

eval set -- "$GETOPT"

while true
do
  case "$1" in
    -l) LAME=$2 ; shift ; shift ;;
    -m) MPLAYER=$2 ; shift ; shift ;;
    -b) do_set_bitrate $2 ; shift ; shift ;;
    -e) EXT=$2 ; shift ; shift ;;
    -f) FORCE="yes" ; shift ;;
    -c) RMM4A="yes" ; shift ;;
    -s) SAVEWAV="yes" ; shift ;;
    -v) VERBOSE="yes" ; shift ;;
    -h) do_usage ;;
    --) shift ; break ;;
     *)  do_usage ;;
  esac
done

test -f $LAME    || do_error "$LAME not found. Use \"-l\" switch."
test -f $MPLAYER || do_error "$MPLAYER not found. Use \"-m\" switch."

if [ $# -eq 0 ]
then                    # Convert all files in current directory
  for IFILE in *.${EXT}
  do
    if [ "${IFILE}" == "*.${EXT}" ]
    then
      do_error "No files with extension ${EXT} in this directory."
    fi

    OUT=`echo "${IFILE}" | sed -e "s/\.${EXT}//g"`

    create_wav "${IFILE}"   "${OUT}.wav"
    create_mp3 "${OUT}.wav" "${OUT}.mp3"
    do_cleanup "${IFILE}"   "${OUT}.wav"

  done
else                    # Convert listed files
  for IFILE in "$*"
  do
    test -f "${IFILE}" || do_error "${IFILE} not found."

    OUT=`echo "${IFILE}" | sed -e "s/\.${EXT}//g"`

    create_wav "${IFILE}" "${OUT}.wav"
    create_mp3 "${OUT}.wav" "${OUT}.mp3"
    do_cleanup "${IFILE}" "${OUT}.wav"
  done
fi
exit 0
5
Twoja ocena: Brak Średnio: 5 (2 głosy)