Posted by: yegorich | April 13, 2010

Automatically Convert Video Using Inotify

I just needed to convert some YouTube videos from flv into Xvid format to watch them on my old media player. At first I converted each video manually using ffmpeg. It was not very comfortable. Using WinFF made the stuff easier nevertheless it still required manual intervention. So after some searching I came across an article describing Inotify kernel feature. So here is my script:


#!/bin/sh

SRCDIR=/home/user/Videos/downloaded
DESTDIR=/home/user/Videos/converted/

inotifywait -mq --format="%w%f" -e close_write $SRCDIR | while read file; do
       ffmpeg -i "$file" -vcodec libxvid -aspect 4:3 -acodec libmp3lame -ab  192k $DESTDIR"`basename "$file" .flv`".avi
       rm "$file"
done

Now each downloaded video will be automatically converted and moved to the right folder. The script can be started on startup to make the process fully automatically.

Dependencies: inotify-tools

Advertisements

Responses

  1. thanks man


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: