mirror of
https://github.com/ivuorinen/aeonview.git
synced 2026-01-26 03:34:06 +00:00
Reviving an old project
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
projects/*
|
||||||
|
!projects/.gitkeep
|
||||||
12
README.md
12
README.md
@@ -1,9 +1,11 @@
|
|||||||
aeonview
|
_)
|
||||||
========
|
_` | -_) _ \ \ \ \ / | -_) \ \ \ /
|
||||||
|
\__,_| \___| \___/ _| _| \_/ _| \___| \_/\_/
|
||||||
|
aeonview - a simple timelapse tool
|
||||||
|
|
||||||
aeonview is a tool for automagical timelapse-video generation. it works as a glue between
|
aeonview is a tool for automagical timelapse-video generation.
|
||||||
different linux programs to produce videos of elapsing time. works best with webcam-images
|
it works as a glue between different linux programs to produce
|
||||||
from the net.
|
videos of elapsing time. works best with webcam-images from the net.
|
||||||
|
|
||||||
sample:
|
sample:
|
||||||
http://www.youtube.com/watch?v=SnywvnjHpUk
|
http://www.youtube.com/watch?v=SnywvnjHpUk
|
||||||
|
|||||||
194
aeonview.py
194
aeonview.py
@@ -1,4 +1,3 @@
|
|||||||
# $Id$
|
|
||||||
import sys, time, datetime, os, optparse, errno, re
|
import sys, time, datetime, os, optparse, errno, re
|
||||||
|
|
||||||
def aeonview(argv):
|
def aeonview(argv):
|
||||||
@@ -7,86 +6,93 @@ def aeonview(argv):
|
|||||||
it works as a glue between different linux programs to produce
|
it works as a glue between different linux programs to produce
|
||||||
videos of elapsing time. works best with webcam-images from the net.
|
videos of elapsing time. works best with webcam-images from the net.
|
||||||
"""
|
"""
|
||||||
version = re.search('([0-9]+)', '$Revision$')
|
version = "0.1.8"
|
||||||
|
|
||||||
parser = optparse.OptionParser(
|
parser = optparse.OptionParser(
|
||||||
usage='Usage: %prog [options]',
|
usage="Usage: %prog [options]",
|
||||||
description="aeonview for timelapses",
|
description="aeonview for timelapses",
|
||||||
version="%prog 0.1."+version.group(0)
|
version="%prog v"+version
|
||||||
)
|
)
|
||||||
|
|
||||||
basicopts = optparse.OptionGroup(parser,
|
basicopts = optparse.OptionGroup(
|
||||||
"Basic settings",
|
parser, "Basic settings", "These effect in both modes."
|
||||||
"These effect in both modes.")
|
)
|
||||||
basicopts.add_option( "-m", "--mode",
|
|
||||||
default="image",
|
basicopts.add_option("-m", "--mode",
|
||||||
help="run mode: image or video [default: %default]")
|
default="image",
|
||||||
basicopts.add_option( '-p', '--project',
|
help="run mode: image or video [default: %default]")
|
||||||
help="Project name, used as directory name. "
|
|
||||||
"Defaults to 5 characters from md5 hash of the webcam url.",
|
basicopts.add_option("-p", "--project",
|
||||||
type="string" )
|
help="Project name, used as directory name. "
|
||||||
basicopts.add_option( '--dest',
|
"Defaults to 5 characters from md5 hash of the webcam url.",
|
||||||
help="Start of the destination. [default: %default]",
|
type="string")
|
||||||
type="string",
|
|
||||||
default=".",
|
basicopts.add_option("-d", "--dest",
|
||||||
dest="path" )
|
help="Start of the destination. [default: %default]",
|
||||||
|
type="string",
|
||||||
|
default=os.getcwdu()+"/projects",
|
||||||
|
dest="path")
|
||||||
|
|
||||||
|
basicopts.add_option("--mencoder",
|
||||||
|
help="Path to mencoder binary. [default: %default]",
|
||||||
|
type="string",
|
||||||
|
default=os.getcwdu()+'/mencoder')
|
||||||
|
|
||||||
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(
|
||||||
"When we are gathering images.")
|
parser, "Options for --mode: image", "When we are gathering images.")
|
||||||
imageopts.add_option( '--url',
|
|
||||||
help="Webcam URL",
|
imageopts.add_option("--url", help="Webcam URL", type="string")
|
||||||
type="string")
|
|
||||||
parser.add_option_group(imageopts)
|
parser.add_option_group(imageopts)
|
||||||
|
|
||||||
|
|
||||||
# When mode is: video
|
# When mode is: video
|
||||||
videoopts = optparse.OptionGroup(parser, "Options for --mode: video",
|
videoopts = optparse.OptionGroup(parser,
|
||||||
"When we are making movies.")
|
"Options for --mode: video", "When we are making movies.")
|
||||||
videoopts.add_option( '--videorun',
|
|
||||||
default="daily",
|
videoopts.add_option("--videorun",
|
||||||
help="Video to process: daily or monthly [default: %default]",
|
default="daily",
|
||||||
type="string")
|
help="Video to process: daily, monthly or yearly [default: %default]",
|
||||||
videoopts.add_option( '--gen-day',
|
type="string")
|
||||||
help="Date to video. Format: YYYY-MM-DD. "
|
videoopts.add_option('--generate',
|
||||||
"Default is calculated yesterday, currently %default",
|
help="Date to video. Format: YYYY-MM-DD. "
|
||||||
type="string",
|
"Default is calculated yesterday, currently %default",
|
||||||
default=datetime.date.today()-datetime.timedelta(1) )
|
type="string",
|
||||||
# TODO: mode for monthly videos
|
default=datetime.date.today()-datetime.timedelta(1))
|
||||||
#videoopts.add_option( '--gen-month',
|
|
||||||
# help="Month to video. Format: YYYY-MM. "
|
# TODO: mode for monthly videos
|
||||||
# "Default is last month, currently %default",
|
#videoopts.add_option("--gen-month",
|
||||||
# type="string",
|
# help="Month to video. Format: YYYY-MM. "
|
||||||
# default=datetime.date.today()-datetime.timedelta(30) )
|
# "Default is last month, currently %default",
|
||||||
videoopts.add_option( '--fps',
|
# type="string",
|
||||||
default="10",
|
# default=datetime.date.today()-datetime.timedelta(30))
|
||||||
help="Frames per second, numeric [default: %default]",
|
|
||||||
type="int")
|
videoopts.add_option("--fps",
|
||||||
|
default="10",
|
||||||
|
help="Frames per second, numeric [default: %default]",
|
||||||
|
type="int")
|
||||||
|
|
||||||
parser.add_option_group(videoopts)
|
parser.add_option_group(videoopts)
|
||||||
|
|
||||||
|
|
||||||
parser.add_option("-v", help="Verbose", action="store_true", dest="verbose", default=False)
|
parser.add_option("-v", help="Verbose", action="store_true", dest="verbose", default=False)
|
||||||
parser.add_option("-q", help="Quiet", action="store_false", dest="verbose", default=True)
|
parser.add_option("-q", help="Quiet", action="store_false", dest="verbose", default=True)
|
||||||
|
|
||||||
parser.add_option( '-s', '--simulate',
|
parser.add_option("-s", "--simulate",
|
||||||
help="Demostrates what will happen "
|
help="Demostrates what will happen (good for checking your settings and destinations)",
|
||||||
"(good for checking your settings and destinations)",
|
default=False,
|
||||||
default=False,
|
action="store_true")
|
||||||
action="store_true" )
|
|
||||||
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args(argv[1:])
|
(options, args) = parser.parse_args(argv[1:])
|
||||||
|
|
||||||
if options.simulate == True:
|
if options.simulate == True:
|
||||||
print
|
print
|
||||||
print "--- Starting simulation, just echoing steps using your parameters."
|
print "--- Starting simulation, just echoing steps using your parameters."
|
||||||
print
|
print
|
||||||
print "(!) You are running aeonview from", os.getcwdu(), "as the user", os.getlogin()
|
print "(!) You are running aeonview from", os.getcwdu()
|
||||||
|
|
||||||
if options.path == ".":
|
|
||||||
options.path = os.path.realpath(".")
|
|
||||||
|
|
||||||
|
|
||||||
if options.mode == 'image':
|
if options.mode == 'image':
|
||||||
# We are now in the gathering mode.
|
# We are now in the gathering mode.
|
||||||
@@ -108,9 +114,9 @@ def aeonview(argv):
|
|||||||
if options.verbose == True or options.simulate == True:
|
if options.verbose == True or options.simulate == True:
|
||||||
print "(!) No project defined, using part of md5-hash of the webcam url:", options.project
|
print "(!) No project defined, using part of md5-hash of the webcam url:", options.project
|
||||||
|
|
||||||
if options.path == None or options.path == ".":
|
if options.path == None:
|
||||||
if options.verbose == True or options.simulate == True:
|
if options.verbose == True or options.simulate == True:
|
||||||
print "(!) No destination defined, using:", options.path
|
print "(!) No destination defined, using:", options.path
|
||||||
else:
|
else:
|
||||||
if options.verbose == True or options.simulate == True:
|
if options.verbose == True or options.simulate == True:
|
||||||
print "(!) Using destination:", options.path
|
print "(!) Using destination:", options.path
|
||||||
@@ -120,30 +126,25 @@ def aeonview(argv):
|
|||||||
options.imgname = time.strftime("%H-%M-%S")
|
options.imgname = time.strftime("%H-%M-%S")
|
||||||
|
|
||||||
# Let us build the destination path and filename
|
# 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
|
||||||
#if options.fileext not in ['jpg', 'png', 'gif']:
|
|
||||||
# options.fileext = "jpg"
|
|
||||||
|
|
||||||
options.destdir = options.path + "/" + options.project + options.imgpath
|
|
||||||
options.destination = options.destdir + options.imgname + options.fileext
|
options.destination = options.destdir + options.imgname + options.fileext
|
||||||
getit = '"' + options.url + '" > "' + options.destination + '"'
|
getit = options.url + " -o " + options.destination
|
||||||
|
|
||||||
# Crude, but works.
|
# Crude, but works.
|
||||||
if options.simulate == False:
|
if options.simulate == False:
|
||||||
#mkdir_p( options.destdir )
|
os.system("curl --create-dirs --silent %s" % getit)
|
||||||
os.system('curl --create-dirs --silent %s' % getit)
|
|
||||||
else:
|
else:
|
||||||
print "(!) Simulation: Making path:", options.destdir
|
print "(!) Simulation: Making path:", options.destdir
|
||||||
print "(!) Simulation: curl", getit
|
print "(!) Simulation: curl (--create-dirs and --silent)", getit
|
||||||
#print options
|
|
||||||
|
|
||||||
elif options.mode == 'video':
|
elif options.mode == "video":
|
||||||
# We are now in the video producing mode
|
# We are now in the video producing mode
|
||||||
|
|
||||||
vid_extension = ".avi"
|
vid_extension = ".avi"
|
||||||
m = os.getcwd() + "/mencoder"
|
#m = os.getcwd() + "/mencoder"
|
||||||
mencoder = m + " -mf fps="+ str(options.fps) +" -nosound -ovc lavc -lavcopts vcodec=mpeg4"
|
m = options.mencoder
|
||||||
|
mencoder = m + " -really-quiet -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."
|
||||||
@@ -153,16 +154,18 @@ def aeonview(argv):
|
|||||||
|
|
||||||
|
|
||||||
if options.videorun == "daily":
|
if options.videorun == "daily":
|
||||||
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+"/img/"+year+"-"+month+"/"+day+"/*"
|
proj_dir = options.path + "/" + options.project
|
||||||
video_out_dir = options.path +"/"+ options.project +"/vid/"+ year +"-"+ month +"/"
|
video_dir = proj_dir + "/img/" + year + "-" + month + "/" + day + "/*"
|
||||||
|
video_out_dir = proj_dir + "/vid/" + year + "-" + month + "/"
|
||||||
video_out_day = video_out_dir + day + vid_extension
|
video_out_day = video_out_dir + day + vid_extension
|
||||||
command = mencoder + " -o " + video_out_day + " 'mf://"+os.path.dirname( os.path.realpath( video_dir ) ) + "/*'"
|
mfdir = os.path.dirname(os.path.realpath(video_dir))
|
||||||
|
command = mencoder + " -o " + video_out_day + " 'mf://" + mfdir + "/*'"
|
||||||
|
|
||||||
if options.simulate == False:
|
if options.simulate == False:
|
||||||
mkdir_p( video_out_dir )
|
mkdir_p( video_out_dir )
|
||||||
@@ -177,28 +180,29 @@ def aeonview(argv):
|
|||||||
print "(!) Error: check your date. Value provided:", options.generate
|
print "(!) Error: check your date. Value provided:", options.generate
|
||||||
|
|
||||||
elif options.videorun == "monthly":
|
elif options.videorun == "monthly":
|
||||||
print "Monthly"
|
print "Monthly: TODO"
|
||||||
# TODO Monthly script. Joins daily movies of that month
|
# TODO Monthly script. Joins daily movies of that month.
|
||||||
|
|
||||||
|
elif options.videorun == "yearly":
|
||||||
|
print "Yearly: TODO"
|
||||||
|
# TODO Yearly script. Joins monthly movies together.
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "(!) What? Please choose between -r daily/montly"
|
print "(!) What? Please choose between -r daily/montly/yearly"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python/600612#600612
|
# http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python/600612#600612
|
||||||
#def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
# try:
|
try:
|
||||||
# os.makedirs(path)
|
os.makedirs(path)
|
||||||
# except OSError as exc: # Python >2.5
|
except OSError as exc: # Python >2.5
|
||||||
# if exc.errno == errno.EEXIST:
|
if exc.errno == errno.EEXIST:
|
||||||
# pass
|
pass
|
||||||
# else: raise
|
else: raise
|
||||||
|
|
||||||
|
|
||||||
# Modified http://markmail.org/message/k2pxsle2lslrmnut
|
# Modified http://markmail.org/message/k2pxsle2lslrmnut
|
||||||
@@ -216,4 +220,4 @@ def check_date(year, month, day):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
aeonview(sys.argv)
|
aeonview(sys.argv)
|
||||||
|
|||||||
4
example.sh
Executable file
4
example.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
python aeonview.py -p abc-la --url http://abclocal.go.com/three/kabc/webcam/web2-1.jpg
|
||||||
|
|
||||||
0
projects/.gitkeep
Normal file
0
projects/.gitkeep
Normal file
Reference in New Issue
Block a user