| Home | Forums | Register | FAQ | Search | Today's Posts | Mark Forums Read |
|
Welcome to the misticriver forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: batch encoding, mencoder |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
mencoder batch encoding script (python)
Hey.
I made a python script for my gentoo linux pc so I could batch encode videos so they are playable on my E10. The script uses mencoder and I thought I would share it in case anyone found it useful by any chance. If you do use the script you may want to change the OUT_DIR variable/constant so it maps to your E10 mount point. You may also wish to change the scale parameter in the encode string depending on the aspect ratio of the videos you are encoding. To run the script stick it in a file, e10_converter.py for example. To run the script type: python e10_converter.py [file1] [file2] [...] You can use wildcards obviously: python e10_converter.py /mnt/video/* Code:
#!/usr/bin/python
import sys, os
#--------------------------------TWEAKS--------------------------------#
#Path to mencoder
MENCODER = "/usr/bin/mencoder"
#Append postfix to differentiate original and converted video
FILE_POSTFIX="-e10"
#Encoding bitrate
BITRATE = 384
#Output directory for converted videos
OUT_DIR = "/media/E10/Video"
#----------------------------------------------------------------------#
encode = "%s %s -ofps 15 -ovc lavc -oac mp3lame -lameopts cbr:br=128 -lavcopts vcodec=mpeg4:mbd=2:cbp:trell:vbitrate=%d -srate 44100 -vf scale=128:96,expand=:128 -ffourcc XVID - o %s >& /dev/null"
file_count = len(sys.argv) - 1
for i in range(1, file_count + 1):
f = sys.argv[i]
infile = "\"%s\"" % f
fn = f[f.rfind("/") + 1:]
fn = fn[0:fn.rfind(".")]
outfile = "\"%s/%s%s.avi\"" % (OUT_DIR, fn, FILE_POSTFIX)
print "Encoding file: %d of %d" % (i, file_count)
os.system(encode % (MENCODER, infile, BITRATE, outfile))
|