Jump to content

I have a Raspberry Pi project where I 'm taking a time lapse series


G+_James Hughes
 Share

Recommended Posts

I have a Raspberry Pi project where I'm taking a time lapse series. I found some code online and it works up to a point. Problem is I get an error when running the code. I was hoping to get some insight (and help).

 

Here is the error message:

 

converting to film now

sh: 1: avconv: not found

moving completed mp4 file

mv: cannot stat ‘*.mp4’: No such file or directory

 

Here is the code:

 

#!/usr/bin/python

# BEFORE USING THIS SCRIPT.

# mkdir ~/timelapse

# mkdir ~/timelapse/completed

# this file should live in ~/timelapse and is run with command "python ~/timelapse/timelapse.py

 

import time

from picamera import PiCamera

from os import system

 

camera = PiCamera()

camera.resolution = (1920, 1080)

# my camera was flipped and upside down - this fixes that

camera.vflip = True

camera.hflip = True

 

SleepTimeL = 1

FrameCount = 0

FrameStop = 240

 

WAIT = int(FrameStop)*int(SleepTimeL)/60

 

print('Photography will take approximately ' + str(WAIT) + ' minutes')

print('Taking photos now')

while (FrameCount < FrameStop):

print('Picture:' + str(FrameCount) + ' of ' + str(FrameStop))

camera.capture('image' + str(FrameCount).zfill(4) + '.jpg')

time.sleep(SleepTimeL);

FrameCount = FrameCount + 1

 

# create film

print('converting to film now')

system('avconv -r 24 -i image%04d.jpg -vcodec libx264 -crf 20 -g 15 `date +%Y%m%d%H%M`timelapse.mp4')

 

# create film

print('moving completed mp4 file')

system('mv *.mp4 ~/timelapse/completed/')

 

print('cleaning up old jpgs')

system('rm *.jpg')

 

print('done')

 

Link to comment
Share on other sites

Is avconv installed? To install it you can do: sudo apt-get install avconv.

 

I'm not sure why it is erroring out on moving the jpg files. Did you do the "mkdir ~/timelapse/completed" like the notes say at the top?

 

Hopefully something there will point you the right direction.

Link to comment
Share on other sites

Could you make sure that the directory and or file has the proper rights when originally created? I once did this where I created directories as root then ran the script as pi user (silly mistake but we are human)

 

# BEFORE USING THIS SCRIPT.

# mkdir ~/timelapse

# mkdir ~/timelapse/completed

# this file should live in ~/timelapse and is run with command "python ~/timelapse/timelapse.py

Link to comment
Share on other sites

The code has the pi taking one picture per second. I'd like to get it up to the maximum capture which is supposed to be 90 per second (at 1280 x 720). I haven't gotten there yet as I'm about to try some of the suggestions above. But I'm not sure it will work if I put a float instead of an int. I'll give it a try and report back. Thanks again!

Link to comment
Share on other sites

David Peach So I tried to install avconv and well...

this is what I got:

sudo apt-get install avconv

Reading package lists... Done

Building dependency tree

Reading state information... Done

E: Unable to locate package avconv

 

I'm going to try running the script again and see if this has helped, but the last line gives me some doubts. (fingers crossed, lol)

Link to comment
Share on other sites

Ben Reese Thanks, I tried that with no luck. Did a little digging and discovered some references to avconv being the 'fake' ffmpeg. So now I'm installing ffmpeg. Time to do a little digging to see if I can find out how to accomplish this with ffmpeg (which is what I thought I would be using before I started looking for code to 'borrow'.

Link to comment
Share on other sites

Well I finally got it installed (had to take a pool break) now to try to update the script for FFMPEG. I agree with you that I don't think avconv is a fake, just repeating what I read online (always dangerous). They talked about them being competing standards and someone else was complaining because Jessie no longer contains ffmpeg. It's supposed to have avconv, I'm just not getting any love from it. Well back to the coal mines. :)

Link to comment
Share on other sites

 Share

×
×
  • Create New...