tarina

git clone https://git.tarina.org/tarina
Log | Files | Refs | README | LICENSE

commit 78a7eebc9359867a3d7be3f5c6a54b04d971abfc
parent dc8829eb8cd8aff1bb9c607d5ec35f21d390fcce
Author: Robin Bäckman <robinbackman@gmail.com>
Date:   Wed, 10 Aug 2016 20:10:34 +0300

added copy to usb feature

Diffstat:
MINSTALL | 2+-
MREADME | 2+-
Mtarina.py | 130++++++++++++++++++++++++++++++++++----------------------------------------------
3 files changed, 57 insertions(+), 77 deletions(-)

diff --git a/INSTALL b/INSTALL @@ -20,7 +20,7 @@ enable camera, extend filesystem and reboot 2. sudo apt-get update 3. sudo apt-get upgrade -4. sudo apt-get install git python-picamera python-imaging python-pexpect libav-tools gpac omxplayer sox cpufrequtils +4. sudo apt-get install git python-picamera python-imaging python-pexpect libav-tools gpac omxplayer sox cpufrequtils usbmount 5. git clone https://rbckman@bitbucket.org/rbckman/tarina.git diff --git a/README b/README @@ -14,7 +14,7 @@ Blender file and printable stls in 3d folder ---------------||Installing||----------------- -1. sudo apt-get install git python-picamera python-imaging python-pexpect libav-tools gpac omxplayer sox cpufrequtils +1. sudo apt-get install git python-picamera python-imaging python-pexpect libav-tools gpac omxplayer sox cpufrequtils usbmount 2. git clone https://rbckman@bitbucket.org/rbckman/tarina.git diff --git a/tarina.py b/tarina.py @@ -217,8 +217,8 @@ def renderlist(filmname, filmfolder, scene): 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) + #writemessage(str(len(scenefiles))) + #time.sleep(2) return scenefiles #-------------Render thumbnails------------ @@ -285,58 +285,6 @@ def removeimage(camera, overlay): overlay = None camera.start_preview() -#-------------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): @@ -763,7 +711,7 @@ def compileshot(filename): def render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, filename, tarinafolder): #print filmfiles - writemessage('Hold on, rendering ' + str(len(filmfiles)) + ' files ' + str(renderedshots) + str(renderfullscene)) + writemessage('Hold on, rendering ' + str(len(filmfiles)) + ' files') time.sleep(2) render = 0 #CHECK IF THERE IS A RENDERED VIDEO @@ -784,7 +732,8 @@ def render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, fi videomerge.append('-cat') videomerge.append(f + '.h264') videomerge.append('-new') - videomerge.append(filename + '.h264') + videomerge.append(filename + '.mp4') + #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') @@ -797,26 +746,15 @@ def render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, fi audiomerge.append(filename + '.wav') call(audiomerge, shell=False) ##CONVERT AUDIO IF WAV FILES FOUND - if os.path.isfile(filename + '.wav'): - 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) - else: - writemessage('No audio files found! View INSTALL file for instructions.') - call(['MP4Box', '-add', filename + '.h264', '-new', filename + '.mp4'], shell=False) - #call(['MP4Box', '-add', filename + '.h264', '-new', filename + '.mp4'], shell=False) - #shotsrendered = shot + #if os.path.isfile(filename + '.wav'): + # 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) + #else: + # writemessage('No audio files found! View INSTALL file for instructions.') + # call(['MP4Box', '-add', filename + '.h264', '-new', filename + '.mp4'], shell=False) 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------------------------ @@ -877,6 +815,43 @@ def viewfilm(filmfolder, filmname): scene = scene + 1 return filmfiles +#--------------Copy to USB------------------- + +def copytousb(filmfolder, filmname): + pressed = '' + buttonpressed = '' + buttontime = time.time() + holdbutton = '' + writemessage('Searching for usb storage device, middlebutton to cancel') + while True: + pressed, buttonpressed, buttontime, holdbutton = getbutton(pressed, buttonpressed, buttontime, holdbutton) + usbconnected = os.path.ismount('/media/usb0') + if pressed == 'middle': + break + time.sleep(0.02) + if usbconnected == True: + writemessage('USB device found, copying files...') + #COUNT FILES + 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 + #RENDER FILES TO MP4 ON USB STICK + os.system('mkdir -p /media/usb0/' + filmname) + for f in filmfiles[:]: + os.system('MP4Box -add ' + f + '.h264 -new /media/usb0/' + filmname + '/' + f[-24:] + '.mp4') + os.system('cp ' + f + '.wav /media/usb0/' + filmname + '/' + f[-24:] + '.wav') + os.system('sync') + writemessage('all files copied successfully!') + time.sleep(1) + writemessage('You can safely unplug the usb device now') + time.sleep(2) + return + #-------------Upload Scene------------ def uploadfilm(filename, filmname): @@ -1192,6 +1167,11 @@ def main(): renderedshots, renderfullscene, playfile = render(scene, shot, filmfolder, filmname, renderedshots, renderfullscene, filmfiles, renderfilename, tarinafolder) playthis(playfile, camera) + #COPY TO USB + elif pressed == 'middle' and selectedaction == 2: + if recording == False: + copytousb(filmfolder, filmname) + #NEW SCENE elif pressed == 'middle' and selectedaction == 22: if recording == False: