commit d8d72f55f6315774d919190acdd1fff8a832287b
parent cef77cad8a1c3469294f937959f9de581414254e
Author: rbckman <rob@tarina.org>
Date: Thu, 29 May 2025 16:13:39 +0100
crucial bug fixes, split function, tree view, dubs now organize right
Diffstat:
7 files changed, 361 insertions(+), 28 deletions(-)
diff --git a/VERSION b/VERSION
@@ -1,2 +1,2 @@
-2.19
+2.20
Gilliam
diff --git a/gonzopi.py b/gonzopi.py
@@ -527,7 +527,9 @@ def main():
renderfilename, newaudiomix = rendershot(filmfolder, filmname, foldername+filename, scene, shot)
if renderfilename == foldername+filename:
trim, split_list = playdub(filmname,foldername + filename, 'shot',take)
- if split_list:
+ if split_list != []:
+ print(split_list)
+ #time.sleep(5)
split_list_save(foldername, split_list)
writemessage('Splits saved! press view to see them.')
else:
@@ -4175,7 +4177,7 @@ def add_organize(filmfolder, filmname):
if 'yanked' in p:
#print(p)
os.system('mv -n ' + filmfolder + filmname + '/' + i + '/shot' + str(organized_nr - 1).zfill(3) + '_yanked ' + filmfolder + filmname + '/' + i + '/shot' + str(organized_nr).zfill(3))
- elif 'insert' in p:
+ elif '_insert' in p:
os.system('mv -n ' + filmfolder + filmname + '/' + i + '/shot' + str(organized_nr - 1).zfill(3) + '_insert ' + filmfolder + filmname + '/' + i + '/shot' + str(organized_nr).zfill(3))
run_command('touch ' + filmfolder + filmname + '/' + i + '/shot' + str(organized_nr).zfill(3) + '/.placeholder')
elif 'shot' in p:
@@ -4195,7 +4197,7 @@ def add_organize(filmfolder, filmname):
#print(i)
if 'yanked' in i:
os.system('mv -n ' + filmfolder + filmname + '/scene' + str(organized_nr - 1).zfill(3) + '_yanked ' + filmfolder + filmname + '/scene' + str(organized_nr).zfill(3))
- elif 'insert' in i:
+ elif '_insert' in i:
#print(p)
os.system('mv -n ' + filmfolder + filmname + '/scene' + str(organized_nr - 1).zfill(3) + '_insert ' + filmfolder + filmname + '/scene' + str(organized_nr).zfill(3))
run_command('touch ' + filmfolder + filmname + '/scene' + str(organized_nr).zfill(3) + '/.placeholder')
@@ -4211,6 +4213,34 @@ def add_organize(filmfolder, filmname):
organized_nr -= 1
return
+#------------Organize and move dubs----------------
+
+def organizedubs(foldername):
+ dubs = next(os.walk(foldername))[2]
+ print(dubs)
+ time.sleep(3)
+ for c in dubs:
+ if 'dub' not in c:
+ dubs.remove(c)
+ organized_nr = len(dubs)
+ for p in sorted(dubs, reverse=True):
+ print(p)
+ time.sleep(3)
+ if '_insert' in p:
+ os.system('mv -n ' + foldername + 'dub' + str(organized_nr).zfill(3) + '_insert.wav ' + foldername + 'dub' + str(organized_nr).zfill(3)+'.wav')
+ elif 'dub' in p:
+ print(p)
+ time.sleep(3)
+ unorganized_nr = int(p[5:-4])
+ if organized_nr == unorganized_nr:
+ print('correct')
+ time.sleep(3)
+ pass
+ if organized_nr != unorganized_nr:
+ print('false, correcting from ' + str(unorganized_nr) + ' to ' + str(organized_nr))
+ time.sleep(3)
+ os.system('mv -n ' + foldername + 'dub' + str(unorganized_nr).zfill(3) + '.wav ' + foldername + 'dub' + str(organized_nr).zfill(3)+'.wav')
+ organized_nr -= 1
#-------------Stretch Audio--------------
@@ -4522,6 +4552,9 @@ def renderaudio(audiofiles, filename, dubfiles, dubmix):
time.sleep(5)
except:
pass
+ #print(d)
+ #print(filename)
+ #time.sleep(3)
os.system('cp ' + filename + '.wav ' + filename + '_tmp.wav')
#Fade and make stereo
run_command('sox -V0 -b 16 -G ' + d + ' -c 2 /dev/shm/fade.wav fade ' + str(round(i[2],1)) + ' 0 ' + str(round(i[3],1)))
@@ -4645,21 +4678,38 @@ def rendershot(filmfolder, filmname, renderfilename, scene, shot):
settings = pickle.load(open(scenedir + ".split", "rb"))
split_list = settings
logger.info("settings loaded")
+ nr=1
for i in split_list:
- newshotdir = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '_insert/'
- newtakename = 'take' + str(1).zfill(3)
- try:
- os.makedirs(newshotdir)
- except:
- print('is there already prob')
- videotrim(scenedir,i[1],'both', i[0][0],i[0][1],newshotdir+newtakename)
+ if nr == 1:
+ #make first split as a new take in the original shot
+ newshotdir = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/'
+ newtakename = 'take' + str(counttakes2(newshotdir)).zfill(3)
+ if i[0][0] < i[0][1]:
+ videotrim(scenedir,i[1],'both', i[0][0],i[0][1],'take')
+ #newtakename = 'take' + str(1).zfill(3)
+ elif nr > 1:
+ #then make new shots
+ newshotdir = filmfolder + filmname + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '_insert/'
+ newtakename = 'take' + str(1).zfill(3)
+ try:
+ os.makedirs(newshotdir)
+ except:
+ print('is there already prob')
+ if i[0][0] < i[0][1]:
+ videotrim(scenedir,i[1],'both', i[0][0],i[0][1],newshotdir+newtakename)
add_organize(filmfolder, filmname)
scenes, shots, takes = browse(filmname,filmfolder,scene,shot,1)
#vumetermessage('Shot ' + str(shot) + ' inserted')
updatethumb = True
time.sleep(1)
+ nr=nr+1
shot=shot+1
os.remove(scenedir+'.split')
+ take=counttakes2(scenedir)
+ updatethumb=True
+ rendermenu = True
+ newaudiomix = True
+ renderfilename = scenedir+'take' + str(counttakes2(scenedir)).zfill(3)
elif os.path.isfile(scenedir+'.beginning') == True and os.path.isfile(scenedir+'.end') == True:
settings = pickle.load(open(scenedir + ".beginning", "rb"))
s, trimfile = settings
@@ -5180,6 +5230,7 @@ def getdubs(filmfolder, filmname, scene, shot):
if 'dub' in a:
print('Dub audio found! ' + filefolder + a)
dubfiles.append(filefolder + a)
+ dubfiles.sort()
#check if dub mix has changed
dubnr = 1
for i in dubfiles:
@@ -5358,6 +5409,15 @@ def clipsettings(filmfolder, filmname, scene, shot, take, plughw, yanked):
elif pressed == 'down' and selected == 4:
if dubselected > 0:
dubselected = dubselected - 1
+ elif pressed == 'move' and selected == 4:
+ vumetermessage('press insert button to move dub')
+ movedub = filefolder + 'dub' + str(dubselected + 1).zfill(3) + '.wav'
+ elif pressed == 'insert' and selected == 4:
+ vumetermessage('moving dub please hold on')
+ pastedub = filefolder + 'dub' + str(dubselected + 1).zfill(3) + '_insert.wav'
+ os.system('mv -n ' + movedub + ' ' + pastedub)
+ organizedubs(filefolder)
+ pastedub=''
elif pressed == 'remove' and selected == 4:
removedub(filefolder, dubselected + 1)
dubfiles, dubmix, newmix = getdubs(filmfolder, filmname, scene, shot)
@@ -5405,15 +5465,19 @@ def clipsettings(filmfolder, filmname, scene, shot, take, plughw, yanked):
elif pressed == 'middle' and menu[selected] == 'BACK':
os.system('pkill aplay')
break
- elif pressed == 'view': # mix dub and listen
+ elif pressed == 'views': # mix dub and listen
run_command('pkill aplay')
dubfiles, dubmix, rerender = getdubs(filmfolder, filmname, scene, shot)
if scene:
filename = filmfolder + filmname + '/scene' + str(scene).zfill(3) +'/scene'
+ renderfilename = renderfilm(filmfolder, filmname, 0, scene)
+ playdub(filmname,renderfilename, 'scene',take)
+ elif shot and scene:
+ filename = filmfolder + filmname + '/scene' + str(scene).zfill(3) +'/shot' + str(scene).zfill(3)+'/shot'
+ renderfilename = renderfilm(filmfolder, filmname, 0, scene)
+ playdub(filmname,renderfilename, 'shot',take)
else:
filename = filmfolder + filmname + '/' + filmname
- renderfilename = renderfilm(filmfolder, filmname, 0, scene)
- playdub(filmname,renderfilename, 'scene',take)
time.sleep(0.05)
#Save dubmix before returning
if dubmix != dubmix_old:
@@ -5482,12 +5546,11 @@ def playdub(filmname, filename, player_menu, take):
oldmenu=''
if video == True:
if player_menu == 'dubbb':
- pause = False
try:
if hdmi_mode==False:
- player = OMXPlayer(filename + '.mp4', args=['-n', '-1', '--fps', '25', '--layer', '3', '--no-osd', '--win', '0,15,800,475','--no-keys'], dbus_name='org.mpris.MediaPlayer2.omxplayer1', pause=True)
+ player = OMXPlayer(filename + '.mp4', args=['-n', '-1', '--fps', '25', '--layer', '3', '--no-osd', '--win', '0,15,800,475','--no-keys', '--loop'], dbus_name='org.mpris.MediaPlayer2.omxplayer1', pause=True)
else:
- player = OMXPlayer(filename + '.mp4', args=['-n', '-1', '--fps', '25', '--layer', '3', '--no-osd','--win', '0,15,1920,1080','--no-keys'], dbus_name='org.mpris.MediaPlayer2.omxplayer1', pause=True)
+ player = OMXPlayer(filename + '.mp4', args=['-n', '-1', '--fps', '25', '--layer', '3', '--no-osd','--win', '0,15,1920,1080','--no-keys', '--loop'], dbus_name='org.mpris.MediaPlayer2.omxplayer1', pause=True)
except:
writemessage('Something wrong with omxplayer')
time.sleep(0.1)
@@ -5684,15 +5747,16 @@ def playdub(filmname, filename, player_menu, take):
if sound == False:
playerAudio.play()
elif pressed == 'record':
- split_list.append([[trimfromstart, trimfromend], takename])
- vumetermessage('split '+str(len(split_list))+' position set to: '+ str(player.position()))
- player.pause()
- if sound == False:
- playerAudio.pause()
- time.sleep(0.5)
- player.play()
- if sound == False:
- playerAudio.play()
+ if trimfromstart != 0 and trimfromend != 0 and trimfromstart < trimfromend:
+ split_list.append([[trimfromstart, trimfromend], takename])
+ vumetermessage('split '+str(len(split_list))+' position set to: '+ str(player.position()))
+ player.pause()
+ if sound == False:
+ playerAudio.pause()
+ time.sleep(0.5)
+ player.play()
+ if sound == False:
+ playerAudio.play()
elif pressed == 'retake':
if player.position() < clipduration:
trimfromend = player.position()
@@ -5788,13 +5852,13 @@ def playdub(filmname, filename, player_menu, take):
trim = ['beginning', player.position()]
player.quit()
#playerAudio.quit()
- return trim
+ return trim, split_list
elif menu[selected] == 'FROM END':
trim = ['end', player.position()]
player.quit()
if sound == False:
playerAudio.quit()
- return trim
+ return trim, split_list
time.sleep(0.02)
if pause == False:
try:
diff --git a/srv/gonzopiserver.py b/srv/gonzopiserver.py
@@ -20,6 +20,7 @@ urls = (
'/','intro',
'/c/?', 'index',
'/f/(.*)?', 'films',
+ '/t/(.*)?', 'tree',
'/p/(.*)?', 'player',
'/api','api'
)
@@ -93,6 +94,7 @@ network=networks[0]
app = web.application(urls, globals())
render = web.template.render('templates/', base="base")
+render2 = web.template.render('templates/', base="base2")
web.config.debug=False
os.system('rm '+basedir+'/sessions/*')
store = web.session.DiskStore(basedir + '/sessions/')
@@ -200,6 +202,15 @@ def checkpicture(thumbdir,scene,shot,take):
else:
return ''
+def if_exist(dir):
+ print(basedir+dir)
+ if os.path.isfile(basedir+dir) == False:
+ print('thumb not exist')
+ return False
+ else:
+ print('thumb is')
+ return True
+
def countsize(filename):
size = 0
if type(filename) is str:
@@ -388,6 +399,32 @@ class films:
scenes = countscenes(filmfolder, film)
return render.filmpage(allfilms, film, scenes, str, filmfolder, counttakes, countshots, shots, i.scene, takes, i.shot, i.take, checkvideo, randhash)
+class tree:
+ def GET(self, film):
+ shots = 0
+ takes = 0
+ gonzopifilms = getfilms(filmfolder)
+ renderedfilms = []
+ unrenderedfilms = []
+ allfilms = []
+ for f in gonzopifilms:
+ if os.path.isfile(filmfolder + f[0] + '/' + f[0] + '.mp4') == True:
+ renderedfilms.append(f[0])
+ allfilms.append(f[0])
+ else:
+ unrenderedfilms.append(f[0])
+ allfilms.append(f[0])
+ i = web.input(page=None, scene=None, shot=None, take=None, film=None, randhash=None)
+ if i.scene != None:
+ shots = countshots(film, filmfolder, i.scene)
+ takes = counttakes(film, filmfolder, i.scene, i.shot)
+ if i.scene != None and i.shot != None:
+ shots = countshots(film, filmfolder, i.scene)
+ if i.randhash == None:
+ randhash = hashlib.md5(str(random.getrandbits(256)).encode('utf-8')).hexdigest()
+ scenes = countscenes(filmfolder, film)
+ return render2.tree(allfilms, film, scenes, str, filmfolder, counttakes, countshots, countscenes, shots, i.scene, takes, i.shot, i.take, checkvideo, randhash, if_exist)
+
class player:
def GET(self, film):
i=web.input(scene=None,shot=None,take=None)
diff --git a/srv/static/empty.jpeg b/srv/static/empty.jpeg
Binary files differ.
diff --git a/srv/static/style2.css b/srv/static/style2.css
@@ -0,0 +1,126 @@
+body
+{
+ margin: 0px auto;
+ text-align: left;
+ background-color:#000;
+ color: #f4f4f4;
+ font-family: monospace;
+ width: 100%;
+ white-space: nowrap
+}
+
+pre
+{
+ margin: 5px auto;
+ padding: 3px;
+ display: inline-block;
+ background-color: #555;
+ color: #fff;
+}
+
+a
+{
+ color: #FCD612;
+ padding: 5px;
+}
+
+img
+{
+ width: 90%;
+ max-width: 800px;
+}
+
+#controller a
+{
+ margin-bottom: 20px;
+ color: #FFF;
+ line-height:60px;
+ background-color: #555;
+ font-size: 30px;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 10px
+}
+
+#controller a:active
+{
+ margin-bottom: 20px;
+ color: #000;
+ line-height:60px;
+ background-color: #FFF;
+ font-size: 30px;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 10px
+}
+
+#controller2 a
+{
+ margin-bottom: 20px;
+ color: #FFF;
+ line-height:60px;
+ background-color: #777;
+ font-size: 30px;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 10px
+}
+
+#controller2 a:active
+{
+ margin-bottom: 20px;
+ color: #000;
+ line-height:60px;
+ background-color: #FFF;
+ font-size: 30px;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 10px
+}
+
+#controller3 a
+{
+ margin-bottom: 20px;
+ color: #FFF;
+ line-height:50px;
+ background-color: #888;
+ font-size: 20px;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 10px
+}
+
+#controller3 a:active
+{
+ margin-bottom: 20px;
+ color: #000;
+ line-height:50px;
+ background-color: #FFF;
+ font-size: 20px;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 10px
+}
+
+.player-container {
+width: 90vw; /* 100% of viewport width */
+margin: 0 auto;
+font-family: Arial, sans-serif;
+}
+video {
+width: 100%; /* Takes full width of container */
+height: auto; /* Maintains aspect ratio */
+display: block; /* Removes bottom gap */
+}
+.controls {
+padding: 10px; /* Better spacing on mobile */
+text-align: center; /* Center buttons */
+}
+/* Optional: Add max-width for very large screens */
+@media (min-width: 1200px) {
+.player-container {
+max-width: 1200px; /* Optional maximum width */
+margin: 0 auto; /* Centers on large screens */
+}
+}
+
diff --git a/srv/templates/base2.html b/srv/templates/base2.html
@@ -0,0 +1,15 @@
+$def with (content)
+<!doctype html>
+<HEAD>
+ <meta charset="utf-8">
+ <title>Gonzo Pi | a reboot of filmmaking </title>
+ <link rel="stylesheet" href="/static/style2.css?v=165" 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>
+</HEAD>
+
+<BODY>
+
+ $:content
+
+</BODY>
diff --git a/srv/templates/tree.html b/srv/templates/tree.html
@@ -0,0 +1,91 @@
+$def with (films, film, scenes, str, filmfolder, counttakes, countshots, countscenes, shots, scene, takes, shot, take, checkvideo,randhash, if_exist)
+$ video = ''
+$if take != None:
+ <h1>$film | scene $scene | shot $shot | take $take</h1>
+ $ video = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/take' + str(take).zfill(3) + '.mp4'
+$elif shot != None:
+ <h1>$film | scene $scene | shot $shot</h1>
+ $ video = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/take' + str(takes).zfill(3) + '.mp4'
+ $ take = takes
+$elif scene != None:
+ <h1>$film | scene $scene</h1>
+ $ video = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/scene.mp4'
+$elif film != '':
+ <h1>$film</h1>
+ $ video = '/'+filmfolder + film + '/' + film + '.mp4'
+$if video != '':
+ <br>
+ <h3><a href="javascript:history.back()">Go Back</a></h3>
+ <br>
+ $ picture = checkvideo(video,filmfolder,film,scene,shot,take)
+ $if picture[1] == 'video':
+ <video width="80%" controls>
+ <source src="$video?$randhash" style="width:80%; max-width:500px;" type="video/mp4">
+ Your brower is caput
+ </video>
+ $elif picture[0] != '':
+ <img style="width:80%;" src="$picture[0]?$randhash"/>
+ $elif picture[1] == '':
+ <pre>video not rendered</pre>
+ <a href="">render now!</a>
+ <br>
+$else:
+ <br>
+ <a href="/c/">camera control</a>
+
+$ t=0
+
+$if film != '':
+ $ i = film
+ $ scenes=countscenes(filmfolder, i)
+ $for s in range(scenes):
+ <div class='scene $str(s+1)' style="padding:10px; vertical-align:top;">
+ <pre style="background-color:#680000;">scene $str(s+1)</pre>
+ $ t = counttakes(i, filmfolder, s+1, 1)
+ $ thumbnail_url = '/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot001/take' + str(t).zfill(3) + '.jpeg'
+ <a href="?scene=${str(s+1)}"><img style="vertical-align:middle; width:80%; max-width:100px;" src="$thumbnail_url?$randhash"/></a>
+ $ shots = countshots(i, filmfolder, s+1)
+ $for s2 in range(shots):
+ <div class='shot $str(s2+1)' style="padding:10px;">
+ <pre style="background-color:#fffe00; color:#000;">shot $str(s2+1)</pre>
+ $ t2 = countshots(i, filmfolder, s+1)
+ $ p2 = counttakes(i, filmfolder, s+1, s2+1)
+ $ thumbnail_url = '/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '.jpeg'
+ $ check=if_exist(thumbnail_url)
+ $if check == True:
+ <a href="?scene=${str(s+1)}&shot=${str(s2+1)}"><img style="vertical-align:middle; width:80%; max-width:80px;" src="$thumbnail_url?$randhash"/></a>
+ $else:
+ $ thumbnail_url = '/static/empty.jpeg'
+ <a href="?scene=${str(s+1)}&shot=${str(s2+1)}"><img style="vertical-align:middle; width:80%; max-width:80px;" src="$thumbnail_url?$randhash"/></a>
+ $if p2 != None:
+ $for t3 in range(p2):
+ $ thumbnail_url = '/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(t3+1).zfill(3) + '.jpeg'
+ <div class='take $str(t3+1)' style="padding:10px;">
+ <pre style="background-color:#0e2b00;">take $str(t3+1)</pre>
+ <a href="?scene=${str(s+1)}&shot=${str(s2+1)}&take=${str(t)}"><img style="vertical-align:middle; width:80%; max-width:50px;" src="$thumbnail_url?$randhash"/></a>
+ </br>
+ </div>
+ </br>
+ </div>
+ </br>
+ </div>
+$else:
+ <h1>FILMS</h1>
+ $for i in films:
+ <a href="$i"><pre>$i</pre></a>
+ $ thumbnail_url = '/'+filmfolder + i + '/scene' + str(1).zfill(3) + '/shot' + str(1).zfill(3) + '/take' + str(1).zfill(3) + '.jpeg'
+ <a href="$i"><img style="vertical-align:middle; width:80%; max-width:50px;" src="$thumbnail_url?$randhash"/></a><br><br>
+
+$if shot != None:
+ $for t in range(takes):
+ $ thumbnail_url = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(shot).zfill(3) + '/take' + str(t+1).zfill(3) + '.jpeg'
+ <pre>take $str(t+1)</pre>
+ <a href="?scene=$scene&shot=$shot&take=${str(t+1)}"><img style="vertical-align:middle; width:80%; max-width:50px;" src="$thumbnail_url?$randhash"/></a><br>
+$elif scene != None:
+ $for s in range(shots)
+ <pre>shot $str(s+1)</pre>
+ $ t = countshots(film, filmfolder, scene)
+ $ p = counttakes(film, filmfolder, scene, s+1)
+ $ thumbnail_url = '/'+filmfolder + film + '/scene' + str(scene).zfill(3) + '/shot' + str(s+1).zfill(3) + '/take' + str(p).zfill(3) + '.jpeg'
+ <a href="?scene=$scene&shot=${str(s+1)}"><img style="vertical-align:middle; width:80%; max-width:50px;" src="$thumbnail_url?$randhash"/></a><br>
+