ssh_mp32ogg.sh

‘cos those MP3 wont convert by themselves.


#!/bin/sh

# -----------------------------------------------------------------------------
# It is a simple script to convert mp3 files (one at a time) to ogg on my 
# other computer, because that's where the LAME codec is installed.
# Last edit: 5 June 2009
#
# It requires sox (with LAME installed) on the other computer.
#
# Usage: ssh_mp32ogg.sh [-s SERVER] [-u USERNAME] [-r BITRATE] infile outfile
# -----------------------------------------------------------------------------

mp3_fn=;
out_fn=;
server="CHIKUZA.KRYIE";	# default server
server_usr="ariel"	# default user @ server, must be exists
out_rate=4	# output bitrate to ~ 128

for cur_arg in "$@" ; do 
  if [ -z "$mp3_fn" ] && [ -f "$cur_arg" ] ; then
    mp3_fn="$cur_arg";
    echo "Input file is $mp3_fn";
  elif [ -z "$out_fn" ] && [ ! -z "$mp3_fn" ] ; then
    out_fn="$cur_arg";
    echo "Output file is $out_fn";
  fi
done

while getopts s:u:r: OPTION; do
  case "$OPTION" in
	s)	shift `echo "$OPTIND -1" | bc`;
		server="$OPTARG";
		;;
	u)	shift `echo "$OPTIND -1" | bc`;
		server_usr="$OPTARG";
		;;
	r)	shift `echo "$OPTIND -1" | bc`;
		out_rate=`echo "$OPTARG / 32" | bc`;
		;;
  esac
done

# do the format conversion
cat "$1" | ssh $server_usr@$server "sox -S -t mp3 - -C $out_rate -t ogg -" > "$2"
Advertisements

Leave a comment

Filed under Ilmu, Orang bego punya kegiatan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s