I cannot for the life of me get this little (simple) script I wrote to work.
Here is the entire script:
Code:
#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
SIZE=`echo 320x$HEIGHT`
ffmpeg -i $1 -s $SIZE -f mp4 -vcodec libxvid -maxrate 2500 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec libfaac -ab 128k $2
So, here's what should happen:
An input filename ($1) is fed into mediainfo, which by the use of grep and cut spits out a single number which is the aspect ratio. This is then divided by bc into 320, which gives the desired height dimension for the file that I want ffmpeg to create for me. Finally, ffmpeg runs using the calculated dimensions...
Basically, it's the passing of the $ASPECT variable to bc that seems to fail.
It looks like bc won't read the output from the mediainfo line...
It always crashes out with:
Code:
(standard_in) 1: illegal character: ^M
I've tried doing something even simpler like this to debug by just trying it to display the calculation on the screen:
Code:
#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
echo $HEIGHT
...and it does the same, so it's definitely bc that won't accept the output from mediainfo...
Can anyone help?