from picamera import PiCamera
from time import sleep
from datetime import datetime
from subprocess import call
import os

name = 'test_30fps_highres'
camera = PiCamera()
#camera.resolution = (640,480)
#camera.framerate = 30

now = datetime.now()
curr = now.strftime('%H-%M-%S')
name = './'+curr+'_'+name

camera.start_preview()
camera.start_recording(name+'.h264')
sleep(10)
camera.stop_recording()
camera.stop_preview()

print("Converting video to mp4")
command = "ffmpeg -r "+str(camera.framerate)+" -i "+name+".h264 -vcodec copy "+name+".mp4"
call([command], shell=True)
os.remove(name+".h264")
print("Done")