PYTHON   23

time lapse py

Guest on 25th August 2022 04:43:13 AM

  1. import os
  2. import subprocess
  3.  
  4. WIDTH = "1280"
  5. HEIGHT = "720"
  6. DURATION = "60000" # duration in milliseconds. E.G 30000 = 30 seconds
  7. FREQUENCY = "2000" # images to capture per milliseconds E.G 1000 = 1 frame per second
  8. PIC_DIR = "/home/pi/time-lapse/pics/"
  9. WORKING_DIR = "/home/pi/time-lapse/"
  10. IMG_NAME = "image%04d.jpg"
  11.  
  12. FRAMERATE = "2"
  13. MOVIE_FILE = "movie.avi"
  14. YTUBE_TITLE = "Raspberry Pi YouTube Upload"
  15.  
  16. snapCommand = "raspistill -t " + DURATION + " -tl " +  FREQUENCY + " -w " + WIDTH +  " -h " + HEIGHT + " -o " + PIC_DIR + IMG_NAME
  17. #ret = os.popen(snapCommand, "r")
  18. ret = subprocess.call(snapCommand, shell=True)
  19.  
  20. print "Snapshots Done\n"
  21.  
  22. os.chdir(PIC_DIR)
  23.  
  24. vidCommand = "mencoder \"mf://*.jpg\"  -mf fps=" + FRAMERATE + ":type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:vbitrate=3000 -vf scale=" + WIDTH + ":" + HEIGHT +" -oac copy -o " + MOVIE_FILE
  25.  
  26. ret = subprocess.call(vidCommand, shell=True)
  27.  
  28. print "Video Done\n"
  29.  
  30. os.chdir(WORKING_DIR)
  31.  
  32. ytubeCommand = "sudo python upload_video.py --file=" + PIC_DIR + MOVIE_FILE + " --title=\"Raspberry Pi YouTube Upload\" --description=\"This video was uploaded by my Raspberry Pi\" --category=28 --keywords=\"Raspberry Pi,Python,camera\" --privacyStatus=public"
  33.  
  34. ret = subprocess.call(ytubeCommand, shell=True)
  35.  
  36. print "Video Uploaded to YouTube\n"

Raw Paste


Login or Register to edit or fork this paste. It's free.