Convert Video for Flash Streaming

This is a simple script I’m using to convert the videos I take on my Canon S90 for posting online using a flash player.

#!/bin/bash
# Convert videos from Canon S90 to flash-playable streaming format
for file in "$@"
do
filename=$(basename $file)
        filename=${filename%.*}
        # Convert the audio stream to AAC
        ffmpeg -i $file -vcodec copy -acodec libfaac temp_vid.mp4
        # Move the H.264 MOOV atom to the beginning of the file for progressive streaming
        qt-faststart temp_vid.mp4 $filename.mp4
        rm temp_vid.mp4
        # Create a screenshot
        ffmpeg -i $filename.mp4 -f image2 -vframes 1 $filename.jpg
done

XBMC Boxee UI Switcher

I bind this script to a button on my LIRC remote to easily switch between XBMC and Boxee on my HTPC. XBMC’s interface using the Rapier skin and fanart is much more attractive, but Boxee offers great social network integration (read: Youtube).

#/bin/bash
# Switch between XBMC and Boxee
if ps ax | grep -v grep | grep xbmc.bin > /dev/null
then
echo "XBMC running, killing process"
kill `pidof xbmc.bin`
sleep 7
echo "running Boxee"
/usr/bin/runBoxee &
elif ps ax | grep -v grep | grep Boxee > /dev/null
then
echo "Boxee running, killing process"
kill `pidof Boxee`
sleep 7
echo "running XBMC"
/usr/bin/runXBMC &
else
echo "No UI running, starting XBMC"
/usr/bin/runXBMC &
fi
view raw switchUI.sh This Gist brought to you by GitHub.

Start irexec daemon

#!/bin/bash
# Checks to see if irexec is running and runs it if not already running.

youruser=richard

# Test to see if IRexec is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -vi start|grep -i irexec
then
ps aux|grep -i $youruser|grep -i irexec |grep -vi start|awk '{print $2}'|xargs kill
else
# Do nothing
echo "irexec already dead!"
fi

#test to see if an instance of irexec is already running
if ps -ef|grep -v grep|grep irexec
then
# do nothing
echo "irexec already running"
else
# start irxevent
irexec -d /home/$youruser/.lircrc &
fi

exit

Count files and folders

# Prints the folder name number of files and folders in each subdirectory.
for i in *; do show="$i"; num=`ls "$i" | wc -l`; echo "$show: $num"; done;
view raw gistfile1.bat This Gist brought to you by GitHub.

Find text in files

# Search for a text string in all files and subdirectories.
find -type f -print0 | xargs -0 grep -il "$1"
view raw gistfile1.bat This Gist brought to you by GitHub.