Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions DuetLapse.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ def unPause():
alreadyPaused = False

def onePhoto():

global frame
fname=printer.getFile()
# print (fname)
frame += 1
s="{0:08d}".format(int(np.around(frame)))
fn = '/tmp/DuetLapse/IMG'+s+'.jpeg'
fn = '/tmp/DuetLapse/'+fname+'.'+s+'.jpeg'

if ('usb' in camera):
if (camparms == ''):
Expand Down Expand Up @@ -257,13 +260,14 @@ def oneInterval():

def postProcess():
print()
fname=printer.getFile()
print("Now making {0:d} frames into a video at 10 frames per second.".format(int(np.around(frame))))
if (250 < frame): print("This can take a while...")
fn ='~/DuetLapse'+time.strftime('%m%d%y%H%M',time.localtime())+'.mp4'
fn ='~/'+fname+'.DuetLapse'+time.strftime('%m%d%y%H%M',time.localtime())+'.mp4'
if (vidparms == ''):
cmd = 'ffmpeg -r 10 -i /tmp/DuetLapse/IMG%08d.jpeg -vcodec libx264 -y -v 8 '+fn
cmd = 'ffmpeg -r 10 -i /tmp/DuetLapse/'+fname+'.%08d.jpeg -vcodec libx264 -y -v 8 '+fn
else:
cmd = 'ffmpeg '+vidparms+' -i /tmp/DuetLapse/IMG%08d.jpeg '+fn
cmd = 'ffmpeg '+vidparms+' -i /tmp/DuetLapse/'+fname+'.%08d.jpeg '+fn
subprocess.call(cmd, shell=True)
print('Video processing complete.')
print('Video file is in home directory, named '+fn)
Expand Down Expand Up @@ -292,8 +296,11 @@ def postProcess():
try:
while(1):
time.sleep(.77) # Intentionally not evenly divisible into one second.
status=printer.getStatus()

try:
status=printer.getStatus()
except:
print("Could Not Connect") #Skips the current Frame without killing script

if (printerState == 0): # Idle before print started.
if (dontwait):
oneInterval()
Expand Down