How to convert DTS wav to 5.1 FLAC with gstreamer (bash script)

This script convert DTS wav to FLAC with 5.1 channel.

You need gstreamer and gstreamer DTS/FLAC plugins.

#!/bin/bash

if [ -z "$1" ] || [ -z "$2"]
then
    echo "USAGE: dts2flac [Input Dir] [output Dir]"
    exit
fi

INPUT_DIR="$1*.wav"
OUT_DIR="$2"

echo "Input Directory : $INPUT_DIR"
echo "Export Directory: $OUT_DIR"

[ ! -d ${OUT_DIR} ] && mkdir -p ${OUT_DIR}

for x in $INPUT_DIR
do

WAV=$x
echo "File : $WAV"
FLAC=`basename "${WAV%.wav}.flac"`

[ -r "$WAV" ] || { echo can not read file "$WAV" >&1 ; exit 1 ; } ;

echo "Converting ${WAV} to FLAC format"

gst-launch-0.10 filesrc location="$WAV" ! dtsdec ! audioconvert ! audio/x-raw-int,channels=6 ! flacenc ! id3mux name=tag ! filesink location=${OUT_DIR}/"$FLAC"

done
Advertisements

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