G+_James Hughes Posted July 19, 2017 Share Posted July 19, 2017 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 More sharing options...
G+_David Peach Posted July 19, 2017 Share Posted July 19, 2017 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 More sharing options...
G+_Ellis Malave Posted July 19, 2017 Share Posted July 19, 2017 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 More sharing options...
G+_Ben Reese Posted July 19, 2017 Share Posted July 19, 2017 Also check caps on your folders. "timelapse/Completed" != "timelapse/completed" Link to comment Share on other sites More sharing options...
G+_James Hughes Posted July 19, 2017 Author Share Posted July 19, 2017 David Peach I'm not sure if avconv is installed, great idea. All directories made as per instructions. I'll try installing avconv and running it again. Thanks! Link to comment Share on other sites More sharing options...
G+_James Hughes Posted July 19, 2017 Author Share Posted July 19, 2017 Ellis Malave I'm SSHing in to the pi and running it as sudo (which is how I created the file). Thanks for the input, I'll keep it in mind as I troubleshoot it today. Link to comment Share on other sites More sharing options...
G+_James Hughes Posted July 19, 2017 Author Share Posted July 19, 2017 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 More sharing options...
G+_James Hughes Posted July 19, 2017 Author Share Posted July 19, 2017 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 More sharing options...
G+_Ben Reese Posted July 19, 2017 Share Posted July 19, 2017 I don't believe avconv has a stand-alone package, but it's part of libav-tools. And I have a link pulled up with more info about it, but I can't find this conversation on the web-version of G+. sudo apt-get install libav-tools Link to comment Share on other sites More sharing options...
G+_James Hughes Posted July 19, 2017 Author Share Posted July 19, 2017 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 More sharing options...
G+_Ben Reese Posted July 19, 2017 Share Posted July 19, 2017 James Hughes I don't think avconv is a "fake", I think it's a renaming of ffmpeg. But FFMPEG should do the exact same for you if you get it installed - just update your script accordingly. Link to comment Share on other sites More sharing options...
G+_James Hughes Posted July 19, 2017 Author Share Posted July 19, 2017 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 More sharing options...
Recommended Posts