#!/usr/bin/env python
import cgi, sys, datetime
import cgitb; cgitb.enable()
import subprocess
print "Content-type: text/html"
print
print "hello from python
"
n = datetime.datetime.now()
basename = n.strftime("%Y-%m-%dT%H-%M-%S")
o1 = subprocess.check_output(["scripts/black2.py", "--output", basename+".avi", "--time", "5"])
print o1 + "
\n"
o2 = subprocess.check_output(["ffmpeg", "-i", basename+".avi", "-y", basename+".mp4"])
print o2 + "
\n"
o2 = subprocess.check_output(["ffmpeg", "-i", basename+".avi", "-ss", "1", "-vframes", "1", "-y", basename+".jpg"])
print o2 + "
\n"
# print """VIDEO""".format(basename)
print """OK"""