canon-vid
#!/usr/bin/env python
# canon-vid
# Rotates and reencodes videos from Canon digital cameras
#
# Copyright Tom Chance, 2003
# Released under the GNU General Pulic License
# See http://www.gnu.org/licenses/gpl.html for details
import os, sys, re
def encode(url,rotate=0):
if not rotate:
rotate_text = ""
else:
rotate_text= "rotate=1 "
cmd = "".join(["mencoder ", url, " -vop ", rotate_text, "-channels 1 -srate 11025 -oac mp3lame
-lameopts mode=3:abr:br=32 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=496 -o ", url,
"2 2&>/dev/null >/dev/null"])
# print cmd
os.popen(cmd)
def find_videos(rotate=0):
if not rotate:
print "* Finding normal videos"
videos = os.popen("ls MVI_*.AVI").readlines()
else:
print "* Finding rotates videos"
videos = os.popen("ls MVI_*.AVI_R").readlines()
for video in videos:
url = re.compile("(.*)").search(video).group(1)
print "Working on %s" % (url)
encode(url, rotate)
def main():
print "* Canon-vid, copyright Tom Chance 2003"
find_videos()
find_videos(1)
print "* All done"
if __name__ == "__main__":
main()