Sample post processing script to convert videos

Example scripts to convert video into a format that
is supported by the IAUDIO X5(L). Shows how to write
such a post-download script for "cmd_download_complete"
in gPodder's advanced preferences.
This commit is contained in:
Casey Watson 2009-01-03 12:48:06 +01:00 committed by Thomas Perl
parent af2a672da1
commit 73dd1fae62
3 changed files with 89 additions and 0 deletions

54
doc/dev/convert/README Normal file
View file

@ -0,0 +1,54 @@
Sample post processing script to convert videos after download
==============================================================
This script is a post download processor for gPodder. It can convert mp4 and
mov movie files into an avi format that can be played on the COWON IAUDIO
X5(L). It should also be able to support other players with some minor changes
to the "convert_video_iaudio-x5" file.
Installation:
* Copy "convert_video_iaudio-x5" and "gpodder_download_complete" to a location
in your $PATH (i.e. /usr/local/bin or ~/bin)
* Set the gPodder "cmd_download_complete" advanced setting to the location
of the "gpodder_download_complete" script
by Casey Watson ("watsoncj" on GMail) 2008-12-17
Initial announcement:
I've whipped up this little script to convert downloaded videos into a
format that is supported by my IAUDIO X5(L). It's still got some gaps
in it but it does take away some of the manual process of getting
video's onto my player. While I'm not sure that this is the intended
direction for the gPodder application, it might make a nice addition
to the gPodderWiki.
You can download it here:
http://www.casedogdesigns.com/gpodder_convert_video/
The script uses the post download hook by setting the advanced
configuration variable "cmd_download_complete" to the
gpodder_download_complete script.
Once the download is complete the movie is converted onto the desktop.
A zenity progress bar is shown while the conversion takes place.
Ideally, the new file could replace the original in gPodder so the
user would need to manually copy the file to their device, but this
requires changing the file extension and I haven't found a clean way
of doing this. So, for now the video must be manually put onto your
player.
Anyway, I think its a good starting point. It should be able to
support video types for other devices by changing the mencoder
parameters in the convert_video script.
Let me know if you find it useful or end up making any changes.
--
Casey Watson
watsoncj at gmail.com
(https://lists.berlios.de/pipermail/gpodder-devel/2008-December/002323.html)

View file

@ -0,0 +1,20 @@
#!/bin/bash
#
# Requirements:
# Debian/Ubuntu aptitude install mencoder libmp3lame0 zenity
#
if [ $# -ne 2 ]; then
echo "Usage: $0 inputfile outputfile"
exit 65
fi
# This will convert mp4 videos into an avi format suitable for playing on the IAUDIO X5
COMMAND="mencoder $1 -o $2 -ovc lavc -oac mp3lame -lavcopts acodec=mp3:abitrate=96 -ofps 13 -vf scale=160:108"
$COMMAND 2>&1 &
COMMAND_PID=$!
zenity --progress --text="Converting Video $2" --auto-kill --pulsate &
PROGRESS_PID=$!
while [ -n "`ps -p ${COMMAND_PID} | grep ${COMMAND_PID}`" ] ; do
sleep 1
done
kill $PROGRESS_PID
exit 0

View file

@ -0,0 +1,15 @@
#!/bin/bash
#
# Post download processor to convert a video into a format that can be played on handheld devices.
#
LOG=$HOME/.gpodder.log
date >> $LOG
EXT=${GPODDER_EPISODE_FILENAME##*.}
OUTFILE=$HOME/Desktop/`basename ${GPODDER_EPISODE_URL%.*}`.avi
if [ "$EXT" == "mp4" ] || [ "$EXT" == "mov" ]; then
echo "Converting $GPODDER_EPISODE_FILENAME to $OUTFILE" >> $LOG
convert_video_iaudio-x5 $GPODDER_EPISODE_FILENAME $OUTFILE >> $LOG 2>&1
echo "Finished converting" >> $LOG
exit 0
fi