This is a script I made and have been using for a while. I figured I'd post it here in hopes that it will be of use to others. It converts videos to what I've found to be the best for playback on my Blackberry Curve. The quality is high enough to allow you to enjoy your videos while being modest enough not to slow down your phone during playback.
Simply put videos into ~/Videos/blackberry-video-converter/input and run the script. You'll find your converted videos in ~/Videos/blackberry-video-converter/output.
You must have ffmpeg and libfaac installed on your system.
Enjoy!
Code:
#!/bin/bash
## This script uses ffmpeg to convert video files for playback on Blackberry smartphones.
## By Todd Stein
# INITIALIZATION
rootDir="${HOME}/Videos/blackberry-video-converter"
inputDir="${rootDir}/input"
outputDir="${rootDir}/output"
workingSymbols=( "." "-" "+" "*" "*" "+" "-" )
mkdir -p ${inputDir}
mkdir -p ${outputDir}
# CONVERT FILES (simultaneously)
cd ${inputDir}
for i in *; do
if [[ -f ${i} ]]; then
printf "\nStarting converstion of ${i}"
{
rm -f "${outputDir}/${i%.*}.mp4" # remove existing output
ffmpeg -i "${inputDir}/${i}" -vcodec mpeg4 -s qvga -r 16 -acodec libfaac -ar 22050 -ac 2 -ab 48k "${outputDir}/${i%.*}.mp4" &> /dev/null # convert the video
} &
children="${children}${!} " # collect PIDs of children
else
printf "\nNo files to convert!\n\n"
exit 1
fi
done
# WAIT FOR CONVERSION TO FINISH
printf "\n\nConverting, please wait... "
allDone="0"
until [[ ${allDone} -eq 1 ]]; do
# if the first PID in the children PID list no longer exists, remove it from the list
if ! ps -p $(echo ${children} | cut -f1 -d" ") &> /dev/null; then
children=$(echo ${children#$(echo ${children} | cut -f1 -d" ")})
fi
# bounce the working ball
for (( i=0; ${i}<${#workingSymbols[*]}; i++ )); do
printf "\b \b${workingSymbols[${i}]}"
sleep .1
done
# if the child PID list is empty, we're done
if [[ -z ${children} ]]; then
allDone="1"
printf "\bDone!\n\n"
fi
done