Register
It is currently Mon Jul 28, 2014 6:21 am

FFmpeg script to code a video


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Sun Jul 06, 2008 6:08 pm   

Joined: Sun Jul 06, 2008 5:51 pm
Posts: 1
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


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP