Re-encode video files to Iphone format in Ubuntu

Copy the script and paste it into a file named recode_mp4.sh.

#!/bin/bash

for file in "$@"
do
  while [ -n "$(ps -ef | egrep "ffmpeg" | grep -v grep)" ];
  do
    echo -e "\n[$(date +%b\ %d\ %Y:\ %H:%M:%S)]\nFound another instance of \
HandBrake or ffmpeg running, pausing 5 minutes..."
    sleep 300
  done
  fnout=${file}
  ffmpeg -i "${file}" -acodec libfaac -aq 100 -ac 2 -vcodec libx264 -vpre \
slow -vpre ipod640 -crf 26 -map_meta_data 0:0 -vf scale=640:-1 \
-threads 0 "${fnout}".mp4
done

exit 0

*Tip: Combine the lines separated by "\" as they are there only there to improve readability.

Install ffmpeg, using this guide.

Now you can run ./recode_mp4.sh video_file.ext to recode that video file or ./recode_mp4.sh * to recode all files in the directory you are in.

Post a comment:






«-- back

What is this?

This is an entry posted to the Snakeblog on September 23, 2010.

This entry is part of the categories Iphone and Ubuntu

Tags: iphone and ubuntu

Latest entries in the snakeblog

This page uses the Perfect 'Holy Grail' 3 Column Liquid Layout.


Creative Commons License
This work is licensed under a
Creative Commons License.