commit 9575260f2d44f6865fd23c97c7c16f9d8be1c5ca
parent 98b8e46e0d9eac573fbd85dbce858c29aa985c4d
Author: rbckman <rbckman@rbckman>
Date: Thu, 6 Sep 2018 19:55:02 +0300
unused things removed
Diffstat:
29 files changed, 0 insertions(+), 2766 deletions(-)
diff --git a/extras/mcp23017_pinout.png b/extras/mcp23017_pinout.png
Binary files differ.
diff --git a/random/alsaout.wav b/random/alsaout.wav
Binary files differ.
diff --git a/random/audiosync.py b/random/audiosync.py
@@ -1,39 +0,0 @@
-#!/bin/env python
-
-import os
-import time
-import sys
-import subprocess
-
-pipe = subprocess.Popen('mediainfo --Inform="Video;%Duration%" test.mp4', shell=True, stdout=subprocess.PIPE).stdout
-videolenght = pipe.read()
-pipe = subprocess.Popen('mediainfo --Inform="Audio;%Duration%" test.wav', shell=True, stdout=subprocess.PIPE).stdout
-audiolenght = pipe.read()
-print "Videolenght: " + videolenght
-print "Audiolenght: " + audiolenght
-
-videoms = int(videolenght) % 1000
-audioms = int(audiolenght) % 1000
-
-print videoms
-print audioms
-
-videos = int(videolenght) / 1000
-audios = int(audiolenght) / 1000
-
-print 'Video is ' + str(videos) + ' sec and ' + str(videoms) + ' ms long'
-print 'Audio is ' + str(audios) + ' sec and ' + str(audioms) + ' ms long'
-
-audiosyncs = videos - audios
-audiosyncms = videoms - audioms
-
-if audiosyncms < 0:
- audiosyncs = audiosyncs - 1
- audiosyncms = 1000 + audiosyncms
-
-print "Difference: " + str(audiosyncs) + " s " + str(audiosyncms) + " ms"
-
-os.system('sox -n -r 44100 -c 1 silence.wav trim 0.0 ' + str(audiosyncs) + '.' + str(audiosyncms))
-
-#os.system('mediainfo --Inform="Video;%Duration%" scene10.mp4')
-#os.system('mediainfo --Inform="Audio;%Duration%" scene10.wav')
diff --git a/random/bak.ninjacam.py b/random/bak.ninjacam.py
@@ -1,368 +0,0 @@
-#/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import picamera
-import os
-import time
-from subprocess import call
-import subprocess
-import sys
-import cPickle as pickle
-import curses
-import RPi.GPIO as GPIO
-
-GPIO.setmode(GPIO.BCM)
-GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-os.system('clear')
-
-#--------------Save settings-----------------
-
-def savesetting(brightness, contrast, saturation, shutter_speed, iso, awb_mode, awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take):
- settings = brightness, contrast, saturation, shutter_speed, iso, awb_mode, awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take
- pickle.dump(settings, open(filmfolder + "settings.p", "wb"))
- pickle.dump(settings, open(filmfolder + filmname + "/settings.p", "wb"))
-
-#--------------Load settings-----------------
-
-def loadsettings(filmfolder, filmname):
- try:
- if filmname == '':
- settings = pickle.load(open(filmfolder + "settings.p", "rb"))
- else:
- settings = pickle.load(open(filmfolder + filmname + "/settings.p", "rb"))
- return settings
- except:
- print "no settings"
-
-#--------------Write the menu layer to dispmax--------------
-
-def writemenu(menu,settings,selected,header):
- c = 0
- clear = 275
- menudone = ''
- if header != '':
- spaces = 55 - len(header)
- header = header + (spaces * ' ')
- for a in menu:
- if c == selected:
- menudone = menudone + '<'
- else:
- menudone = menudone + ' '
- menudone = menudone + menu[c] + settings[c]
- if c == selected:
- menudone = menudone + '>'
- else:
- menudone = menudone + ' '
- c = c + 1
- if len(menudone) > 20:
- spaces = 55 - len(menudone)
- menudone = menudone + spaces * '-'
- if len(menudone) > 90:
- spaces = 110 - len(menudone)
- menudone = menudone + spaces * '-'
- if len(menudone) > 135:
- spaces = 165 - len(menudone)
- menudone = menudone + spaces * '-'
- if len(menudone) > 210:
- spaces = 220 - len(menudone)
- menudone = menudone + spaces * '-'
- f = open('interface.txt', 'rw+')
- clear = clear - len(menudone)
- f.write(header + menudone + clear * ' ')
- f.close()
-
-#------------Write to screen----------------
-
-def writemessage(message):
- clear = 275
- clear = clear - len(message)
- f = open('interface.txt', 'rw+')
- f.write(message + clear * ' ')
- f.close()
-
-#-------------New film----------------
-
-def nameyourfilm():
- abc = 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
- abcx = 0
- name = ''
- thefuck = ''
- while True:
- message = 'Name Your Film: ' + name + abc[abcx]
- spaces = 55 - len(message)
- writemessage(message + (spaces * ' ') + thefuck)
- time.sleep(0.2)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if upbutton == False:
- if abcx < (len(abc) - 1):
- abcx = abcx + 1
- if downbutton == False:
- if abcx > 0:
- abcx = abcx - 1
- if rightbutton == False:
- if len(name) < 10:
- name = name + abc[abcx]
- else:
- thefuck = 'Yo, maximum characters reached bro!'
- if leftbutton == False:
- if len(name) > 0:
- name = name[:-1]
- thefuck = ''
- if middlebutton == False:
- return(name)
-
-#------------Happy with take or not?------------
-
-def happyornothappy(camera, filmfolder, filmname, filename, scene, shot, take):
- header = 'Are You Happy with Your Take? Retake if not!'
- menu = '', '', '', ''
- settings = 'VIEWTAKE', "NEXTSHOT", "RETAKE", "SCENEDONE"
- selected = 0
- play = False
- writemessage('Converting video, hold your horses...')
- thefile = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(2) + '/' + filename
- call(['avconv', '-y', '-i', thefile + '.wav', '-acodec', 'ac3', thefile + '.ac3'], shell=False)
- call(['MP4Box', '-add', thefile + '.h264', '-add', thefile + '.ac3', '-new', thefile + '.mp4'], shell=False)
- while True:
- time.sleep(0.1)
- writemenu(menu,settings,selected,header)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if rightbutton == False:
- if selected < (len(settings) - 1):
- selected = selected + 1
- if leftbutton == False:
- if selected > 0:
- selected = selected - 1
- if middlebutton == False:
- if selected == 0:
- writemessage('Hold on, video loading...')
- camera.stop_preview()
- time.sleep(1)
- player = subprocess.Popen(['omxplayer', '--layer', '3', '--fps', '25' , thefile + '.mp4'], shell=True)
- play = True
- time.sleep(1)
- while player.poll() != 0:
- middlebutton = GPIO.input(5)
- if middlebutton == False:
- player.kill()
- os.system('pkill -9 omxplayer')
- time.sleep(2)
- camera.start_preview()
- if selected == 1:
- take = 1
- shot = shot + 1
- return scene, shot, take, thefile
- if selected == 2:
- take = take + 1
- return scene, shot, take, ''
-
-
-
-#-------------Start main--------------
-
-def main():
- filmfolder = "/home/pi/Videos/"
- filename = "ninjacam"
- ##---------Count film files-----------
- files = os.listdir(filmfolder)
- filename_count = len(files)
- screen = curses.initscr()
- curses.cbreak(1)
- screen.keypad(1)
- curses.noecho()
- screen.nodelay(1)
- curses.curs_set(0)
- time.sleep(1)
- # prep picamera
- with picamera.PiCamera() as camera:
- camera.resolution = (1920, 816)
- camera.crop = (0, 0, 1.0, 1.0)
- # display preview
- time.sleep(1)
- camera.start_preview()
- os.system('clear')
- #time.sleep(1)
- # call fbcp, dispmax and arecord
- call (['/home/pi/ninjacam/fbcp &'], shell = True)
- call (['./startinterface.sh &'], shell = True)
- screen.clear()
- menu = 'MIDDLEBUTTON: ', 'BRI:', 'CON:', 'SAT:', 'SHUTTER:', 'ISO:', 'AWB:', 'LOCKAWB:', 'MIC:', 'PHONES:', 'WBG:', 'DSK:', 'FILM:', 'SCENE:', 'SHOT:', 'TAKE', '', ''
- if filename_count > 0:
- actionmenu = 'Record', 'View Last', 'View Scene', 'The Trash Room', 'Upload Film to lulzcam.org', 'New Film'
- else:
- actionmenu = 'Start Shooting a New Movie'
- selectedaction = 0
- selected = 0
- camera.framerate = 25
- awb = 'auto', 'sunlight', 'cloudy', 'shade', 'tungsten', 'fluorescent', 'incandescent', 'flash', 'horizon'
- awbx = 0
- awb_lock = 'no'
- headphoneslevel = 50
- miclevel = 50
- recording = False
- retake = False
- rectime = ''
- showrec = ''
- scene = 1
- shot = 1
- take = 1
- filmname = ''
- filmfiles = []
- filmnames = os.listdir(filmfolder)
- buttonpressed = time.time()
- disk = os.statvfs('/home/pi/ninjacam/')
- diskleft = str(disk.f_bavail * disk.f_frsize / 1024 / 1024 / 1024) + 'Gb'
- #load settings
- try:
- camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take = loadsettings(filmfolder, filmname)
- except:
- print "no settings"
- if filmname == '':
- filmname = nameyourfilm()
- os.system('mkdir -p ' + filmfolder + filmname + '/' + 'scene01/')
- os.system('amixer -c 0 set Mic Capture ' + str(miclevel) + '%')
- os.system('amixer -c 0 set Mic Playback ' + str(headphoneslevel) + '%')
- while True:
- time.sleep(0.1)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- event = screen.getch()
- if event == 27:
- os.system('pkill -9 fbcp')
- os.system('pkill -9 arecord')
- os.system('pkill -9 startinterface')
- os.system('pkill -9 camerainterface')
- curses.nocbreak()
- curses.echo()
- curses.endwin()
- quit()
- elif middlebutton == False and selectedaction == 0 and int(time.time() - buttonpressed) > 1:
- buttonpressed = time.time()
- if recording == False:
- filename = 'scene' + str(scene).zfill(2) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3)
- recording = True
- starttime = time.time()
- camera.start_recording('/mnt/tmp/' + filename + '.h264', format='h264', quality=20)
- arecord = subprocess.Popen(['/home/pi/ninjacam/alsa-utils-1.0.25/aplay/arecord', '-D', 'plughw:0,0', '-f', 'S16_LE', '-c1', '-r44100', '-vv', '/mnt/tmp/' + filename + '.wav'], shell=False)
- #camera.wait_recording(3600)
- else:
- disk = os.statvfs('/home/pi/ninjacam/')
- diskleft = str(disk.f_bavail * disk.f_frsize / 1024 / 1024 / 1024) + 'Gb'
- recording = False
- camera.stop_recording()
- arecord.kill()
- rectime = ''
- showrec = ''
- copyvideo = subprocess.Popen(['mv', '/mnt/tmp/' + filename + '.h264', filmfolder + filmname + '/scene' + str(scene).zfill(2)], shell=False)
- while copyvideo.poll() != 0:
- writemessage('Copying video file...')
- copyaudio = subprocess.Popen(['mv', '/mnt/tmp/' + filename + '.wav', filmfolder + filmname + '/scene' + str(scene).zfill(2)], shell=False)
- while copyaudio.poll() != 0:
- writemessage('Copying audio file...')
- os.system('cp err.log lasterr.log')
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take)
- scene, shot, take, thefile = happyornothappy(camera, filmfolder, filmname, filename, scene, shot, take)
- if thefile != '':
- filmfiles.append(thefile)
- elif event == ord('w') or upbutton == False:
- if selected == 0:
- if selectedaction < (len(actionmenu) - 1):
- selectedaction = selectedaction + 1
- if selected == 1:
- camera.brightness = min(camera.brightness + 1, 99)
- if selected == 2:
- camera.contrast = min(camera.contrast + 1, 99)
- if selected == 3:
- camera.saturation = min(camera.saturation + 1, 99)
- if selected == 4:
- camera.shutter_speed = min(camera.shutter_speed + 510, 50000)
- if selected == 5:
- camera.iso = min(camera.iso + 100, 1600)
- if selected == 6:
- if awbx < 8:
- awbx = awbx + 1
- camera.awb_mode = awb[awbx]
- awb_lock = 'no'
- if selected == 7:
- awb_lock = 'yes'
- g = camera.awb_gains
- camera.awb_mode = 'off'
- camera.awb_gains = g
- if selected == 8:
- if miclevel < 100:
- miclevel = miclevel + 2
- os.system('amixer -c 0 set Mic Capture ' + str(miclevel) + '%')
- if selected == 9:
- if headphoneslevel < 100:
- headphoneslevel = headphoneslevel + 2
- os.system('amixer -c 0 set Mic Playback ' + str(headphoneslevel) + '%')
- elif event == ord('a') or leftbutton == False and buttonrelease == True:
- buttonrelease = False
- if selected > 0:
- selected = selected - 1
- elif event == ord('s') or downbutton == False:
- if selected == 0:
- if selectedaction > 0:
- selectedaction = selectedaction - 1
- if selected == 1:
- camera.brightness = max(camera.brightness - 1, 0)
- if selected == 2:
- camera.contrast = max(camera.contrast - 1, -100)
- if selected == 3:
- camera.saturation = max(camera.saturation - 1, -100)
- if selected == 4:
- camera.shutter_speed = max(camera.shutter_speed - 510, 0)
- if selected == 5:
- camera.iso = max(camera.iso - 100, 0)
- if selected == 6:
- if awbx > 0:
- awbx = awbx - 1
- camera.awb_mode = awb[awbx]
- awb_lock = 'no'
- if selected == 7:
- awb_lock = 'yes'
- g = camera.awb_gains
- camera.awb_mode = 'off'
- camera.awb_gains = g
- if selected == 8:
- if miclevel > 0:
- miclevel = miclevel - 2
- os.system('amixer -c 0 set Mic Capture ' + str(miclevel) + '%')
- if selected == 9:
- if headphoneslevel > 0:
- headphoneslevel = headphoneslevel - 2
- os.system('amixer -c 0 set Mic Playback ' + str(headphoneslevel) + '%')
- elif event == ord('d') or rightbutton == False and buttonrelease == True:
- buttonrelease = False
- if selected < 9:
- selected = selected + 1
- elif leftbutton == True or rightbutton == True:
- buttonrelease = True
- if recording == True:
- showrec = 'RECORDING'
- t = time.time() - starttime
- rectime = time.strftime("%H:%M:%S", time.gmtime(t))
- settings = actionmenu[selectedaction], str(camera.brightness), str(camera.contrast), str(camera.saturation), str(camera.shutter_speed).zfill(5), str(camera.iso), str(camera.awb_mode)[:4], awb_lock, str(miclevel), str(headphoneslevel), str(camera.awb_gains[0]) + ' ' + str(camera.awb_gains[1]), diskleft, filmname, str(scene), str(shot), str(take), showrec, rectime
- header=''
- writemenu(menu,settings,selected,header)
-if __name__ == '__main__':
- import sys
- try:
- main()
- except:
- print 'Unexpected error : ', sys.exc_info()[0], sys.exc_info()[1]
diff --git a/random/buttons.py b/random/buttons.py
@@ -1,32 +0,0 @@
-import RPi.GPIO as GPIO
-import time
-
-GPIO.setmode(GPIO.BCM)
-
-GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-
-while True:
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if middlebutton == False:
- print('Middle')
- time.sleep(0.2)
- if upbutton == False:
- print('Up')
- time.sleep(0.2)
- if downbutton == False:
- print('Down')
- time.sleep(0.2)
- if leftbutton == False:
- print('Left')
- time.sleep(0.2)
- if rightbutton == False:
- print('Right')
- time.sleep(0.2)
diff --git a/random/buzzer.py b/random/buzzer.py
@@ -1,24 +0,0 @@
-import time
-from RPi import GPIO
-
-buzzerrepetitions = 100
-pausetime = 1
-beeps = 3
-
-GPIO.setmode(GPIO.BCM)
-GPIO.setup(1, GPIO.OUT)
-
-while beeps > 1:
- buzzerdelay = 0.0001
- for _ in xrange(buzzerrepetitions):
- for value in [True, False]:
- GPIO.output(1, value)
- time.sleep(buzzerdelay)
- time.sleep(pausetime)
- beeps = beeps - 1
-buzzerdelay = 0.0001
-for _ in xrange(buzzerrepetitions * 10):
- for value in [True, False]:
- GPIO.output(1, value)
- buzzerdelay = buzzerdelay - 0.00000004
- time.sleep(buzzerdelay)
diff --git a/random/freescript.sh b/random/freescript.sh
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-## Stop the ntp service
-sudo service ntp stop
-
-## Stop the triggerhappy service
-sudo service triggerhappy stop
-
-## Stop the dbus service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
-sudo service dbus stop
-
-## Stop the console-kit-daemon service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
-sudo killall console-kit-daemon
-
-## Stop the polkitd service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
-sudo killall polkitd
-
-## Only needed when Jack2 is compiled with D-Bus support (Jack2 in the AutoStatic RPi audio repo is compiled without D-Bus support)
-#export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
-
-## Remount /dev/shm to prevent memory allocation errors
-sudo mount -o remount,size=128M /dev/shm
-
-## Kill the usespace gnome virtual filesystem daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
-killall gvfsd
-
-## Kill the userspace D-Bus daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
-killall dbus-daemon
-
-## Kill the userspace dbus-launch daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
-killall dbus-launch
diff --git a/random/getfilms.py b/random/getfilms.py
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-
-import os
-
-# Get path of the current dir, then use it as working directory:
-rundir = os.path.dirname(__file__)
-if rundir != '':
- os.chdir(rundir)
-
-filmfolder = '/home/pi/Videos/'
-
-films_sorted = []
-films = os.walk(filmfolder).next()[1]
-for i in films:
- if os.path.isfile(filmfolder + i + '/' + 'settings.p') == True:
- lastupdate = os.path.getmtime(filmfolder + i + '/' + 'settings.p')
- films_sorted.append((i,lastupdate))
- else:
- films_sorted.append((i,0))
-films_sorted = sorted(films_sorted, key=lambda tup: tup[1], reverse=True)
-print films_sorted
diff --git a/random/i2cbuttons.py b/random/i2cbuttons.py
@@ -1,31 +0,0 @@
-import wiringpi
-from time import sleep
-
-pin_base = 65 # lowest available starting number is 65
-i2c_addr = 0x20 # A0, A1, A2 pins all wired to GND
-
-wiringpi.wiringPiSetup() # initialise wiringpi
-wiringpi.mcp23017Setup(pin_base,i2c_addr) # set up the pins and i2c address
-
-wiringpi.pinMode(80, 0) # sets GPB7 to input
-wiringpi.pinMode(79, 0) # sets GPB7 to input
-wiringpi.pinMode(78, 0) # sets GPB7 to input
-wiringpi.pinMode(77, 0) # sets GPB7 to input
-wiringpi.pullUpDnControl(80, 2) # set internal pull-up
-wiringpi.pullUpDnControl(79, 2) # set internal pull-up
-wiringpi.pullUpDnControl(78, 2) # set internal pull-up
-wiringpi.pullUpDnControl(77, 2) # set internal pull-up
-
-# Note: MCP23017 has no internal pull-down, so I used pull-up and inverted
-# the button reading logic with a "not"
-
-try:
- while True:
- if not wiringpi.digitalRead(79): # inverted the logic as using pull-up
- print "button is pressed!!" # sets port GPA1 to 1 (3V3, on)
- else:
- print "no buttons pressed" # sets port GPA1 to 0 (0V, off)
- sleep(0.01)
-finally:
- print "fuck" # sets port GPA1 to 0 (0V, off)
- # GPB7 is already an input, so no need to change anything
diff --git a/random/i2cpython.py b/random/i2cpython.py
@@ -1,21 +0,0 @@
-import smbus
-import time
-
-bus = smbus.SMBus(1) # Rev 2 Pi uses 1
-
-DEVICE = 0x20 # Device address (A0-A2)
-IODIRA = 0x00 # Pin direction register
-GPIOA = 0x12 # Register for inputs
-
-# Set first 7 GPA pins as outputs and
-# last one as input.
-bus.write_byte_data(DEVICE,IODIRA,0x80)
-
-# Loop until user presses CTRL-C
-while True:
- # Read state of GPIOA register
- MySwitch = bus.read_byte_data(DEVICE,GPIOA)
-
- if MySwitch & 0b10000000 == 0b10000000:
- print "Switch was pressed!"
- time.sleep(1)
diff --git a/random/interface.txt b/random/interface.txt
@@ -1 +0,0 @@
-<MIDDLEBUTTON: Record>--------------------------------- BRI:50 CON:-6 SAT:-21 SHUTTER:29155 --------------- ISO:100 AWB:off LOCKAWB:yes ------------------------ MIC:0 PHONES:50 WBG:215/128 69/64 DSK:23Gb -------- aaaa SCENE:1 SHOT:46 TAKE1 -
\ No newline at end of file
diff --git a/random/interface2.txt b/random/interface2.txt
diff --git a/random/lasterr.log b/random/lasterr.log
diff --git a/random/log.err b/random/log.err
@@ -1,333 +0,0 @@
-Recording WAVE '/mnt/tmp/scene01_shot003_take002.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-[wav @ 0xb7c380] max_analyze_duration reached
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot003_take002.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot003_take002.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 343kB time=29.25 bitrate= 96.0kbits/s
size= 362kB time=30.89 bitrate= 96.0kbits/s
-video:0kB audio:362kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot004_take001.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-overrun!!! (at least 71.741 ms long)
-Status:
- state : XRUN
- trigger_time: 123.686592007
- tstamp : 0.000000
- delay : 0
- avail : 22095
- avail_max : 22095
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-[wav @ 0xc0f380] max_analyze_duration reached
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot004_take001.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot004_take001.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 221kB time=18.87 bitrate= 96.0kbits/s
-video:0kB audio:221kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot004_take002.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot004_take002.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot004_take002.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 36kB time=3.02 bitrate= 96.2kbits/s
-video:0kB audio:36kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot005_take001.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-[wav @ 0x16d3380] max_analyze_duration reached
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot005_take001.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot005_take001.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 101kB time=8.63 bitrate= 96.1kbits/s
-video:0kB audio:101kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot006_take001.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-[wav @ 0xf76380] max_analyze_duration reached
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot006_take001.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot006_take001.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 93kB time=7.90 bitrate= 96.1kbits/s
-video:0kB audio:93kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot007_take001.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot007_take001.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot007_take001.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 37kB time=3.13 bitrate= 96.2kbits/s
-video:0kB audio:37kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot008_take001.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot008_take001.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot008_take001.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 32kB time=2.75 bitrate= 96.2kbits/s
-video:0kB audio:32kB global headers:0kB muxing overhead 0.000000%
-Recording WAVE '/mnt/tmp/scene01_shot009_take001.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
-Plug PCM: Hardware PCM card 0 'C-Media USB Audio Device' device 0 subdevice 0
-Its setup is:
- stream : CAPTURE
- access : RW_INTERLEAVED
- format : S16_LE
- subformat : STD
- channels : 1
- rate : 44100
- exact rate : 44100 (44100/1)
- msbits : 16
- buffer_size : 22050
- period_size : 5513
- period_time : 125011
- tstamp_mode : NONE
- period_step : 1
- avail_min : 5513
- period_event : 0
- start_threshold : 1
- stop_threshold : 22050
- silence_threshold: 0
- silence_size : 0
- boundary : 1445068800
- appl_ptr : 0
- hw_ptr : 0
-avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
- built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
-Guessed Channel Layout for Input Stream #0.0 : mono
-Input #0, wav, from '/home/pi/Videos/fiace/scene01/scene01_shot009_take001.wav':
- Duration: 06:45:47.88, bitrate: 0 kb/s
- Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
-Output #0, ac3, to '/home/pi/Videos/fiace/scene01/scene01_shot009_take001.ac3':
- Metadata:
- encoder : Lavf54.20.4
- Stream #0.0: Audio: ac3, 44100 Hz, mono, fltp, 96 kb/s
-Stream mapping:
- Stream #0:0 -> #0:0 (pcm_s16le -> ac3)
-Press ctrl-c to stop encoding
-size= 2kB time=0.13 bitrate= 100.1kbits/s
-video:0kB audio:2kB global headers:0kB muxing overhead 0.000000%
-tvservice-client: Failed to connect to TV service: -1
diff --git a/random/mcp23017_inputs.py b/random/mcp23017_inputs.py
@@ -1,18 +0,0 @@
-import smbus
-import time
-
-#bus = smbus.SMBus(0) # Rev 1 Pi uses 0
-bus = smbus.SMBus(3) # Rev 2 Pi uses 1
-
-DEVICE = 0x20 # Device address (A0-A2)
-IODIRB = 0x0d # Pin direction register
-GPIOB = 0x13 # Register for inputs
-
-bus.write_byte_data(DEVICE,IODIRB,0xFF) # set all gpiob to input
-
-# Loop until user presses CTRL-C
-while True:
- # Read state of GPIOA register
- readbus = bus.read_byte_data(DEVICE,GPIOB)
- print readbus
- time.sleep(0.1)
diff --git a/random/ninjacam.py b/random/ninjacam.py
@@ -1,1275 +0,0 @@
-#/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import picamera
-import os
-import time
-from subprocess import call
-from pyomxplayer import OMXPlayer
-import subprocess
-import sys
-import cPickle as pickle
-import curses
-import RPi.GPIO as GPIO
-from PIL import Image
-
-
-GPIO.setmode(GPIO.BCM)
-GPIO.setup(1, GPIO.OUT)
-GPIO.setup(18, GPIO.OUT)
-GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-os.system('clear')
-
-#--------------Save settings-----------------
-
-def savesetting(brightness, contrast, saturation, shutter_speed, iso, awb_mode, awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots):
- settings = brightness, contrast, saturation, shutter_speed, iso, awb_mode, awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots
- pickle.dump(settings, open(filmfolder + "settings.p", "wb"))
- pickle.dump(settings, open(filmfolder + filmname + "/scene" + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + "/settings.p", "wb"))
-
-#--------------Load film settings-----------------
-
-def loadfilmsettings(filmfolder):
- try:
- settings = pickle.load(open(filmfolder + "settings.p", "rb"))
- return settings
- except:
- return ''
-
-#--------------Load scene settings--------------
-
-def loadscenesettings(filmfolder, filmname, scene, shot):
- try:
- settings = pickle.load(open(filmfolder + filmname + "/scene" + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + "/settings.p", "rb"))
- return settings
- except:
- return ''
-
-#--------------Write the menu layer to dispmax--------------
-
-def writemenu(menu,settings,selected,header):
- c = 0
- clear = 305
- menudone = ''
- firstline = 18
- if header != '':
- header = ' ' + header
- spaces = 61 - len(header)
- header = header + (spaces * ' ')
- firstline = 45
- for a in menu:
- if c == selected:
- menudone = menudone + '<'
- else:
- menudone = menudone + ' '
- menudone = menudone + menu[c] + settings[c]
- if c == selected:
- menudone = menudone + '>'
- else:
- menudone = menudone + ' '
- c = c + 1
- if len(menudone) > firstline:
- spaces = 61 - len(menudone)
- menudone = menudone + spaces * '-'
- if len(menudone) > 102:
- spaces = 122 - len(menudone)
- menudone = menudone + spaces * '-'
- if len(menudone) > 170:
- spaces = 183 - len(menudone)
- menudone = menudone + spaces * '-'
- if len(menudone) > 208:
- spaces = 244 - len(menudone)
- menudone = menudone + spaces * '-'
- f = open('/mnt/tmp/interface', 'w')
- clear = clear - len(menudone)
- f.write(header + menudone + clear * ' ')
- f.close()
-
-#------------Write to screen----------------
-
-def writemessage(message):
- clear = 305
- clear = clear - len(message)
- f = open('/mnt/tmp/interface', 'w')
- f.write(' ' + message + clear * ' ')
- f.close()
-
-#------------Write to vumeter (last line)-----
-
-def vumetermessage(message):
- clear = 61
- clear = clear - len(message)
- f = open('/mnt/tmp/vumeter', 'w')
- f.write(message + clear * ' ')
- f.close()
-
-#------------Count scenes, takes and shots OLD-----
-
-def countlastold(filmname, filmfolder):
- takes = 0
- try:
- scenes = len(os.walk(filmfolder + filmname).next()[1])
- except:
- scenes = 1
- try:
- shots = len(os.walk(filmfolder + filmname + '/scene' + str(scenes).zfill(3)).next()[1])
- except:
- shots = 1
- try:
- allfiles = os.listdir(filmfolder + filmname + '/scene' + str(scenes).zfill(3) + '/shot' + str(shots).zfill(3))
- except:
- allfiles = []
- takes = 0
- for a in allfiles:
- if '.h264' in a:
- takes = takes + 1
- return scenes, shots, takes
-
-
-#------------Count scenes, takes and shots-----
-
-def countlast(filmname, filmfolder):
- scenes = 0
- shots = 0
- takes = 0
- try:
- allfiles = os.listdir(filmfolder + filmname)
- except:
- allfiles = []
- scenes = 1
- for a in allfiles:
- if 'scene' in a:
- scenes = scenes + 1
- try:
- allfiles = os.listdir(filmfolder + filmname + '/scene' + str(scenes).zfill(3))
- except:
- allfiles = []
- shots = 1
- for a in allfiles:
- if 'shot' in a:
- shots = shots + 1
- try:
- allfiles = os.listdir(filmfolder + filmname + '/scene' + str(scenes).zfill(3) + '/shot' + str(shots).zfill(3))
- except:
- allfiles = []
- takes = 0
- for a in allfiles:
- if '.h264' in a:
- takes = takes + 1
- return scenes, shots, takes
-
-#------------Count shots old--------
-
-def countshotsold(filmname, filmfolder, scene):
- try:
- shots = len(os.walk(filmfolder + filmname + '/scene' + str(scene).zfill(3)).next()[1])
- except:
- shots = 0
- return shots
-
-#------------Count shots--------
-
-def countshots(filmname, filmfolder, scene):
- shots = 0
- try:
- allfiles = os.listdir(filmfolder + filmname + '/scene' + str(scene).zfill(3))
- except:
- allfiles = []
- shots = 0
- for a in allfiles:
- if 'shot' in a:
- shots = shots + 1
- return shots
-
-#------------Count takes--------
-
-def counttakes(filmname, filmfolder, scene, shot):
- takes = 0
- try:
- allfiles = os.listdir(filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3))
- except:
- allfiles = []
- return takes
- for a in allfiles:
- if '.h264' in a:
- takes = takes + 1
- return takes
-
-#------------Count thumbnails----
-
-def countthumbs(filmname, filmfolder):
- thumbs = 0
- try:
- allfiles = os.listdir(filmfolder + filmname + '/.thumbnails')
- except:
- os.system('mkdir ' + filmfolder + filmname + '/.thumbnails')
- allfiles = []
- return thumbs
- for a in allfiles:
- if '.png' in a:
- thumbs = thumbs + 1
- return thumbs
-
-#-------------Render scene list--------------
-
-def renderlist(filmname, filmfolder, scene):
- scenefiles = []
- shots = countshots(filmname,filmfolder,scene)
- takes = counttakes(filmname,filmfolder,scene,shots)
- shot = 1
- while shot <= shots:
- takes = counttakes(filmname,filmfolder,scene,shot)
- if takes > 0:
- folder = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
- filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(takes).zfill(3)
- scenefiles.append(folder + filename)
- shot = shot + 1
- writemessage(str(len(scenefiles)))
- time.sleep(2)
- return scenefiles
-
-#-------------Render thumbnails------------
-
-def renderthumbnails(filmname, filmfolder):
- #count how many takes in whole film
- thumbs = countthumbs(filmname, filmfolder)
- writemessage(str(thumbs) + ' thumbnails found')
- alltakes = 0
- scenes = countlast(filmname, filmfolder)
- for n in xrange(scenes[0]):
- shots = countshots(filmname, filmfolder, n + 1)
- for s in xrange(shots):
- takes = counttakes(filmname, filmfolder, n + 1, s + 1)
- alltakes = alltakes + takes
- if thumbs == 0:
- writemessage('No thumbnails found. Rendering ' + str(alltakes) + ' thumbnails...')
- time.sleep(2)
- scenes = countlast(filmname, filmfolder)
- for n in xrange(scenes[0]):
- shots = countshots(filmname, filmfolder, n + 1)
- for s in xrange(shots):
- takes = counttakes(filmname, filmfolder, n + 1, s + 1)
- for p in xrange(takes):
- folder = filmfolder + filmname + '/' + 'scene' + str(n + 1).zfill(3) + '/shot' + str(s + 1).zfill(3) + '/'
- filename = 'scene' + str(n + 1).zfill(3) + '_shot' + str(s + 1).zfill(3) + '_take' + str(p + 1).zfill(3)
- os.system('avconv -i ' + folder + filename + '.h264 -ss 00:00:00 -vframes 1 -vf scale=800:340 ' + filmfolder + filmname + '/.thumbnails/' + filename + '.png')
- return alltakes
-
-#-------------Display png-------------------
-
-def displayimage(camera, filename):
- # Load the arbitrarily sized image
- try:
- img = Image.open(filename)
- except:
- writemessage('Seems like an empty shot. Hit record!')
- return
- # Create an image padded to the required size with
- # mode 'RGB'
- pad = Image.new('RGB', (
- ((img.size[0] + 31) // 32) * 32,
- ((img.size[1] + 15) // 16) * 16,
- ))
- # Paste the original image into the padded one
- pad.paste(img, (0, 0))
-
- # Add the overlay with the padded image as the source,
- # but the original image's dimensions
- overlay = camera.add_overlay(pad.tostring(), size=img.size)
- # By default, the overlay is in layer 0, beneath the
- # preview (which defaults to layer 2). Here we make
- # the new overlay semi-transparent, then move it above
- # the preview
- overlay.alpha = 255
- overlay.layer = 3
- return overlay
-
-def removeimage(camera, overlay):
- if overlay:
- camera.remove_overlay(overlay)
- overlay = None
-
-#-------------Browse------------------
-
-def browse(filmname, filmfolder):
- header = 'Select scene & shot'
- scenes, shots, takes = countlast(filmname, filmfolder)
- menu = 'SCENE', 'SHOT', 'TAKES'
- selected = 0
- scene = scenes
- shot = shots
- take = takes
- while True:
- settings = str(scene), str(shot), str(takes)
- writemenu(menu,settings,selected,header)
- time.sleep(0.2)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if upbutton == False:
- if selected == 0:
- if scene < scenes:
- scene = scene + 1
- shots = countshots(filmname, filmfolder, scene)
- shot = shots
- else:
- if shot < shots:
- shot = shot + 1
- takes = counttakes(filmname, filmfolder, scene, shot)
- take = takes
- elif downbutton == False:
- if selected == 0:
- if scene > 1:
- scene = scene - 1
- shots = countshots(filmname, filmfolder, scene)
- shot = shots
- else:
- if shot > 1:
- shot = shot - 1
- takes = counttakes(filmname, filmfolder, scene, shot)
- take = takes
- elif rightbutton == False:
- if selected == 0:
- selected = 1
- elif leftbutton == False:
- if selected == 1:
- selected = 0
- elif middlebutton == False:
- writemessage('Now recording to scene ' + str(scene) + ' shot ' + str(shot) + ' take ' + str(take + 1))
- time.sleep(2)
- return scene, shot, take + 1
-
-#-------------Browse2.0------------------
-
-def browse2(filmname, filmfolder, scene, shot, take, n, b):
- scenes, k, l = countlast(filmname, filmfolder)
- shots = countshots(filmname, filmfolder, scene)
- takes = counttakes(filmname, filmfolder, scene, shot)
- #writemessage(str(scene) + ' < ' + str(scenes))
- #time.sleep(4)
- selected = n
- if selected == 0 and b == 1:
- if scene < scenes:
- scene = scene + 1
- shots = countshots(filmname, filmfolder, scene)
- takes = counttakes(filmname, filmfolder, scene, shots)
- shot = shots
- take = takes
- if take == 0:
- shot = shot - 1
- take = counttakes(filmname, filmfolder, scene, shot - 1)
- if selected == 1 and b == 1:
- if shot < shots:
- shot = shot + 1
- takes = counttakes(filmname, filmfolder, scene, shot)
- take = takes
- if selected == 2 and b == 1:
- if take < takes + 1:
- take = take + 1
- if selected == 0 and b == -1:
- if scene > 1:
- scene = scene - 1
- shots = countshots(filmname, filmfolder, scene)
- takes = counttakes(filmname, filmfolder, scene, shots)
- shot = shots
- take = takes
- if take == 0:
- shot = shot - 1
- take = counttakes(filmname, filmfolder, scene, shot - 1)
- if selected == 1 and b == -1:
- if shot > 1:
- shot = shot - 1
- takes = counttakes(filmname, filmfolder, scene, shot)
- take = takes
- if selected == 2 and b == -1:
- if take > 1:
- take = take - 1
- if takes == 0:
- take = 1
- if shot == 0:
- shot = 1
- return scene, shot, take
-
-#-------------Update------------------
-
-def update(tarinaversion, tarinavername):
- writemessage('Current version ' + tarinaversion + ' ' + tarinavername)
- time.sleep(2)
- writemessage('Checking for updates...')
- os.system('wget http://tarina.org/src/ninjacam/VERSION -P /tmp/')
- f = open('/tmp/VERSION')
- versionnumber = f.readline()
- versionname = f.readline()
- os.system('rm /tmp/VERSION*')
- if float(tarinaversion) < float(versionnumber):
- writemessage('New version found ' + versionnumber + ' ' + versionname)
- time.sleep(4)
- timeleft = 0
- while timeleft < 5:
- writemessage('Updating in ' + str(timeleft) + ' seconds. Press middlebutton to cancel')
- time.sleep(1)
- timeleft = timeleft + 1
- middlebutton = GPIO.input(5)
- if middlebutton == False:
- return tarinaversion, tarinavername
- #os.system('rsync -R www-data@tarina.org/src/ninjacam/')
- writemessage('Version up-to-date!')
- time.sleep(2)
- return tarinaversion, tarinavername
-
-#-------------Load film---------------
-
-def loadfilm(filmname, filmfolder):
- films = os.walk(filmfolder).next()[1]
- films.sort()
- settings = [''] * len(films)
- firstslice = 0
- secondslice = 14
- selected = 0
- header = 'Select and load film'
- while True:
- writemenu(films[firstslice:secondslice],settings,selected,header)
- time.sleep(0.2)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if downbutton == False:
- firstslice = firstslice + 14
- secondslice = secondslice + 14
- selected = 0
- elif upbutton == False:
- if firstslice > 0:
- firstslice = firstslice - 14
- secondslice = secondslice - 14
- selected = 0
- elif rightbutton == False:
- if selected < 13:
- selected = selected + 1
- time.sleep(0.1)
- elif leftbutton == False:
- if selected > 0:
- selected = selected - 1
- time.sleep(0.1)
- elif middlebutton == False:
- filmname = (films[firstslice + selected])
- #scene = len(os.walk(filmfolder + filmname).next()[1])
- scene, shot, take = countlast(filmname, filmfolder)
- #writemessage(filmfolder + filmname + ' scenes ' + str(scene))
- #time.sleep(5)
- alltakes = renderthumbnails(filmname, filmfolder)
- writemessage('This film has ' + str(alltakes) + ' takes')
- time.sleep(2)
- scenesettings = loadscenesettings(filmfolder, filmname, scene, shot)
- if scenesettings == '':
- writemessage('Could not find settings file, sorry buddy')
- time.sleep(2)
- else:
- return scenesettings
-
-
-#-------------New film----------------
-
-def nameyourfilm():
- abc = 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
- abcx = 0
- name = ''
- thefuck = ''
- while True:
- message = 'Name Your Film: ' + name + abc[abcx]
- spaces = 55 - len(message)
- writemessage(message + (spaces * ' ') + thefuck)
- time.sleep(0.2)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if upbutton == False:
- if abcx < (len(abc) - 1):
- abcx = abcx + 1
- elif downbutton == False:
- if abcx > 0:
- abcx = abcx - 1
- elif rightbutton == False:
- if len(name) < 6:
- name = name + abc[abcx]
- else:
- thefuck = 'Yo, maximum characters reached bro!'
- elif leftbutton == False:
- if len(name) > 0:
- name = name[:-1]
- thefuck = ''
- elif middlebutton == False:
- if name > 0:
- name = name + abc[abcx]
- return(name)
-
-#------------Timelapse--------------------------
-
-def timelapse(beeps,camera,timelapsefolder,thefile):
- seconds = 1
- selected = 0
- header = 'Adjust how many seconds between frames'
- menu = 'TIME:', '', ''
- while True:
- time.sleep(0.1)
- settings = str(seconds), 'START', 'BACK'
- writemenu(menu,settings,selected,header)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if upbutton == False and selected == 0:
- seconds = seconds + 0.1
- if downbutton == False and selected == 0:
- if seconds > 0.2:
- seconds = seconds - 0.1
- if rightbutton == False:
- if selected < (len(settings) - 1):
- selected = selected + 1
- time.sleep(0.1)
- if leftbutton == False:
- if selected > 0:
- selected = selected - 1
- time.sleep(0.1)
- if middlebutton == False:
- time.sleep(0.2)
- if selected == 1:
- writemessage('Recording timelapse, middlebutton to stop')
- os.system('mkdir ' + timelapsefolder)
- for filename in camera.capture_continuous(timelapsefolder + '/img{counter:03d}.jpg'):
- camera.led = False
- i = 0
- while i < seconds:
- i = i + 0.1
- time.sleep(0.1)
- middlebutton = GPIO.input(5)
- if middlebutton == False:
- break
- if middlebutton == False:
- break
- camera.led = True
- writemessage('Compiling timelapse')
- os.system('avconv -y -framerate 25 -i ' + timelapsefolder + '/img%03d.jpg -c:v libx264 -level 40 -crf 24 ' + thefile + '.h264')
- return thefile
- if selected == 2:
- return ''
-
-
-#------------Happy with take or not?------------
-
-def happyornothappy(camera, thefile, scene, shot, take, filmfolder, filmname, foldername, filename, renderedshots, renderfullscene):
- header = 'Are You Happy with Your Take? Retake if not!'
- menu = '', '', '', '', ''
- settings = 'VIEWTAKE', 'NEXTSHOT', 'RETAKE', 'VIEWSCENE', 'VIEWFILM'
- selected = 1
- play = False
- writemessage('Converting video, hold your horses...')
- #call(['avconv', '-y', '-i', thefile + '.wav', '-acodec', 'libmp3lame', thefile + '.mp3'], shell=False)
- #call(['MP4Box', '-add', thefile + '.h264', '-add', thefile + '.mp3', '-new', thefile + '.mp4'], shell=False)
- while True:
- time.sleep(0.1)
- writemenu(menu,settings,selected,header)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if rightbutton == False:
- if selected < (len(settings) - 1):
- selected = selected + 1
- time.sleep(0.1)
- if leftbutton == False:
- if selected > 0:
- selected = selected - 1
- time.sleep(0.1)
- if middlebutton == False:
- if selected == 0:
- viewshot(filmfolder, filmname, foldername, filename)
- #NEXTSHOT (also check if coming from browse)
- if selected == 1:
- #scenes, shots, takes = countlast(filmname, filmfolder)
- #writemessage(str(scenes) + ' ' + str(shots) + ' ' + str(takes))
- #time.sleep(2)
- #if takes > 0:
- #shots = shots + 1
- #os.system('mkdir -p ' + filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shots).zfill(3))
- shot = shot + 1
- takes = counttakes(filmname, filmfolder, scene, shot)
- if takes == 0:
- takes = 1
- os.system('mkdir -p ' + filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3))
- writemessage('Congratz!')
- time.sleep(0.2)
- return scene, shot, takes, thefile, renderedshots, renderfullscene
- #RETAKE
- if selected == 2:
- take = take + 1
- writemessage('You made a shitty shot!')
- time.sleep(0.2)
- thefile = ''
- renderfullscene = True
- return scene, shot, take, thefile, renderedshots, renderfullscene
- #VIEWSCENE
- if selected == 3:
- filmfiles = renderlist(filmname, filmfolder, scene)
- renderfilename = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/scene' + str(scene).zfill(3)
- renderedshots, renderfullscene, playfile = render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, renderfilename)
- playthis(playfile)
- #VIEWFILM
- if selected == 4:
- renderfullscene = True
- filmfiles = viewfilm(filmfolder, filmname)
- renderfilename = filmfolder + filmname + '/' + filmname
- renderedshots, renderfullscene, playfile = render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, renderfilename)
- playthis(playfile)
-
-#-------------Compile Shot--------------
-
-def compileshot(filename):
- writemessage('Converting to playable video')
- os.system('MP4Box -add ' + filename + '.h264 -new ' + filename + '.mp4')
- writemessage('Playing video')
-
- #os.system('omxplayer --layer 3 ' + filmfolder + '/.rendered/' + filename + '.mp4 &')
- #time.sleep(0.8)
- #os.system('aplay ' + foldername + filename + '.wav')
-
-#-------------Render-------(rename to compile or render)-----
-
-def render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, filename):
- #print filmfiles
- writemessage('Hold on, rendering ' + str(len(filmfiles)) + ' files ' + str(renderedshots) + str(renderfullscene))
- time.sleep(2)
- #CHECK IF THERE IS A RENDERED VIDEO
- if renderfullscene == True:
- renderfullscene = False
- render = 0
- else:
- render = renderedshots
- renderedshots = shot
- ##PASTE VIDEO TOGETHER
- videomerge = ['MP4Box']
- videomerge.append('-force-cat')
- #if renderedshots < shot:
- if render > 0:
- videomerge.append('-cat')
- videomerge.append(filename + '.h264')
- for f in filmfiles[render:]:
- videomerge.append('-cat')
- videomerge.append(f + '.h264')
- videomerge.append('-new')
- videomerge.append(filename + '.h264')
- call(videomerge, shell=False) #how to insert somekind of estimated time while it does this?
- ##PASTE AUDIO TOGETHER
- writemessage('Rendering sound')
- audiomerge = ['sox']
- #if render > 2:
- # audiomerge.append(filename + '.wav')
- for f in filmfiles:
- audiomerge.append(tarinafolder + '/delay0138m.wav')
- audiomerge.append(f + '.wav')
- audiomerge.append(filename + '.wav')
- call(audiomerge, shell=False)
- ##CONVERT AUDIO
- call(['avconv', '-y', '-i', filename + '.wav', '-acodec', 'libmp3lame', filename + '.mp3'], shell=False)
- ##MERGE AUDIO & VIDEO
- writemessage('Merging audio & video')
- call(['MP4Box', '-add', filename + '.h264', '-add', filename + '.mp3', '-new', filename + '.mp4'], shell=False)
- #call(['MP4Box', '-add', filename + '.h264', '-new', filename + '.mp4'], shell=False)
- #shotsrendered = shot
- return renderedshots, renderfullscene, filename
- #play = True
- #time.sleep(1)
- #while play == True:
- # middlebutton = GPIO.input(5)
- # if middlebutton == False:
- # os.system('pkill -9 omxplayer')
- # play = False
- # time.sleep(0.2)
- # break
-
-#---------------Play------------------------
-
-def playthis(filename):
- writemessage('Playing scene')
- omx = OMXPlayer('--layer 3 ' + filename + '.mp4')
- #os.system('omxplayer --layer 3 ' + filename + '.mp4 &')
- #time.sleep(2)
- omx.previous_chapter()
- #time.sleep(0.75)
- os.system('aplay ' + filename + '.wav &')
- menu = 'STOP', 'PLAY FROM START'
- settings = '', ''
- selected = 0
- while True:
- header = 'Playing'
- time.sleep(0.1)
- writemenu(menu,settings,selected,header)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if rightbutton == False:
- if selected < (len(settings) - 1):
- selected = selected + 1
- time.sleep(0.1)
- if leftbutton == False:
- if selected > 0:
- selected = selected - 1
- time.sleep(0.1)
- if middlebutton == False:
- time.sleep(0.2)
- if selected == 0:
- omx.stop()
- os.system('pkill aplay')
- os.system('pkill omxplayer')
- break
- if middlebutton == False:
- time.sleep(1)
- if selected == 1:
- os.system('pkill aplay')
- omx.previous_chapter()
- time.sleep(0.75)
- os.system('aplay ' + filename + '.wav &')
-
-#---------------View Film--------------------
-
-def viewfilm(filmfolder, filmname):
- scenes, shots, takes = countlast(filmname, filmfolder)
- scene = 1
- filmfiles = []
- while scene <= scenes:
- shots = countshots(filmname, filmfolder, scene)
- if shots > 0:
- filmfiles.extend(renderlist(filmname, filmfolder, scene))
- scene = scene + 1
- return filmfiles
-
-#-------------Upload Scene------------
-
-def uploadfilm(filename, filmname):
- ##SEND TO SERVER
- writemessage('Hold on, video uploading. middle button to cancel')
- os.system('scp ' + filename + '.mp4 rob@lulzcam.org:/srv/www/lulzcam.org/public_html/videos/' + filmname + '.mp4')
- os.system('ssh -t rob@lulzcam.org "python /srv/www/lulzcam.org/newfilm.py"')
-
-#-------------Beeps-------------------
-
-def buzzer(beeps):
- buzzerrepetitions = 100
- pausetime = 1
- while beeps > 1:
- buzzerdelay = 0.0001
- for _ in xrange(buzzerrepetitions):
- for value in [True, False]:
- GPIO.output(1, value)
- time.sleep(buzzerdelay)
- time.sleep(pausetime)
- beeps = beeps - 1
- buzzerdelay = 0.0001
- for _ in xrange(buzzerrepetitions * 10):
- for value in [True, False]:
- GPIO.output(1, value)
- buzzerdelay = buzzerdelay - 0.00000004
- time.sleep(buzzerdelay)
-
-#-------------Start main--------------
-
-def main():
- filmfolder = "/home/pi/Videos/"
- filename = "ninjacam"
- tarinafolder = os.getcwd()
- #COUNT FILM FILES
- files = os.listdir(filmfolder)
- filename_count = len(files)
-
- #START CURSES
- screen = curses.initscr()
- curses.cbreak(1)
- screen.keypad(1)
- curses.noecho()
- screen.nodelay(1)
- curses.curs_set(0)
- time.sleep(1)
- with picamera.PiCamera() as camera:
-
- #START PREVIEW
- camera.resolution = (1920, 816) #tested modes 1920x816, 1296x552
- camera.crop = (0, 0, 1.0, 1.0)
- camera.led = False
- time.sleep(1)
- camera.awb_mode = 'off'
- camera.start_preview()
-
- #START fbcp AND dispmax hello interface hack
- call ([tarinafolder + '/fbcp &'], shell = True)
- call (['./startinterface.sh &'], shell = True)
-
- #MENUS
- menu = 'MIDDLEBUTTON: ','SHUTTER:', 'ISO:', 'RED:', 'BLUE:', 'BRIGHT:', 'CONT:', 'SAT:', 'FLIP:', 'BEEP:', 'RECL:', 'MIC:', 'PHONES:', 'DSK:', '', 'SCENE:', 'SHOT:', 'TAKE', '', ''
- actionmenu = 'Record', 'Play', 'Play Scene', 'New Scene', 'Play Film', 'Upload', 'Update', 'New Film', 'Load Film', 'Timelapse', 'Remove This Shot', 'New Shot'
-
- #STANDARD VALUES
- selectedaction = 0
- selected = 0
- camera.framerate = 26
- awb = 'auto', 'sunlight', 'cloudy', 'shade', 'tungsten', 'fluorescent', 'incandescent', 'flash', 'horizon'
- awbx = 0
- awb_lock = 'no'
- headphoneslevel = 50
- miclevel = 50
- recording = False
- retake = False
- overlay = None
- reclenght = 0
- t = 0
- rectime = ''
- showrec = ''
- scene = 1
- shot = 1
- take = 1
- filmname = ''
- thefile = ''
- beeps = 0
- flip = 'no'
- renderedshots = 0
- renderfullscene = False
- backlight = True
- filmnames = os.listdir(filmfolder)
- buttonpressed = time.time()
-
- #VERSION
- f = open(tarinafolder + '/VERSION')
- tarinaversion = f.readline()
- tarinavername = f.readline()
-
- #COUNT DISKSPACE
- disk = os.statvfs(filmfolder)
- diskleft = str(disk.f_bavail * disk.f_frsize / 1024 / 1024 / 1024) + 'Gb'
-
- #LOAD FILM AND SCENE SETTINGS
- try:
- camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots = loadfilmsettings(filmfolder)
- except:
- writemessage("no film settings found")
- time.sleep(2)
- try:
- camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots = loadscenesettings(filmfolder, filmname, scene, shot)
- except:
- writemessage("no scene settings found")
- time.sleep(2)
-
- #FILE & FOLDER NAMES
- foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
- filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3)
-
- #NEW FILM (IF NOTHING TO LOAD)
- if filmname == '':
- filmname = nameyourfilm()
-
- if flip == "yes":
- camera.vflip = True
- camera.hflip = True
- os.system('mkdir -p ' + filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3))
- os.system('amixer -c 0 set Mic Capture ' + str(miclevel) + '%')
- os.system('amixer -c 0 set Mic Playback ' + str(headphoneslevel) + '%')
-
- #TESTING SPACE
- alltakes = renderthumbnails(filmname, filmfolder)
- writemessage('This film has ' + str(alltakes) + ' takes')
- time.sleep(2)
- #writemessage(tarinafolder)
- #time.sleep(3)
- #overlay = displayimage(camera, '/home/pi/Videos/.rendered/scene001_shot001_take001.png')
- #removeimage(camera, overlay)
-
- #MAIN LOOP
- while True:
- time.sleep(0.1)
- GPIO.output(18,backlight)
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- event = screen.getch()
-
- #QUIT
- if event == 27 or middlebutton == False and selectedaction == 71:
- writemessage('Happy hacking!')
- time.sleep(1)
- camera.stop_preview()
- camera.close()
- os.system('pkill -9 fbcp')
- os.system('pkill -9 arecord')
- os.system('pkill -9 startinterface')
- os.system('pkill -9 camerainterface')
- curses.nocbreak()
- curses.echo()
- curses.endwin()
- os.system('clear')
- os.system('echo "Have a nice hacking time!"')
- quit()
-
- #SCREEN ON/OFF
- if upbutton == False and downbutton == False:
- time.sleep(0.1)
- if backlight == True:
- backlight = False
- else:
- backlight = True
-
- #RECORD AND PAUSE
- elif middlebutton == False and selectedaction == 0 and float(time.time() - buttonpressed) > 0.2 or reclenght != 0 and t > reclenght:
- buttonpressed = time.time()
- if recording == False:
- if beeps > 0:
- buzzer(beeps)
- time.sleep(0.1)
- foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
- filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3)
- recording = True
- camera.led = True
- os.system(tarinafolder + '/alsa-utils-1.0.25/aplay/arecord -D plughw:0,0 -f S16_LE -c1 -r44100 -vv /mnt/tmp/' + filename + '.wav &')
- camera.start_recording('/mnt/tmp/' + filename + '.h264', format='h264', quality=21)
- starttime = time.time()
- #camera.wait_recording(10)
- else:
- disk = os.statvfs(tarinafolder + '/')
- diskleft = str(disk.f_bavail * disk.f_frsize / 1024 / 1024 / 1024) + 'Gb'
- recording = False
- camera.led = False
- os.system('pkill -9 arecord')
- camera.stop_recording()
- t = 0
- rectime = ''
- showrec = ''
- vumetermessage('Tarina ' + tarinaversion + ' ' + tarinavername)
- thefile = foldername + filename
- writemessage('Copying video file...')
- os.system('mv /mnt/tmp/' + filename + '.h264 ' + foldername)
- try:
- writemessage('Copying audio file...')
- os.system('mv /mnt/tmp/' + filename + '.wav ' + foldername)
- except:
- writemessage('no audio file')
- time.sleep(0.5)
- os.system('cp err.log lasterr.log')
- #render thumbnail
- os.system('avconv -i ' + foldername + filename + '.h264 -ss 00:00:00 -vframes 1 -vf scale=800:340 ' + filmfolder + filmname + '/.thumbnails/' + filename + '.png')
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
- scene, shot, take, thefile, renderedshots, renderfullscene = happyornothappy(camera, thefile, scene, shot, take, filmfolder, filmname, foldername, filename, renderedshots, renderfullscene)
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
-
- #TIMELAPSE
- elif middlebutton == False and selectedaction == 9 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- thefile = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/' + filename
- timelapsefolder = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/' + 'timelapse' + str(shot).zfill(2) + str(take).zfill(2)
- thefile = timelapse(beeps,camera,timelapsefolder,thefile)
- if thefile != '':
- scene, shot, take, thefile, renderedshots, renderfullscene = happyornothappy(camera, thefile, scene, shot, take, filmfolder, filmname, foldername, filename, renderedshots, renderfullscene)
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
-
- #PLAY
- elif middlebutton == False and selectedaction == 1 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- takes = counttakes(filmname, filmfolder, scene, shot)
- if takes > 0:
- removeimage(camera, overlay)
- foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
- filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3)
- #viewshot(filmfolder, filmname, foldername, filename)
- compileshot(foldername + filename)
- playthis(foldername + filename)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- else:
- writemessage('Sorry, no last shot to view buddy!')
- time.sleep(3)
-
- #VIEW SCENE
- elif middlebutton == False and selectedaction == 2 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- filmfiles = renderlist(filmname, filmfolder, scene)
- renderfilename = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/scene' + str(scene).zfill(3)
- renderedshots, renderfullscene, playfile = render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, renderfilename)
- playthis(playfile)
- selectedaction = 0
-
- #NEW SCENE
- elif middlebutton == False and selectedaction == 3 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- scene = scene + 1
- take = 1
- shot = 1
- renderedshots = 0
- os.system('mkdir -p ' + filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3))
- writemessage('New scene!')
- time.sleep(2)
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
- selectedaction = 0
-
- #NEW SHOT
- elif middlebutton == False and selectedaction == 11 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- takes = counttakes(filmname, filmfolder, scene, shot)
- if takes > 0:
- shot = shot + 1
- takes = counttakes(filmname, filmfolder, scene, shot)
- take = takes + 1
- os.system('mkdir -p ' + filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3))
- else:
- writemessage('This is it maan')
- time.sleep(2)
-
- #VIEW FILM
- elif middlebutton == False and selectedaction == 4 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- renderfullscene = True
- filmfiles = viewfilm(filmfolder, filmname)
- renderfilename = filmfolder + filmname + '/' + filmname
- renderedshots, renderfullscene, playfile = render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, renderfilename)
- playthis(playfile)
- selectedaction = 0
-
- #UPLOAD
- elif middlebutton == False and selectedaction == 5 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- renderfullscene = True
- filmfiles = viewfilm(filmfolder, filmname)
- renderfilename = filmfolder + filmname + '/' + filmname
- renderedshots, renderfullscene, uploadfile = render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, renderfilename)
- uploadfilm(uploadfile, filmname)
- selectedaction = 0
-
- #LOAD FILM
- if event == 27 or middlebutton == False and selectedaction == 8:
- buttonpressed = time.time()
- camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots = loadfilm(filmname,filmfolder)
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
- selectedaction = 0
-
- #UPDATE
- elif middlebutton == False and selectedaction == 6 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- tarinaversion, tarinavername = update(tarinaversion, tarinavername)
- selectedaction = 0
-
- #NEW FILM
- elif middlebutton == False and selectedaction == 7 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if recording == False:
- scene = 1
- shot = 1
- take = 1
- renderedshots = 0
- selectedaction = 0
- filmname = nameyourfilm()
- os.system('mkdir -p ' + filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3))
- writemessage('Good luck with your film ' + filmname + '!')
- time.sleep(2)
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
- selectedaction = 0
-
- #REMOVE SHOT
- elif middlebutton == False and selectedaction == 10 and float(time.time() - buttonpressed) > 0.2:
- buttonpressed = time.time()
- if shot > 1:
- writemessage('Removing shot: ' + str(shot))
- foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
- os.system('rm -r ' + foldername)
- shot = shot - 1
- take = counttakes(filmname, filmfolder, scene, shot)
- take = take + 1
- time.sleep(3)
- foldername = filmfolder + filmname + '/' + 'scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
- filename = 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3)
- renderfullscene = True
- savesetting(camera.brightness, camera.contrast, camera.saturation, camera.shutter_speed, camera.iso, camera.awb_mode, camera.awb_gains, awb_lock, miclevel, headphoneslevel, filmfolder, filmname, scene, shot, take, thefile, beeps, flip, renderedshots)
- selectedaction = 0
-
-
- #UP
- elif event == ord('w') or upbutton == False:
- if selected == 0:
- if selectedaction < (len(actionmenu) - 1):
- selectedaction = selectedaction + 1
- time.sleep(0.1)
- else:
- selectedaction = 0
- time.sleep(0.1)
- if selected == 5:
- camera.brightness = min(camera.brightness + 1, 99)
- if selected == 6:
- camera.contrast = min(camera.contrast + 1, 99)
- if selected == 7:
- camera.saturation = min(camera.saturation + 1, 99)
- if selected == 1:
- camera.shutter_speed = min(camera.shutter_speed + 510, 50000)
- if selected == 2:
- camera.iso = min(camera.iso + 100, 1600)
- if selected == 9:
- beeps = beeps + 1
- if selected == 8:
- if flip == 'yes':
- camera.hflip = False
- camera.vflip = False
- flip = 'no'
- time.sleep(0.2)
- else:
- camera.hflip = True
- camera.vflip = True
- flip = 'yes'
- time.sleep(0.2)
- if selected == 10:
- reclenght = reclenght + 1
- time.sleep(0.1)
- if selected == 11:
- if miclevel < 100:
- miclevel = miclevel + 2
- os.system('amixer -c 0 set Mic Capture ' + str(miclevel) + '%')
- if selected == 12:
- if headphoneslevel < 100:
- headphoneslevel = headphoneslevel + 2
- os.system('amixer -c 0 set Mic Playback ' + str(headphoneslevel) + '%')
- if selected == 15:
- scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 0, 1)
- removeimage(camera, overlay)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- if selected == 16:
- scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 1, 1)
- removeimage(camera, overlay)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- if selected == 17:
- scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 2, 1)
- removeimage(camera, overlay)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- if selected == 3:
- camera.awb_mode = 'off'
- if float(camera.awb_gains[0]) < 7.98:
- camera.awb_gains = (float(camera.awb_gains[0]) + 0.02, float(camera.awb_gains[1]))
- if selected == 4:
- camera.awb_mode = 'off'
- if float(camera.awb_gains[1]) < 7.98:
- camera.awb_gains = (float(camera.awb_gains[0]), float(camera.awb_gains[1]) + 0.02)
-
- #LEFT
- elif event == ord('a') or leftbutton == False and buttonrelease == True:
- buttonrelease = False
- if selected > 0:
- selected = selected - 1
- else:
- selected = len(menu) - 3
-
- #DOWN
- elif event == ord('s') or downbutton == False:
- if selected == 0:
- if selectedaction > 0:
- selectedaction = selectedaction - 1
- time.sleep(0.1)
- else:
- selectedaction = len(actionmenu) - 1
- time.sleep(0.1)
- if selected == 5:
- camera.brightness = max(camera.brightness - 1, 0)
- if selected == 6:
- camera.contrast = max(camera.contrast - 1, -100)
- if selected == 7:
- camera.saturation = max(camera.saturation - 1, -100)
- if selected == 1:
- camera.shutter_speed = max(camera.shutter_speed - 510, 200)
- if selected == 2:
- camera.iso = max(camera.iso - 100, 100)
- if selected == 9:
- if beeps > 0:
- beeps = beeps - 1
- if selected == 8:
- if flip == 'yes':
- camera.hflip = False
- camera.vflip = False
- flip = 'no'
- time.sleep(0.2)
- else:
- camera.hflip = True
- camera.vflip = True
- flip = 'yes'
- time.sleep(0.2)
- if selected == 10:
- if reclenght > 0:
- reclenght = reclenght - 1
- time.sleep(0.1)
- if selected == 11:
- if miclevel > 0:
- miclevel = miclevel - 2
- os.system('amixer -c 0 set Mic Capture ' + str(miclevel) + '%')
- if selected == 12:
- if headphoneslevel > 0:
- headphoneslevel = headphoneslevel - 2
- os.system('amixer -c 0 set Mic Playback ' + str(headphoneslevel) + '%')
- if selected == 15:
- scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 0, -1)
- removeimage(camera, overlay)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- if selected == 16:
- scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 1, -1)
- removeimage(camera, overlay)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- if selected == 17:
- scene, shot, take = browse2(filmname, filmfolder, scene, shot, take, 2, -1)
- removeimage(camera, overlay)
- imagename = filmfolder + filmname + '/.thumbnails/' + 'scene' + str(scene).zfill(3) + '_shot' + str(shot).zfill(3) + '_take' + str(take).zfill(3) + '.png'
- overlay = displayimage(camera, imagename)
- if selected == 3:
- camera.awb_mode = 'off'
- if float(camera.awb_gains[0]) > 0.02:
- camera.awb_gains = (float(camera.awb_gains[0]) - 0.02, float(camera.awb_gains[1]))
- if selected == 4:
- camera.awb_mode = 'off'
- if float(camera.awb_gains[1]) > 0.02:
- camera.awb_gains = (float(camera.awb_gains[0]), float(camera.awb_gains[1]) - 0.02)
-
- #RIGHT
- elif event == ord('d') or rightbutton == False and buttonrelease == True:
- buttonrelease = False
- if selected < len(menu) - 3:
- selected = selected + 1
- else:
- selected = 0
- elif leftbutton == True or rightbutton == True:
- buttonrelease = True
- if recording == True:
- showrec = 'RECLENGTH:'
- t = time.time() - starttime
- rectime = time.strftime("%H:%M:%S", time.gmtime(t))
- settings = actionmenu[selectedaction], str(camera.shutter_speed).zfill(5), str(camera.iso), str(float(camera.awb_gains[0]))[:4], str(float(camera.awb_gains[1]))[:4], str(camera.brightness), str(camera.contrast), str(camera.saturation), str(flip), str(beeps), str(reclenght), str(miclevel), str(headphoneslevel), diskleft, filmname, str(scene), str(shot), str(take), showrec, rectime
- header=''
- writemenu(menu,settings,selected,header)
-if __name__ == '__main__':
- import sys
- try:
- main()
- except:
- print 'Unexpected error : ', sys.exc_info()[0], sys.exc_info()[1]
diff --git a/random/organize.py b/random/organize.py
@@ -1,67 +0,0 @@
-#!/usr/bin/python
-
-import web
-import os
-import time
-
-# Get path of the current dir, then use it as working directory:
-rundir = os.path.dirname(__file__)
-if rundir != '':
- os.chdir(rundir)
-
-filmfolder = '/home/pi/Videos/'
-filmname = 'test'
-
-scenes = os.walk(filmfolder + filmname).next()[1]
-
-# Takes
-for i in sorted(scenes):
- shots = os.walk(filmfolder + filmname + '/' + i).next()[1]
- for p in sorted(shots):
- takes = os.walk(filmfolder + filmname + '/' + i + '/' + p).next()[2]
- if len(takes) == 0:
- print 'no takes in this shot, removing shot..'
- os.system('rm -r ' + filmfolder + filmname + '/' + i + '/' + p)
- organized_nr = 1
- for s in sorted(takes):
- if '.mp4' in s:
- print s
- unorganized_nr = int(s[4:-4])
- if organized_nr == unorganized_nr:
- print 'correct'
- if organized_nr != unorganized_nr:
- print 'false, correcting from ' + str(unorganized_nr) + ' to ' + str(organized_nr)
- os.system('mv ' + filmfolder + filmname + '/' + i + '/' + p + '/take' + str(unorganized_nr).zfill(3) + '.mp4 ' + filmfolder + filmname + '/' + i + '/' + p + '/take' + str(organized_nr).zfill(3) + '.mp4')
- organized_nr = organized_nr + 1
-# Shots
-for i in sorted(scenes):
- shots = os.walk(filmfolder + filmname + '/' + i).next()[1]
- if len(shots) == 0:
- print 'no shots in this scene, removing scene..'
- os.system('rm -r ' + filmfolder + filmname + '/' + i)
- organized_nr = 1
- for p in sorted(shots):
- if 'shot' in p:
- print p
- unorganized_nr = int(p[-3:])
- if organized_nr == unorganized_nr:
- print 'correct'
- if organized_nr != unorganized_nr:
- print 'false, correcting from ' + str(unorganized_nr) + ' to ' + str(organized_nr)
- os.system('mv ' + filmfolder + filmname + '/' + i + '/shot' + str(unorganized_nr).zfill(3) + ' ' + filmfolder + filmname + '/' + i + '/shot' + str(organized_nr).zfill(3))
- organized_nr = organized_nr + 1
-
-# Scenes
-organized_nr = 1
-for i in sorted(scenes):
- if 'scene' in i:
- print i
- unorganized_nr = int(i[-3:])
- if organized_nr == unorganized_nr:
- print 'correct'
- if organized_nr != unorganized_nr:
- print 'false, correcting from ' + str(unorganized_nr) + ' to ' + str(organized_nr)
- os.system('mv ' + filmfolder + filmname + '/scene' + str(unorganized_nr).zfill(3) + ' ' + filmfolder + filmname + '/scene' + str(organized_nr).zfill(3))
- organized_nr = organized_nr + 1
-
-print 'Organizer done! Everything is tidy'
diff --git a/random/output.wav b/random/output.wav
Binary files differ.
diff --git a/random/petpicam.py b/random/petpicam.py
@@ -1,338 +0,0 @@
-#!/usr/bin/env/ python
-# -*- coding: utf-8 -*-
-import picamera
-import subprocess
-from subprocess import call
-import os
-import curses
-import time
-import cPickle as pickle
-import RPi.GPIO as GPIO
-
-GPIO.setmode(GPIO.BCM)
-
-GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
-
-petpicamfolder = '/home/pi/petpicam/'
-start_fbcp = '/home/pi/petpicam/fbcp &'
-kill_fbcp = 'pkill fbcp'
-start_arecord = 'arecord -f dat -vv /dev/shm/soundlove'
-kill_arecord = 'pkill arecord'
-start_MP4Box='MP4Box -add /home/pi/Videos/'
-start_omxplayer = 'omxplayer --fps=25 /home/pi/Videos/'
-start_aplay = 'aplay /home/pi/Videos/'
-
-rec_time = 5
-filmfolder = "/home/pi/Videos/"
-filename = "petpicam"
-iso = 100, 200, 320, 400, 500, 640, 800, 1000, 1200, 1400, 1600
-isox = 0
-whitebalance = 'auto', 'sunlight', 'cloudy', 'shade', 'tungsten', 'fluorescent', 'incandescent', 'flash', 'horizon'
-whitebalancex = 0
-cameramode = 'video', 'photo'
-cameramodex = 0
-shutter = 3000
-record = True
-length_selected = 0
-iso_selected = 0
-shutter_selected = 1
-whitebalance_selected = 0
-cameramode_selected = 0
-play_selected = 0
-
-allowedchr = ['1','2','3','4','5','6','7','8','9','0','q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M']
-
-os.system('clear')
-print "------------Petpicam-v001-----------------------------------"
-print "----Hope u have a nice day---gettin some good footage-------"
-
-##---------Count film files-----------
-files = os.listdir(filmfolder)
-filename_count = len(files)
-
-def initcurses():
- global stdscr
- stdscr = curses.initscr()
- curses.cbreak(1)
- stdscr.keypad(1)
- curses.noecho()
- stdscr.nodelay(1)
- curses.curs_set(0)
- curses.start_color()
- curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
- curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
- curses.init_pair(3, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
-
-
-def killcurses():
- global stdscr
- curses.nocbreak()
- stdscr.keypad(0)
- curses.echo()
- curses.endwin()
-
-
-def writestoryname():
- global stdscr, allowedchr
- storyname = ''
- stdscr.addstr(1, 3, "film story name: ", curses.color_pair(2))
- while True:
- event = stdscr.getch()
- middlebutton = GPIO.input(5)
- if middlebutton == False:
- time.sleep(0.2)
- return "petpicam_video"
- if event == 27:
- killcurses()
- exit()
- elif event == 10:
- if storyname == '':
- break
- if len(storyname) > 0:
- return storyname
- stdscr.addstr(2, 3, 'Please write something...', curses.color_pair(2))
- elif event == 127 or event == curses.KEY_BACKSPACE:
- if len(storyname) > 0:
- storyname = storyname[:-1]
- stdscr.addstr(1, 21, storyname + ' ', curses.color_pair(2))
- elif event == 32:
- stdscr.addstr(2, 3, 'Sorry mate! no spaces in storyname.', curses.color_pair(2))
- else:
- try:
- if chr(event) in allowedchr:
- storyname = storyname + (chr(event))
- except:
- continue
- stdscr.addstr(1, 21, storyname + ' ', curses.color_pair(2))
-
-##---------------save settings------------------------------
-
-def savesettings():
- global isox, shutter, cameramodex, whitebalancex, rec_time
- settings = isox, shutter, cameramodex, whitebalancex, rec_time
- pickle.dump(settings, open(petpicamfolder + "settings.p", "wb"))
-
-##---------------load settings------------------------------
-
-def loadsettings():
- try:
- settings = pickle.load(open(petpicamfolder + "settings.p", "rb"))
- return settings
- except:
- print "no settings"
-
-##---------------petpicam-menu-----------------------------<3
-
-def refresh():
- global stdscr, filename, iso, filename_count, shutter, rec_time, length_selected, iso_selected, shutter_selected, whitebalance_selected, whitebalance, whitebalancex
- savesettings()
- stdscr.clear()
- stdscr.addstr(2,2, "---<<< " + filename + " >>>--- PetPiCam v.0001 ", curses.color_pair(1))
- stdscr.addstr(3,2, "Backspace to preview | Enter to Record | (d) for disk space", curses.color_pair(2))
- stdscr.addstr(4,2, "Up or Down to select", curses.color_pair(2))
- stdscr.addstr(5,2, "Film length: " + str(rec_time), curses.color_pair(2 + length_selected))
- stdscr.addstr(6,2, "ISO: " + str(iso[isox]), curses.color_pair(2 + iso_selected))
- stdscr.addstr(7,2, "Shutter: " + str(shutter), curses.color_pair(2 + shutter_selected))
- stdscr.addstr(8,2, "Whitebalance: " + whitebalance[whitebalancex], curses.color_pair(2 + whitebalance_selected))
- stdscr.addstr(9,2, "Mode: " + cameramode[cameramodex], curses.color_pair(2 + cameramode_selected))
- stdscr.addstr(10,2, "Play the last clip", curses.color_pair(2 + play_selected))
- stdscr.addstr(11,2, "Film files: " + str(filename_count), curses.color_pair(2))
- stdscr.addstr(12,2, "(n) for new story", curses.color_pair(2))
- stdscr.addstr(13,2, "Esc to Exit")
- stdscr.refresh()
- stdscr.refresh()
-
-##----------------------Main loop starts-------------------------
-
-initcurses()
-filename = 'librecam'
-settings = loadsettings()
-try:
- isox = settings[0]
- shutter = settings[1]
- cameramodex = settings[2]
- whitebalancex = settings[3]
- rec_time = settings[4]
-except:
- print "no settings loaded"
-else:
- print "settings loaded"
-refresh()
-
-while True:
- time.sleep(0.1555)
- event = stdscr.getch()
- middlebutton = GPIO.input(5)
- upbutton = GPIO.input(12)
- downbutton = GPIO.input(13)
- leftbutton = GPIO.input(16)
- rightbutton = GPIO.input(26)
- if event == 27:
- call ([kill_fbcp], shell=True)
- curses.nocbreak()
- killcurses()
- quit()
- elif event == 10 or middlebutton == False:
- camera = picamera.PiCamera()
- filename_count = filename_count + 1
- if len(str(filename_count)) == 1:
- filenamenumber = '00' + str(filename_count)
- elif len(str(filename_count)) == 2:
- filenamenumber = '0' + str(filename_count)
- else:
- filenamenumber = str(filename_count)
- killcurses()
- camera.start_preview()
- camera.iso = iso[isox]
- if cameramode[cameramodex] == 'video':
- camera.resolution = (1920, 1080)
- if cameramode[cameramodex] == 'photo':
- camera.resolution = (2592, 1944)
- call ([start_fbcp], shell=True)
- camera.framerate = 25
- time.sleep(2)
- camera.iso = iso[isox]
- camera.shutter_speed = shutter
- camera.exposure_mode = 'off'
- g = camera.awb_gains
- camera.awb_mode = whitebalance[whitebalancex]
- #camera.awb_gains = g
- if cameramode[cameramodex] == 'video':
- camera.start_recording('/dev/shm/' + filename + filenamenumber + '.h264')
- call ([start_arecord + filenamenumber + '.wav &'], shell=True)
- camera.wait_recording(rec_time)
- camera.stop_recording()
- call ([kill_arecord], shell=True)
- camera.stop_preview()
- camera.exposure_mode = 'auto'
- camera.close()
- if cameramode[cameramodex] == 'photo':
- time.sleep(2)
- camera.capture(filmfolder + filename + filenamenumber + '.jpg')
- camera.stop_preview()
- camera.close()
- call ([kill_fbcp], shell=True)
- os.system('mv /dev/shm/' + filename + filenamenumber + '.h264 ' + filmfolder)
- os.system('mv /dev/shm/soundlove' + filenamenumber + '.wav ' + filmfolder)
- initcurses()
- refresh()
- elif event == curses.KEY_BACKSPACE:
- camera = picamera.PiCamera()
- killcurses()
- camera.start_preview()
- camera.exposure_mode = 'off'
- camera.iso = iso[isox]
- call ([start_fbcp], shell=True)
- time.sleep(5)
- call ([kill_fbcp], shell=True)
- camera.stop_preview()
- camera.close()
- initcurses()
- refresh()
- elif event == curses.KEY_LEFT and shutter_selected == 1 or leftbutton == False and shutter_selected == 1:
- if shutter > 0:
- shutter = shutter - 350
- refresh()
- elif event == curses.KEY_RIGHT and shutter_selected == 1 or rightbutton == False and shutter_selected == 1:
- if shutter < 24000:
- shutter = shutter + 100
- refresh()
- elif event == curses.KEY_LEFT and iso_selected == 1 or leftbutton == False and iso_selected == 1:
- if isox > 0:
- isox = isox - 1
- refresh()
- elif event == curses.KEY_RIGHT and iso_selected == 1 or rightbutton == False and iso_selected == 1:
- if isox < 10:
- isox = isox + 1
- refresh()
- elif event == curses.KEY_LEFT and cameramode_selected == 1 or leftbutton == False and cameramode_selected == 1:
- if cameramodex > 0:
- cameramodex = cameramodex - 1
- refresh()
- elif event == curses.KEY_RIGHT and cameramode_selected == 1 or rightbutton == False and cameramode_selected == 1:
- if cameramodex < 1:
- cameramodex = cameramodex + 1
- refresh()
- elif event == curses.KEY_LEFT and whitebalance_selected == 1 or leftbutton == False and whitebalance_selected == 1:
- if whitebalancex > 0:
- whitebalancex = whitebalancex - 1
- refresh()
- elif event == curses.KEY_RIGHT and whitebalance_selected == 1 or rightbutton == False and whitebalance_selected == 1:
- if whitebalancex < 8:
- whitebalancex = whitebalancex + 1
- refresh()
- elif event == curses.KEY_RIGHT and length_selected == 1 or rightbutton == False and length_selected == 1:
- rec_time = rec_time + 5
- refresh()
- elif event == curses.KEY_LEFT and length_selected == 1 or leftbutton == False and length_selected == 1:
- if rec_time > 5:
- rec_time = rec_time - 5
- refresh()
- elif event == curses.KEY_RIGHT and play_selected == 1 or rightbutton == False and play_selected == 1:
- call ([start_MP4Box + filename + filenamenumber + '.h264 ' + filmfolder + filename + filenamenumber + '.mp4'], shell=True)
- call ([start_fbcp], shell=True)
- call ([start_omxplayer + filename + filenamenumber + '.mp4 &'], shell=True)
- time.sleep(2)
- call ([start_aplay + 'soundlove' + filenamenumber + '.wav'], shell=True)
- call ([kill_fbcp], shell=True)
- refresh()
- elif event == curses.KEY_DOWN or downbutton == False:
- if cameramode_selected == 1:
- cameramode_selected = 0
- play_selected = 1
- refresh()
- if whitebalance_selected == 1:
- whitebalance_selected = 0
- cameramode_selected = 1
- refresh()
- if shutter_selected == 1:
- shutter_selected = 0
- whitebalance_selected = 1
- refresh()
- if iso_selected == 1:
- shutter_selected = 1
- iso_selected = 0
- length_selected = 0
- refresh()
- if length_selected == 1:
- length_selected = 0
- iso_selected = 1
- refresh()
- elif event == curses.KEY_UP or upbutton == False:
- if iso_selected == 1:
- length_selected = 1
- iso_selected = 0
- refresh()
- if shutter_selected == 1:
- iso_selected = 1
- shutter_selected = 0
- refresh()
- if whitebalance_selected == 1:
- whitebalance_selected = 0
- shutter_selected = 1
- refresh()
- if cameramode_selected == 1:
- cameramode_selected = 0
- whitebalance_selected = 1
- refresh()
- if play_selected == 1:
- play_selected = 0
- cameramode_selected = 1
- refresh()
- elif event == 100:
- killcurses()
- os.system('df /home/pi -h')
- time.sleep(3)
- initcurses()
- elif event == 110:
- stdscr.clear()
- filename = writestoryname()
- refresh()
- else:
- ##stdscr.addstr(10,2, "Event: " + str(event))
- continue
-
diff --git a/random/playaudio.py b/random/playaudio.py
@@ -1,29 +0,0 @@
-import pyaudio
-import wave
-import sys
-
-CHUNK = 1024
-
-if len(sys.argv) < 2:
- print("Plays a wave file.\n\nUsage: %s filename.wav" % sys.argv[0])
- sys.exit(-1)
-
-wf = wave.open(sys.argv[1], 'rb')
-
-p = pyaudio.PyAudio()
-
-stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
- channels=wf.getnchannels(),
- rate=wf.getframerate(),
- output=True)
-
-data = wf.readframes(CHUNK)
-
-while data != '':
- stream.write(data)
- data = wf.readframes(CHUNK)
-
-stream.stop_stream()
-stream.close()
-
-p.terminate()
diff --git a/random/recordaudio.py b/random/recordaudio.py
@@ -1,39 +0,0 @@
-import pyaudio
-import wave
-
-CHUNK = 2024
-FORMAT = pyaudio.paInt16
-CHANNELS = 2
-RATE = 44100
-RECORD_SECONDS = 5
-WAVE_OUTPUT_FILENAME = "output.wav"
-
-p = pyaudio.PyAudio()
-
-stream = p.open(format=FORMAT,
- channels=CHANNELS,
- rate=RATE,
- input=True,
- frames_per_buffer=CHUNK)
-
-print("* recording")
-
-frames = []
-
-for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
- data = stream.read(CHUNK)
- frames.append(data)
-
-print("* done recording")
-
-stream.stop_stream()
-stream.close()
-p.terminate()
-
-wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
-wf.setnchannels(CHANNELS)
-wf.setsampwidth(p.get_sample_size(FORMAT))
-wf.setframerate(RATE)
-wf.writeframes(b''.join(frames))
-wf.close()
-
diff --git a/random/robsi2cbuttons.py b/random/robsi2cbuttons.py
@@ -1,58 +0,0 @@
-import smbus
-import time
-import os
-
-#Hexadecimal convertor
-#https://www.mattsbits.co.uk/webtools/bhd_convertor/
-
-#bus = smbus.SMBus(0) # Rev 1 Pi uses 0
-bus = smbus.SMBus(3) # Rev 2 Pi uses 1
-
-DEVICE = 0x20 # Device address (A0-A2)
-IODIRB = 0x0d # Pin pullups B-side
-IODIRA = 0x00 # Pin pullups A-side 0x0c
-IODIRApullup = 0x0c # Pin pullups A-side 0x0c
-GPIOB = 0x13 # Register B-side for inputs
-GPIOA = 0x12 # Register A-side for inputs
-OLATA = 0x14 # Register for outputs
-
-bus.write_byte_data(DEVICE,IODIRB,0xFF) # set all gpiob to input
-bus.write_byte_data(DEVICE,IODIRApullup,0xF3) # set two pullup inputs and two outputs
-bus.write_byte_data(DEVICE,IODIRA,0xF3) # set two inputs and two outputs
-bus.write_byte_data(DEVICE,OLATA,0x4)
-
-# Loop until user presses CTRL-C
-while True:
- # Read state of GPIOA register
- readbus = bus.read_byte_data(DEVICE,GPIOB)
- readbus2 = bus.read_byte_data(DEVICE,GPIOA)
- if readbus == 239:
- print "right"
- elif readbus == 247:
- print "left"
- elif readbus == 191:
- print "down"
- elif readbus == 254:
- print "up"
- elif readbus == 251:
- print "rightup"
- elif readbus == 253:
- print "leftup"
- elif readbus == 223:
- print "leftdown"
- elif readbus == 127:
- print "rightdown"
- elif readbus2 == 244:
- print "remove"
- #elif readbus2 == 247:
- # print "shutdown"
- #bus.write_byte_data(DEVICE,OLATA,0)
- #os.system('sudo shutdown -h now')
- #time.sleep(15)
- print readbus
- print readbus2
- bus.write_byte_data(DEVICE,OLATA,0xC)
- time.sleep(1)
- os.system('clear')
- bus.write_byte_data(DEVICE,OLATA,0x4)
- time.sleep(1)
diff --git a/random/settings.p b/random/settings.p
@@ -1,27 +0,0 @@
-(I50
-I-12
-I0
-L39806L
-L100L
-Voff
-p1
-(cfractions
-Fraction
-p2
-(S'129/128'
-tRp3
-g2
-(S'313/128'
-tRp4
-tp5
-S'yes'
-p6
-I50
-I50
-S'aaa'
-p7
-I1
-I7
-I1
-tp8
-.-
\ No newline at end of file
diff --git a/random/stream.sh b/random/stream.sh
@@ -1,3 +0,0 @@
-[ -d /tmp/capture ] || mkdir /tmp/capture; rm -f /tmp/capture/* && cd /tmp/capture/ && \
-raspivid -ih -t 0 -w 1280 -h 720 -b 1000000 -pf baseline -o - | /usr/bin/avconv -f alsa -ac 1 -i hw:0 -acodec aac -strict -2 \
--i - -vcodec copy -f segment -segment_list out.list out%10d
diff --git a/random/testings.wav b/random/testings.wav
Binary files differ.
diff --git a/random/vumeter.txt b/random/vumeter.txt
@@ -1 +0,0 @@
-#+ | 01%-
\ No newline at end of file
diff --git a/random/writefasterhack.sh b/random/writefasterhack.sh
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-echo 3 >/proc/sys/vm/dirty_background_ratio
-echo 50 >/proc/sys/vm/dirty_ratio
-echo 300 >/proc/sys/vm/dirty_writeback_centisecs
-echo 300 >/proc/sys/vm/dirty_expire_centisecs
-
diff --git a/rpihdtft/dt-blob-3bplus.bin b/rpihdtft/dt-blob-3bplus.bin
Binary files differ.
diff --git a/rpihdtft/dt-blob.bin b/rpihdtft/dt-blob.bin
Binary files differ.