gonzopi

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

commit 3992955dd589003c196703768cc9b604f24e3a96
parent 32821c82f29efeba7559267d144ba37d659ebec0
Author: rbckman <rob@tarina.org>
Date:   Wed,  8 Oct 2025 08:14:29 +0100

many fixes to edit mode and browser controller

Diffstat:
Mgonzopi.py | 12+++++++++---
Msrv/gonzopiserver.py | 163+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Msrv/static/style2.css | 39+++++++++++++++++++++++++++------------
Msrv/templates/base2.html | 2+-
Msrv/templates/edit.html | 2+-
Msrv/templates/index.html | 50+++++++++++++++++++++++++++++---------------------
6 files changed, 173 insertions(+), 95 deletions(-)

diff --git a/gonzopi.py b/gonzopi.py @@ -4979,6 +4979,7 @@ def shotfiles(filmfolder, filmname, scene): def rendervideo(filmfolder, filmname, scene, filmfiles, filename, renderinfo): videos_totalt = db.query("SELECT COUNT(*) AS videos FROM videos")[0] rendered_video = filmfolder+'.rendered/'+filmname+'_scene' + str(scene).zfill(3) + os.makedirs(filmfolder+'.rendered',exist_ok=True) tot = int(videos_totalt.videos) #video_origins=filmfolder+'.videos/'+datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5) scenedir = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/' @@ -5049,6 +5050,7 @@ def renderaudio(filmfolder, filmname, scene, audiofiles, filename, dubfiles, dub rendered_audio=filename else: rendered_audio = filmfolder+'.rendered/'+filmname+'_scene' + str(scene).zfill(3) + os.makedirs(filmfolder+'.rendered',exist_ok=True) print('Rendering audiofiles') ##PASTE AUDIO TOGETHER writemessage('Hold on, rendering audio...') @@ -5069,14 +5071,18 @@ def renderaudio(filmfolder, filmname, scene, audiofiles, filename, dubfiles, dub p = 1 #pipe = subprocess.check_output('mediainfo --Inform="Video;%Duration%" ' + filename + '.mp4', shell=True) #videolength = pipe.decode().strip() - videolength = get_video_length(filename+'.mp4') + try: + videolength = get_video_length(filename+'.mp4') + except: + videolength = 0 try: audiolength = get_audio_length(filename+'.wav') except: audiosilence(filename) audiolength = get_audio_length(filename+'.wav') - if audiolength > videolength: - audiotrim(filename, 'end','') + if videolength != 0 and videolength != None: + if audiolength > videolength: + audiotrim(filename, 'end','') for i, d in zip(dubmix, dubfiles): writemessage('Dub ' + str(p) + ' audio found lets mix...') #first trimit! diff --git a/srv/gonzopiserver.py b/srv/gonzopiserver.py @@ -32,8 +32,8 @@ urls = ( #--------------USB filmfolder------------------- -def usbfilmfolder(): - usbmount = 0 +def usbfilmfolder(dsk): + usbmount = dsk while True: usbconnected = os.path.ismount('/media/usb'+str(usbmount)) time.sleep(0.02) @@ -68,7 +68,7 @@ real_filmfolder=filmfolder os.system("unlink static/*") #CHECK IF FILMING TO USB STORAGE -filmfolderusb=usbfilmfolder() +filmfolderusb=usbfilmfolder(0) if filmfolderusb: filmfolder=filmfolderusb real_filmfolder=filmfolder @@ -116,6 +116,9 @@ recording = False session.randhash = hashlib.md5(str(random.getrandbits(256)).encode('utf-8')).hexdigest() +oldhash = '' +oldthumb = '' + ##---------------Connection---------------------------------------------- def pingtocamera(host, port, data): @@ -370,6 +373,11 @@ class index: except: selected=0 try: + dsk=menu[3].split(':')[1].split(' ')[0] + dsk=dsk.rstrip('\n') + except: + dsk='' + try: name=menu[4].split(':')[1] name=name.rstrip('\n') except: @@ -405,7 +413,7 @@ class index: if os.path.isfile(basedir+thumb) == False: print(basedir+thumb) thumb='' - return render.index(allfilms, session.cameras, menu, selected,name,scene,shot,take,str,session.randhash,thumb,vumetermessage,i.func,filmfolder) + return render2.index(allfilms, session.cameras, menu, selected,name,scene,shot,take,str,session.randhash,thumb,vumetermessage,i.func,filmfolder, dsk) class films: def GET(self, film): @@ -466,6 +474,39 @@ class edit: def GET(self, film): shots = 0 takes = 0 + interface=open('/dev/shm/interface','r') + vumeter=open('/dev/shm/vumeter','r') + menu=interface.readlines() + vumetermessage=vumeter.readlines()[0].rstrip('\n') + try: + selected=int(menu[0]) + except: + selected=0 + try: + dsk=menu[3].split(':')[1].split(' ')[0] + dsk=dsk.rstrip('\n')[-1:] + dsk=int(dsk) + except: + dsk=0 + filmfolder = '/home/pi/gonzopifilms/' + real_filmfolder=filmfolder + os.system("unlink static/*") + #CHECK IF FILMING TO USB STORAGE + filmfolderusb=usbfilmfolder(dsk) + if filmfolderusb: + filmfolder=filmfolderusb + real_filmfolder=filmfolder + # Link video directory to static dir + os.system("ln -s -t static/ " + filmfolder) + filmfolder='static/gonzopifilms/' + filmdb = filmfolder+'.videos/gonzopi.db' + db = web.database(dbn='sqlite', db=filmdb) + else: + os.system("ln -s -t static/ " + filmfolder) + filmfolder='static/gonzopifilms/' + #fix filmfolder root to Videos/gonzopifilms + filmdb = filmfolder+'.videos/gonzopi.db' + db = web.database(dbn='sqlite', db=filmdb) gonzopifilms = getfilms(filmfolder) renderedfilms = [] unrenderedfilms = [] @@ -620,7 +661,7 @@ class api: return json.dumps({"film": film, "scene":scene,"shot":shot,"isActive":isActive, "selected":selected_videos}) def POST(self): - global menuold, vumeterold + global menuold, vumeterold, oldthumb, oldhash i=web.input(func=None,selected=None, scene=None, shot=None, film=None) if i.func == 'record': sendtocamera(ip,port,'RECORD') @@ -684,60 +725,63 @@ class api: p=0 film=None selectfilm=False - if menu != '': + if menu != '' and menu != ' ': scene=1 shot=1 take=1 for i in menu: - if p == 0: - selected=int(i)+3 - if p > 1: - if selected == p: - #menudone=menudone+'<b> '+i.rstrip('\n')+' </b> | ' + if i != '' and i != ' ': + if p == 0: + selected=int(i)+3 + if p > 1: + if selected == p: + if i.rstrip('\n') != '': + #menudone=menudone+'<b> '+i.rstrip('\n')+' </b> | ' + menudone=menudone+'<ka style="text-decoration:none; font-size:20px;" color:fff;" href="">'+i+'</ka>' + else: + if i.rstrip('\n') != '': + #menudone=menudone+i.rstrip('\n')+' | ' + menudone=menudone+'<a style="text-decoration:none; font-size:20px;" href="?selected='+str(p-3)+'"> '+i+' </a>' + #if p == 7: + # menudone=menudone+'<br>' + #if p == 13: + # menudone=menudone+'<br>' + #if p == 21: + # menudone=menudone+'<br>' + #if p == 30: + # menudone=menudone+'<br>' + if p == 2 and i.rstrip('\n') == 'Up and down to select and load film': + selectfilm=True + if p == 3 and selectfilm==True: + try: + film=i.split(':')[1].rstrip('\n') + except: + film=None + if p == 4 and selectfilm == False: + try: + film=i.split(':')[1].rstrip('\n') + except: + film=None + if p == 5 and film != None: + try: + scene=int(i.split(':')[1].split('/')[0]) + except: + scene=1 + if p == 6 and film != None: + try: + shot=int(i.split(':')[1].split('/')[0]) + except: + shot=1 + if p == 7 and film != None: + try: + take=int(i.split(':')[1].split('/')[0]) + except: + take=1 + if p > 0 and selected == 423: menudone=menudone+'<ka style="text-decoration:none; font-size:20px;" color:fff;" href="">'+i+'</ka>' - else: - #menudone=menudone+i.rstrip('\n')+' | ' - menudone=menudone+'<a style="text-decoration:none; font-size:20px;" href="?selected='+str(p-3)+'"> '+i+' </a>' - #if p == 7: - # menudone=menudone+'<br>' - #if p == 13: - # menudone=menudone+'<br>' - #if p == 21: - # menudone=menudone+'<br>' - #if p == 30: - # menudone=menudone+'<br>' - if p == 2 and i.rstrip('\n') == 'Up and down to select and load film': - selectfilm=True - if p == 3 and selectfilm==True: - try: - film=i.split(':')[1].rstrip('\n') - except: - film=None - if p == 4 and selectfilm == False: - try: - film=i.split(':')[1].rstrip('\n') - except: - film=None - if p == 5 and film != None: - try: - scene=int(i.split(':')[1].split('/')[0]) - except: - scene=1 - if p == 6 and film != None: - try: - shot=int(i.split(':')[1].split('/')[0]) - except: - shot=1 - if p == 7 and film != None: - try: - take=int(i.split(':')[1].split('/')[0]) - except: - take=1 - if p > 0 and selected == 423: - menudone=menudone+'<ka style="text-decoration:none; font-size:20px;" color:fff;" href="">'+i+'</ka>' - #if p > 2 and film == None: - #menudone=menudone+'<ka style="text-decoration:none; font-size:20px;" color:fff;" href="">'+i+'</ka>' - p = p + 1 + #if p > 2 and film == None: + #menudone=menudone+'<ka style="text-decoration:none; font-size:20px;" color:fff;" href="">'+i+'</ka>' + p = p + 1 thumb = '' video = '' if film != None: @@ -756,9 +800,14 @@ class api: video = '/p/'+film+'?scene='+str(scene)+'&shot='+str(shot)+'&take='+str(take) thumb = '/'+filmfolder + film + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".jpeg" if os.path.isfile(basedir+thumb) == True: - randhashimg = '?'+hashlib.md5(str(random.getrandbits(256)).encode('utf-8')).hexdigest() - writemenu=menudone+'<br><br>'+vumetermessage+'<br><a href="'+video+'"><img src="'+thumb+randhashimg+'"></a>' - #writemenu=menudone+render.player(filmfolder,film,scene,shot,take,str) + if oldthumb != basedir+thumb: + randhashimg = '?'+hashlib.md5(str(random.getrandbits(256)).encode('utf-8')).hexdigest() + oldhash = randhashimg + oldthumb = basedir+thumb + else: + randhashimg = oldhash + writemenu=menudone+'<br><br>'+vumetermessage+'<br><a href="'+video+'"><img src="'+thumb+randhashimg+'"><br></a>'+'<a href="/e/'+film+'">edit view</a>' + #writemenu=menudone+render.player(filmfolder,film,scene,shot,take,str) else: writemenu=menudone+'<br><br>'+vumetermessage+'<br>' f = open(basedir+'/static/menu.html', 'w') diff --git a/srv/static/style2.css b/srv/static/style2.css @@ -7,7 +7,6 @@ body font-family: monospace; font-size: 10px; width: 100%; - white-space: nowrap } pre @@ -26,14 +25,30 @@ a img { - width: 90%; + width: 97%; max-width: 800px; } -#controller { - position: fixed; - margin: 0 auto; - background-color:#231f20; +.responsive-div { + display: none; /* Hide by default */ + text-align: center; + +} +@media (max-width: 700px) { + .responsive-div { + display: block; /* Show when screen width is 500px or less */ + position: fixed; + margin: 0 auto; + background-color:#231f20; + font-weight: normal; + font-size: 17px; + bottom:0px; + padding-top:10px; + width: 100%; + } +} + +.controller { font-weight: normal; font-size: 17px; bottom:0px; @@ -41,7 +56,7 @@ img width: 100%; } -#controller a +.controller a { margin-bottom: 20px; color: #FFF; @@ -53,7 +68,7 @@ img border-radius: 10px } -#controller a:active +.controller a:active { margin-bottom: 20px; color: #000; @@ -65,7 +80,7 @@ img border-radius: 10px } -#controller2 a +.controller2 a { margin-bottom: 20px; color: #FFF; @@ -77,7 +92,7 @@ img border-radius: 10px } -#controller2 a:active +.controller2 a:active { margin-bottom: 20px; color: #000; @@ -89,7 +104,7 @@ img border-radius: 10px } -#controller3 a +.controller3 a { margin-bottom: 20px; color: #FFF; @@ -101,7 +116,7 @@ img border-radius: 10px } -#controller3 a:active +.controller3 a:active { margin-bottom: 20px; color: #000; diff --git a/srv/templates/base2.html b/srv/templates/base2.html @@ -3,7 +3,7 @@ $def with (content) <HEAD> <meta charset="utf-8"> <title>Gonzo Pi | a reboot of filmmaking </title> - <link rel="stylesheet" href="/static/style2.css?v=5955" type="text/css" rel="stylesheet"/> + <link rel="stylesheet" href="/static/style2.css?v=97" type="text/css" rel="stylesheet"/> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="/static/jquery-3.7.1.min.js" type="text/javascript"></script> <script src="/static/jquery-ui.min.js" type="text/javascript"></script> diff --git a/srv/templates/edit.html b/srv/templates/edit.html @@ -87,7 +87,7 @@ button { <br> <a href="/c/">camera control</a> <div class="responsive-div"> -<div id="controller"> +<div class="controller"> <a id="VIEW">VIEW</a> <a id="UP">UP</a> <a id="RECORD">RECORD</a><br> <a id="LEFT">LEFT</a> <a id="MIDDLE">MIDDLE</a> <a id="RIGHT">RIGHT</a><br> <a id="DELETE">DELETE</a> <a id="DOWN">DOWN</a> <a id="RETAKE">RETAKE</a><br> diff --git a/srv/templates/index.html b/srv/templates/index.html @@ -1,4 +1,4 @@ -$def with (films, cameras, menu, selected,name,scene,shot,take,str,randhash,thumb,vumetermessage,func,filmfolder) +$def with (films, cameras, menu, selected,name,scene,shot,take,str,randhash,thumb,vumetermessage,func,filmfolder,dsk) <script> function Get(yourUrl){ @@ -87,14 +87,19 @@ $$(document).on('keydown', function (event) { } else if (event.which == 39) { $$('#RIGHT').trigger('click'); } else if (event.which == 38) { + event.preventDefault(); $$('#UP').trigger('click'); } else if (event.which == 40) { + event.preventDefault(); $$('#DOWN').trigger('click'); } else if (event.which == 33) { + event.preventDefault(); $$('#RECORD').trigger('click'); } else if (event.which == 32) { + event.preventDefault(); $$('#RECORD').trigger('click'); } else if (event.which == 34) { + event.preventDefault(); $$('#RETAKE').trigger('click'); } else if (event.which == 9) { event.preventDefault(); @@ -156,26 +161,6 @@ connected <pre>use keyboard to control</pre> $for i in cameras: $i -<a href="/e/$name">edit view</a> -<div id="controller"> -<a id="VIEW">VIEW</a> <a id="UP">UP</a> <a id="RECORD">RECORD</a><br> -<a id="LEFT">LEFT</a> <a id="MIDDLE">MIDDLE</a> <a id="RIGHT">RIGHT</a><br> -<a id="DELETE">DELETE</a> <a id="DOWN">DOWN</a> <a id="RETAKE">RETAKE</a><br> -</div> -<div id="controller2"> -<a id="CAMERA0">CAM1</a> <a id="CAMERA1">CAM2</a> <a id="CAMERA2">CAM3</a><br> -<a id="CAMERA3">CAM4</a> <a id="CAMERA4">CAM5</a> <a id="CAMERA5">CAM6</a><br> -</div> -<div id="controller3"> -<a id="MOVE">MOVE</a> <a id="COPY">COPY</a> <a id="PASTE">PASTE</a><br> -</div> - -<div id="menu2" style="margin:0 auto; width:99%" ></div> -<div id="menu" style="margin:0 auto; width:99%"> -</div> -<br> -<br> -<input></input> $if thumb != '': $ picture= '/'+filmfolder + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/picture" + str(take).zfill(3) + ".jpeg" @@ -195,6 +180,29 @@ $if thumb != '': <a href='$take_link'><img width="80%" src="$picture?$randhash"/></a><br> <br> +<div class="responsive-div"> + +<div class="controller"> +<a id="VIEW">VIEW</a> <a id="UP">UP</a> <a id="RECORD">RECORD</a><br> +<a id="LEFT">LEFT</a> <a id="MIDDLE">MIDDLE</a> <a id="RIGHT">RIGHT</a><br> +<a id="DELETE">DELETE</a> <a id="DOWN">DOWN</a> <a id="RETAKE">RETAKE</a><br> +</div> + +<div class="controller2"> +<a id="CAMERA0">CAM1</a> <a id="CAMERA1">CAM2</a> <a id="CAMERA2">CAM3</a><br> +<a id="CAMERA3">CAM4</a> <a id="CAMERA4">CAM5</a> <a id="CAMERA5">CAM6</a><br> +</div> + +<div class="controller3"> +<a id="MOVE">MOVE</a> <a id="COPY">COPY</a> <a id="PASTE">PASTE</a><br> +</div> + +</div> + +<div id="menu2" style="width:95%; max-width:800px;" ></div> +<div id="menu" style="width:95%; max-width:800px;"> +</div> + <script> $$('#CAMERA0').on('click', function () { $$.ajax({