|
Hi,
I need a script to take a .mpeg file and reencode it to .ts, now in the current directory i have only .ts so i change it to do reencoding.I have done only for english but i want to do also for german, german-english, english-german and so on.It would be nice to insert the option to choose between the languages and then make the encode from this choice. This is my first script and i have tryed my best but it's not working.FFmpeg is ok,
which ffmpeg
/usr/bin/ffmpeg
My script is here#!/bin/bash
INPUTDIR=$1
OUTPUTDIR=$2
echo "Output Dir : $OUTPUTDIR"
echo "Input Dir : $INPUTDIR"
usage()
{
echo "Usage: 'basename $0' <input folder> <output folder>";
}
convert_eng()
{
find "$INPUTDIR" -name " *.ts" -print 2>/dev/null |
while read ifile ; do
ofile='echo ${ifile#$INPUTDIR} | sed -e "s/ / _/g"';
ofile='echo $OUTPUTDIR&ofile';
dirs='dirname $ofile';
mkdir -p $dirs;
tfile='echo ${ofile%.ts}.ts';
echo "Output File : $tfile"
echo -e "\nCOnverting MPEG file <$ifile> to <$ofile>\n"
echo -y |ffmpeg -i "$ifile" -f dvd -acodec ac3 -alang eng -target pal-dvd -aspect 16:9 -b 4000000 -maxrate 4000000 -minrate 4000000
-bufsize 2000000 -vcodec mpeg2video -f mpegts -s 720*576 -y "$tfile"
done
}
if [ "" == "$INPUTDIR" -o ""OUTPUTDIR" ]; then
usage
exit 1;
fi
which ffmpeg 2> /dev/null
if [ $2 !=0" ]; then
echo "Please install ffmpeg !"
fi
convert_eng
echo -e "\n\nCopy & Conversion done , have a nice day !\n"
I run it like ./ffmpegscript.sh /video/ /video/test/ and the result is
Output Dir : /video/test/
Input Dir : /video/
Please install ffmpeg !
Copy & Conversion done , have a nice day !
Thanks
|