Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-31-2008, 04:41 PM   #1
LQ Newbie
Registered: Dec 2007
Posts: 13

Rep: Reputation: 0
Question batch file to convert every file in a directory with mencoder.

I am trying to build a perl or shell script that does the following.
After I manually ftp a file to /home/incoming the script runs to see:

If new files have been completly uploaded copy files to /home/needencoding

encode all new files with:
mencoder filename.dv -o newfilename.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=450:400 -srate 22050

copy files to /home/outgoing

The goal is to have a directory on my server that files get ftp'd to.
The server automatically moves the files to the right directory, encodes them, then puts them in another directory they can be copied from.

I already have mencoder command working, I just need a way to batch all the encoding whenever files get uploaded.

How do I tell if a file in a directory has been completely uploaded via ftp or if it is still being uploaded? The file appears before it is completed.

I will then tell the server to run the script every 5 minutes so whenever a file gets uploaded it gets copied over.

Thanks in advance for your help.
Old 01-31-2008, 06:28 PM   #2
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
You could put the following in a script and run it out of cron. It would need commands added to move the files once they're processed. I've just copy/pasted from a script of mine, so you'll also need to modify the mencoder options:
for i in *flv;
  ORIGINAL=`basename $i .flv`
  /usr/bin/mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
  -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 \
  -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:trell:mbd=2:precmp=2:
subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:dc=10:vstrict=0:acodec=ac3:abitrate=192:aspect=4/3 \
  -ofps 25 -o $NEWNAME $i


encode, perl, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
i want to convert .wav file into mp3 files in batch mode sparsh Linux - Software 6 11-20-2007 11:53 AM
How to convert a batch file(.bat) to script file(.sh) manas_sem Programming 4 06-28-2007 01:10 PM
howto convert .flw (koffice/kivio file) into windows readable type of file? rahmmandel Linux - Desktop 7 01-30-2007 05:12 PM
Howto convert bin file to a executable DOS file lilzz Linux - Newbie 5 08-04-2006 01:03 AM
using mencoder to convert directory to avi ogross74 Linux - Software 2 07-05-2005 10:04 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration