Worked on video-mode, should work now

This commit is contained in:
Ismo Vuorinen
2010-07-25 09:51:29 +00:00
parent a3e16e6060
commit 6f11436459

View File

@@ -20,14 +20,14 @@ def aeonview(argv):
"Defaults to 5 characters from md5 hash of the webcam url.", "Defaults to 5 characters from md5 hash of the webcam url.",
type="string" ) type="string" )
basicopts.add_option( '-d', '--destination', basicopts.add_option( '-d', '--destination',
help="Start of the path. Optional, defaults to: .", help="Start of the path. [default: %default]",
type="string", type="string",
default=".", default=".",
dest="path" ) dest="path" )
parser.add_option_group(basicopts) parser.add_option_group(basicopts)
# When mode is: image # When mode is: image
imageopts = optparse.OptionGroup(parser, "Options for mode 'image'", imageopts = optparse.OptionGroup(parser, "Options for --mode: image",
"When we are gathering images.") "When we are gathering images.")
imageopts.add_option( '-u', '--url', imageopts.add_option( '-u', '--url',
help="Webcam URL", help="Webcam URL",
@@ -36,7 +36,7 @@ def aeonview(argv):
# When mode is: video # When mode is: video
videoopts = optparse.OptionGroup(parser, "Options for mode 'video'", videoopts = optparse.OptionGroup(parser, "Options for --mode: video",
"When we are making movies.") "When we are making movies.")
videoopts.add_option( '-g', '--generate', videoopts.add_option( '-g', '--generate',
help="Date to video. Format: YYYY-MM-DD. " help="Date to video. Format: YYYY-MM-DD. "
@@ -47,9 +47,9 @@ def aeonview(argv):
default="daily", default="daily",
help="Video to process: daily or monthly [default: %default]", help="Video to process: daily or monthly [default: %default]",
type="string") type="string")
videoopts.add_option( '-f', '--faster', videoopts.add_option( '-f', '--fps',
default="10", default="10",
help="Multiplier of video speed, numeric [default: %default]", help="Frames per second, numeric [default: %default]",
type="int") type="int")
parser.add_option_group(videoopts) parser.add_option_group(videoopts)
@@ -72,6 +72,7 @@ def aeonview(argv):
print print
print "(!) You are running aeonview from", os.getcwdu(), "as the user", os.getlogin() print "(!) You are running aeonview from", os.getcwdu(), "as the user", os.getlogin()
if options.mode == 'image': if options.mode == 'image':
# We are now in the gathering mode. # We are now in the gathering mode.
@@ -103,7 +104,7 @@ def aeonview(argv):
options.imgpath = time.strftime("/img/%Y-%m/%d/") options.imgpath = time.strftime("/img/%Y-%m/%d/")
options.imgname = time.strftime("%H-%M-%S") options.imgname = time.strftime("%H-%M-%S")
# Let's rock # Let us build the destination path and filename
options.fileext = os.path.splitext(options.url)[1] options.fileext = os.path.splitext(options.url)[1]
options.destdir = options.path + "/" + options.project + options.imgpath options.destdir = options.path + "/" + options.project + options.imgpath
options.destination = options.destdir + options.imgname + options.fileext options.destination = options.destdir + options.imgname + options.fileext
@@ -118,17 +119,12 @@ def aeonview(argv):
print "(!) Simulation: curl", getit print "(!) Simulation: curl", getit
#print options #print options
elif options.mode == 'video': elif options.mode == 'video':
if options.faster < 1:
options.faster = 1 # Never gonna let you multiply by zero.
# We are now in the video producing mode # We are now in the video producing mode
videofps = options.faster * 25 # = 25fps * multiplier
vid_extension = ".avi" vid_extension = ".avi"
mencoder = os.getcwd() + "/mencoder" m = os.getcwd() + "/mencoder"
mencoder = mencoder + " -mf fps="+vidfps+" -nosound -ovc lavc -lavcopts vcodec=mpeg4" mencoder = m + " -mf fps="+ str(options.fps) +" -nosound -ovc lavc -lavcopts vcodec=mpeg4"
if options.project == None: if options.project == None:
print "(!) No project defined, please specify what project you are working on." print "(!) No project defined, please specify what project you are working on."
@@ -138,19 +134,25 @@ def aeonview(argv):
if options.videorun == "daily": if options.videorun == "daily":
#options.generate = "2010-13-01"
vid_date = str(options.generate).split( "-" ) vid_date = str(options.generate).split( "-" )
year = vid_date[0] year = vid_date[0]
month = vid_date[1] month = vid_date[1]
day = vid_date[2] day = vid_date[2]
if check_date(int(year), int(month), int(day)): if check_date(int(year), int(month), int(day)):
video_dir = options.path + "/" + options.project + "/vid/" + year + "-" + month + "/" + day + "/*" video_dir = options.path+"/"+options.project+"/img/"+year+"-"+month+"/"+day+"/*"
print "Video dir to process:", video_dir video_out_dir = options.path +"/"+ options.project +"/vid/"+ year +"-"+ month +"/"
video_out_day = options.path + "/" + options.project + "/vid/" + year + "-" + month + "/" + day + vid_extension video_out_day = video_out_dir + day + vid_extension
print "Video output-file: ", video_out_day command = mencoder + " -o " + video_out_day + " 'mf://"+os.path.dirname( os.path.realpath( video_dir ) ) + "/*'"
print mencoder, "-o", video_out_day, "'mf://"+os.path.dirname( os.path.realpath( video_dir ) ) + "/*'"
if options.simulate == False:
mkdir_p( video_out_dir )
os.system(command)
else:
print "(!) Video dir to process:", video_dir
print "(!) Video output-file: ", video_out_day
print "(!) Command to run", command
else: else:
print "(!) Error: check your date. Value provided:", options.generate print "(!) Error: check your date. Value provided:", options.generate
@@ -158,9 +160,7 @@ def aeonview(argv):
print "Monthly" print "Monthly"
else: else:
pass print "(!) What? Please choose between -r daily/montly"
pass
else: else:
parser.print_help() parser.print_help()