commit 590470210b49afb38792df5bfb26345bbc362e16
parent 989ab615130756f2ad8e2f075e92afc818d97a71
Author: rbckman <rob@tarina.org>
Date: Thu, 2 Oct 2025 11:23:07 +0100
getting there
Diffstat:
5 files changed, 160 insertions(+), 69 deletions(-)
diff --git a/gonzopi.py b/gonzopi.py
@@ -617,6 +617,11 @@ def main():
shots_selected.append(folder)
shots_sel = '*'
vumetermessage(str(len(shots_selected))+' shots selected')
+ os.system('rm /dev/shm/videos_selected')
+ f = open('/dev/shm/videos_selected', 'w')
+ for i in shots_selected:
+ f.write(i+'\n')
+ f.close()
elif pressed == 'middle' and menu[selected] == 'SCENE:':
folder = filmfolder + filmname + '/scene' + str(scene).zfill(3) +'/'
if folder in scenes_selected:
@@ -847,7 +852,7 @@ def main():
#PASTE MANY SCENES
elif pressed == 'copy' and menu[selected] == 'SCENE:' and scenes_selected != [] or pressed == 'move' and menu[selected] == 'SCENE:' and scenes_selected != []:
landingscene=scene-1
- for yanked in scenes_selected:
+ for yanked in reversed(scenes_selected):
vumetermessage('Pasting scene, please wait...')
paste = filmfolder + filmname + '/' + 'scene' + str(scene-1).zfill(3) + '_yanked'
os.system('cp -r ' + yanked + ' ' + paste)
@@ -870,7 +875,7 @@ def main():
#PASTE MANY SHOTS
elif pressed == 'copy' and menu[selected] == 'SHOT:' and shots_selected != [] or pressed == 'move' and menu[selected] == 'SHOT:' and shots_selected != []:
landingshot=shot-1
- for yanked in shots_selected:
+ for yanked in reversed(shots_selected):
take = counttakes(filmname, filmfolder, scene, shot)
if shot == 0:
shot=1
@@ -885,6 +890,7 @@ def main():
os.system('touch ' + yanked + '/.remove')
add_organize(filmfolder, filmname)
yanked = ''
+ os.system('rm /dev/shm/videos_selected')
shots_selected = []
organize(filmfolder, filmname)
organize(filmfolder, filmname)
@@ -1313,6 +1319,13 @@ def main():
shot=pressed.split(':')[1]
shot=int(shot)
take = counttakes(filmname, filmfolder, scene, shot)
+ elif 'SHOTSCENES:' in pressed:
+ sceneshot=pressed.split(':')[1]
+ scene=sceneshot.split('|')[0]
+ scene=int(scene)
+ shot=sceneshot.split('|')[1]
+ shot=int(shot)
+ take = counttakes(filmname, filmfolder, scene, shot)
elif 'REMOVE:' in pressed:
scene=pressed.split(':')[1]
scene=int(scene)
@@ -1675,10 +1688,10 @@ def main():
recprocess, camera = stoprecording(camera, rec_process)
os.system('pkill arecord')
try:
- db.update('videos', where='filename="'+filmfolder+'.videos/'+video_origins+'.mp4"', soundlag=soundlag, faststart=False)
+ db.update('videos', where='filename="'+filmfolder+'.videos/'+video_origins+'.mp4"', soundlag=soundlag, videolength=float(time.time() - starttime), faststart=False)
except:
db = correct_database(filmname,filmfolder,db)
- db.update('videos', where='filename="'+filmfolder+'.videos/'+video_origins+'.mp4"', soundlag=soundlag, faststart=False)
+ db.update('videos', where='filename="'+filmfolder+'.videos/'+video_origins+'.mp4"', soundlag=soundlag, videolength=float(time.time() - starttime), faststart=False)
#time.sleep(0.005) #get audio at least 0.1 longer
#camera.capture(foldername + filename + '.jpeg', resize=(800,341))
#if slidecommander:
@@ -4512,18 +4525,6 @@ def organize(filmfolder, filmname):
#time.sleep(2)
for s in sorted(takes):
if 'take' in s:
- if '.wav' in s:
- origin=os.path.realpath(takename+'.wav')
- if origin != os.path.abspath(takename+'.wav'):
- print('appending: '+origin)
- origin_files.append(origin)
- origin_scene_files.append(origin)
- else:
- print('no sublink for sound, create it here')
- #time.sleep(1)
- origin=os.path.realpath(takename+'.mp4')
- os.system('mv '+takename+'.wav '+origin[:-4]+'.wav')
- os.system('ln -sfr '+origin[:-4]+'.wav '+takename+'.wav')
if '.mp4' in s or '.h264' in s:
unorganized_nr = int(s[4:7])
takename = filmfolder + filmname + '/' + i + '/' + p + '/take' + str(unorganized_nr).zfill(3)
@@ -4536,8 +4537,24 @@ def organize(filmfolder, filmname):
if os.path.isfile(takename+'.h264'):
print('oh no boubles found!')
else:
+ videos_totalt = db.query("SELECT COUNT(*) AS videos FROM videos")[0]
+ tot = int(videos_totalt.videos)
+ video_origins=filmfolder+'.videos/'+datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5)
print('no sublink for video, create it here')
- time.sleep(1)
+ os.system('mv '+takename+'.mp4 '+video_origins+'.mp4')
+ os.system('ln -sfr '+video_origins+'.mp4 '+takename+'.mp4')
+ #time.sleep(1)
+ origin_audio=os.path.realpath(takename+'.wav')
+ if origin_audio != os.path.abspath(takename+'.wav'):
+ print('appending: '+origin_audio)
+ origin_files.append(origin_audio)
+ origin_scene_files.append(origin_audio)
+ else:
+ print('no sublink for sound, create it here')
+ #time.sleep(1)
+ origin=os.path.realpath(takename+'.mp4')
+ os.system('mv '+takename+'.wav '+origin[:-4]+'.wav')
+ os.system('ln -sfr '+origin[:-4]+'.wav '+takename+'.wav')
if '.h264' in s:
origin=os.path.realpath(takename+'.h264')
if origin != os.path.abspath(takename+'.h264'):
@@ -4803,8 +4820,13 @@ def is_audio_stereo(file_path):
return None
def get_video_length(filepath):
+ global db
+ video_origins = (os.path.realpath(filepath))
# Parse the file
- media_info = MediaInfo.parse(filepath)
+ try:
+ media_info = MediaInfo.parse(filepath)
+ except:
+ return
# Find the video track (usually the first video track)
for track in media_info.tracks:
if track.track_type == "Video":
@@ -4812,7 +4834,9 @@ def get_video_length(filepath):
duration_ms = track.duration
if duration_ms is None:
return None # No duration found
+ db.update('videos', where='filename="'+video_origins+'"', videolength=duration_ms/1000, audiolength=duration_ms/1000)
return int(duration_ms)
+ #return int(duration_ms)
return None # No video track found
def get_audio_length(filepath):
@@ -4857,13 +4881,18 @@ def compileshot(filename,filmfolder,filmname):
#os.system('ln -sfr '+video_origins+'.mp4 '+filename+'.mp4')
print(filename+'.h264 converted to mp4')
video_origins = (os.path.realpath(filename+'.mp4'))[:-4]
+ vumetermessage('checking video audio length...')
+ videolength = get_video_length(filename+'.mp4')
+ print('videolength:'+str(videolength))
if not os.path.isfile(filename + '.wav'):
vumetermessage('creating audio track...')
audiosilence(filename)
+ try:
+ db.update('videos', where='filename="'+video_origins+'.mp4"', videolength=videolength/1000, audiolength=videolength/1000)
+ except:
+ db = correct_database(filmname,filmfolder,db)
+ db.update('videos', where='filename="'+video_origins+'.mp4"', videolength=videolength/1000, audiolength=videolength/1000)
#add audio/video start delay sync
- vumetermessage('checking video audio length...')
- videolength = get_video_length(filename+'.mp4')
- print('videolength:'+str(videolength))
try:
audiolength = get_audio_length(filename+'.wav')
except:
@@ -4886,10 +4915,10 @@ def compileshot(filename,filmfolder,filmname):
vumetermessage('trimming audio to video...')
audiosync, videolength, audiolength = audiotrim(filename, 'end','')
try:
- db.update('videos', where='filename="'+video_origins+'"', videolength=videolength/1000, audiolength=audiolength/1000, audiosync=audiosync)
+ db.update('videos', where='filename="'+video_origins+'.mp4"', videolength=videolength/1000, audiolength=audiolength/1000, audiosync=audiosync)
except:
db = correct_database(filmname,filmfolder,db)
- db.update('videos', where='filename="'+video_origins+'"', videolength=videolength/1000, audiolength=audiolength/1000, audiosync=audiosync)
+ db.update('videos', where='filename="'+video_origins+'.mp4"', videolength=videolength/1000, audiolength=audiolength/1000, audiosync=audiosync)
mux=False
#one more if stereo check!
stereo = is_audio_stereo(filename+'.wav')
@@ -5018,7 +5047,12 @@ def renderaudio(filmfolder, filmname, scene, audiofiles, filename, dubfiles, dub
# writemessage('Nothing here!')
# time.sleep(2)
# return None
- rendered_audio = filmfolder+'.rendered/'+filmname+'_scene' + str(scene).zfill(3)
+ #
+ #check if shot or take and put them in .rendered folder
+ if audiofiles == filename:
+ rendered_audio=filename
+ else:
+ rendered_audio = filmfolder+'.rendered/'+filmname+'_scene' + str(scene).zfill(3)
print('Rendering audiofiles')
##PASTE AUDIO TOGETHER
writemessage('Hold on, rendering audio...')
@@ -5067,6 +5101,7 @@ def renderaudio(filmfolder, filmname, scene, audiofiles, filename, dubfiles, dub
#Fade and make stereo
run_command('sox -V0 -b 16 -G ' + d + ' -c 2 '+filmfolder+'.tmp/fade.wav fade ' + str(round(i[2],1)) + ' 0 ' + str(round(i[3],1)))
run_command('sox -V0 -b 16 -G -m -v ' + str(round(i[0],1)) + ' '+filmfolder+'.tmp/fade.wav -v ' + str(round(i[1],1)) + ' ' + filename + '_tmp.wav -c 2 ' + rendered_audio + '.wav trim 0 ' + str(audiolength))
+ os.system('ln -sfr '+rendered_audio+'.wav '+filename+'.wav')
try:
os.remove(filename + '_tmp.wav')
os.remove(''+filmfolder+'.tmp/fade.wav')
@@ -6517,7 +6552,8 @@ def videotrim(filmfolder, foldername ,filename, where, s, t, make_new_take_or_sh
video_origins=filmfolder+'.videos/'+datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5)
run_command('ffmpeg -i '+filename+'.mp4 -ss '+str(s)+' -t '+str(video_edit_len)+' -c:v copy -c:a copy -y '+video_origins+'.mp4')
os.system('ln -sfr '+video_origins+'.mp4 '+trim_filename+'.mp4')
- run_command('ffmpeg -i '+filename+'.wav -ss '+str(s)+' -t '+str(video_edit_len)+' -c:a copy -y '+trim_filename+'.wav')
+ run_command('ffmpeg -i '+filename+'.wav -ss '+str(s)+' -t '+str(video_edit_len)+' -c:a copy -y '+video_origins+'.wav')
+ os.system('ln -sfr '+video_origins+'.wav '+trim_filename+'.wav')
#run_command('ecasound -i:'+filename+'.wav -o:'+trim_filename+'.wav -ss:'+str(s)+' -t:'+str(video_edit_len))
#if os.path.exists(foldername+'dub') == True:
# dubfiles, dubmix, rerender = getdubs(foldername+'dub/', None, None, None)
@@ -6532,35 +6568,46 @@ def videotrim(filmfolder, foldername ,filename, where, s, t, make_new_take_or_sh
#run_command('ffmpeg -ss ' + str(s) + ' -i ' + filename + '.mp4 -c copy ' + trim_filename + '.mp4')
#ffmpeg -fflags +genpts -r 25 -i take009.mp4 -c:v h264_omx -crf 20 -profile:v high -level:v 4.2 -preset slower -bsf:v h264_metadata=level=4.2 -g 1 -b:v 8888888 take010.mp4
#run_command('MP4Box ' + filename + '.mp4 -splitx ' + str(s) + ':end -out ' + trim_filename + '.mp4')
- run_command('ffmpeg -i '+filename+'.mp4 -ss '+str(s)+' -c:v copy -c:a copy -y '+trim_filename+'.mp4')
- run_command('cp ' + filename + '.wav ' + trim_filename + '.wav')
- audiotrim(trim_filename, 'beginning','')
- if os.path.exists(foldername+'dub') == True:
- dubfiles, dubmix, rerender = getdubs(foldername+'dub/', None, None, None)
- for d in dubfiles:
- writemessage('trimming dubs from beginning')
- vumetermessage(d)
- audiotrim(trim_filename, 'beginning', d)
- writemessage('trimming original sound')
- audiotrim(trim_filename, 'beginning', foldername+'dub/original.wav')
+ videos_totalt = db.query("SELECT COUNT(*) AS videos FROM videos")[0]
+ tot = int(videos_totalt.videos)
+ video_origins=filmfolder+'.videos/'+datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5)
+ run_command('ffmpeg -i '+filename+'.mp4 -ss '+str(s)+' -c:v copy -c:a copy -y '+video_origins+'.mp4')
+ run_command('cp ' + filename + '.wav ' + video_origins + '.wav')
+ audiotrim(video_origins, 'beginning','')
+ os.system('ln -sfr '+video_origins+'.mp4 '+trim_filename+'.mp4')
+ os.system('ln -sfr '+video_origins+'.wav '+trim_filename+'.wav')
+ #if os.path.exists(foldername+'dub') == True:
+ # dubfiles, dubmix, rerender = getdubs(foldername+'dub/', None, None, None)
+ # for d in dubfiles:
+ # writemessage('trimming dubs from beginning')
+ # vumetermessage(d)
+ # audiotrim(trim_filename, 'beginning', d)
+ # writemessage('trimming original sound')
+ # audiotrim(trim_filename, 'beginning', foldername+'dub/original.wav')
elif where == 'end':
logger.info('trimming clip from end')
#run_command('ffmpeg -to ' + str(s) + ' -i ' + filename + '.mp4 -c copy ' + trim_filename + '.mp4')
#run_command('MP4Box ' + filename + '.mp4 -splitx 0:' + str(s) + ' -out ' + trim_filename + '.mp4')
- run_command('ffmpeg -i '+filename+'.mp4 -t '+str(s)+' -c:v copy -c:a copy -y '+trim_filename+'.mp4')
- run_command('cp ' + filename + '.wav ' + trim_filename + '.wav')
- audiotrim(trim_filename, 'end','')
- if os.path.exists(foldername+'dub') == True:
- dubfiles, dubmix, rerender = getdubs(foldername+'dub/', None, None, None)
- for d in dubfiles:
- writemessage('trimming dubs from end')
- vumetermessage(d)
- audiotrim(trim_filename, 'end', d)
- writemessage('trimming original sound')
- audiotrim(trim_filename, 'end', foldername+'dub/original.wav')
+ videos_totalt = db.query("SELECT COUNT(*) AS videos FROM videos")[0]
+ tot = int(videos_totalt.videos)
+ video_origins=filmfolder+'.videos/'+datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5)
+ run_command('ffmpeg -i '+filename+'.mp4 -t '+str(s)+' -c:v copy -c:a copy -y '+video_origins+'.mp4')
+ run_command('cp ' + filename + '.wav ' + video_origins + '.wav')
+ audiotrim(video_origins, 'end','')
+ os.system('ln -sfr '+video_origins+'.mp4 '+trim_filename+'.mp4')
+ os.system('ln -sfr '+video_origins+'.wav '+trim_filename+'.wav')
+ #if os.path.exists(foldername+'dub') == True:
+ # dubfiles, dubmix, rerender = getdubs(foldername+'dub/', None, None, None)
+ # for d in dubfiles:
+ # writemessage('trimming dubs from end')
+ # vumetermessage(d)
+ # audiotrim(trim_filename, 'end', d)
+ # writemessage('trimming original sound')
+ # audiotrim(trim_filename, 'end', foldername+'dub/original.wav')
#take last frame
if film_reso == '1920x1080':
run_command('ffmpeg -y -sseof -1 -i ' + trim_filename + '.mp4 -update 1 -q:v 1 -vf scale=800:450 ' + trim_filename + '.jpeg')
+ run_command('ffmpeg -y -sseof -1 -i ' + trim_filename + '.mp4 -update 1 -q:v 1 -vf scale=80:45 ' + trim_filename + '_thumb.jpeg')
elif film_reso == '1920x816':
run_command('ffmpeg -y -sseof -1 -i ' + trim_filename + '.mp4 -update 1 -q:v 1 -vf scale=800:340 ' + trim_filename + '.jpeg')
return
@@ -6715,6 +6762,7 @@ def audiosilence(renderfilename):
#videolength = pipe.decode()
logger.info('checking video length')
videolength = get_video_length(renderfilename+'.mp4')
+ audio_origins = (os.path.realpath(renderfilename+'.mp4'))[:-4]
logger.info('Video length is ' + str(videolength))
#separate seconds and milliseconds
videoms = int(videolength) % 1000
@@ -6723,9 +6771,9 @@ def audiosilence(renderfilename):
run_command('sox -V0 -n -b 16 -r '+soundrate+' -c 2 '+filmfolder+'.tmp/silence.wav trim 0.0 ' + str(videos))
videos_totalt = db.query("SELECT COUNT(*) AS videos FROM videos")[0]
tot = int(videos_totalt.videos)
- audio_origins=datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5)
- os.system('cp '+filmfolder+'.tmp/silence.wav ' +filmfolder+'.videos/'+audio_origins+'.wav')
- os.system('ln -sfr '+filmfolder+'.videos/'+audio_origins+'.wav '+renderfilename+'.wav')
+ #audio_origins=datetime.datetime.now().strftime('%Y%d%m')+'_'+os.urandom(8).hex()+'_'+str(tot).zfill(5)
+ os.system('cp '+filmfolder+'.tmp/silence.wav '+audio_origins+'.wav')
+ os.system('ln -sfr '+audio_origins+'.wav '+renderfilename+'.wav')
os.system('rm '+filmfolder+'.tmp/silence.wav')
#--------------USB filmfolder-------------------
@@ -7174,6 +7222,8 @@ def getbutton(lastbutton, buttonpressed, buttontime, holdbutton):
pressed=nextstatus
elif "SHOT:" in nextstatus:
pressed=nextstatus
+ elif "SHOTSCENES:" in nextstatus:
+ pressed=nextstatus
elif "REMOVE:" in nextstatus:
pressed=nextstatus
elif "Q:" in nextstatus:
diff --git a/srv/gonzopiserver.py b/srv/gonzopiserver.py
@@ -75,10 +75,14 @@ if filmfolderusb:
# 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)
basedir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(basedir)
@@ -244,8 +248,18 @@ def checkvideo(video,filmfolder,film,scene,shot,take):
return '', v
def get_video_length(filepath):
+ video_origins = (os.path.realpath(filepath))
+ try:
+ video_db=db.select('videos', where='filename="'+video_origins+'"')[0]
+ return str(datetime.timedelta(seconds=round(video_db.videolength)))
+ except:
+ pass
+ return
# Parse the file
- media_info = MediaInfo.parse(filepath)
+ try:
+ media_info = MediaInfo.parse(filepath)
+ except:
+ return
# Find the video track (usually the first video track)
for track in media_info.tracks:
if track.track_type == "Video":
@@ -253,7 +267,8 @@ def get_video_length(filepath):
duration_ms = track.duration
if duration_ms is None:
return None # No duration found
- return str(datetime.timedelta(seconds=round(duration_ms)))
+ db.update('videos', where='filename="'+video_origins+'"', videolength=duration_ms/1000, audiolength=duration_ms/1000)
+ return str(datetime.timedelta(seconds=round(duration_ms/1000)))
#return int(duration_ms)
return None # No video track found
@@ -455,6 +470,8 @@ class edit:
renderedfilms = []
unrenderedfilms = []
allfilms = []
+ filmdb = filmfolder+'.videos/gonzopi.db'
+ db = web.database(dbn='sqlite', db=filmdb)
for f in gonzopifilms:
if os.path.isfile(filmfolder + f[0] + '/' + f[0] + '.mp4') == True:
renderedfilms.append(f[0])
@@ -471,7 +488,7 @@ class edit:
if i.randhash == None:
randhash = hashlib.md5(str(random.getrandbits(256)).encode('utf-8')).hexdigest()
scenes = countscenes(filmfolder, film)
- return render2.edit(allfilms, film, scenes, str, filmfolder, counttakes, countshots, countscenes, shots, i.scene, takes, i.shot, i.take, checkvideo, randhash, if_exist, createthumb,basedir,time,get_video_length)
+ return render2.edit(allfilms, film, scenes, str, filmfolder, counttakes, countshots, countscenes, shots, i.scene, takes, i.shot, i.take, checkvideo, randhash, if_exist, createthumb,basedir,time,get_video_length, db, real_filmfolder)
class logorder:
def POST(self, film):
@@ -558,7 +575,7 @@ class api:
scene=1
if p == 6 and film != None:
try:
- shot=int(i.split(':')[1].split('/')[0])
+ shot=int(i.split(':')[1].split('/')[0].rstrip('*'))
except:
shot=1
if p == 7 and film != None:
@@ -595,7 +612,12 @@ class api:
else:
writemenu=menudone+'<br><br>'+vumetermessage+'<br>'
isActive=True
- return json.dumps({"film": film, "scene":scene,"shot":shot,"isActive":isActive})
+ try:
+ with open('/dev/shm/videos_selected','r') as f:
+ selected_videos=[line.rstrip('\n') for line in f.readlines()]
+ except:
+ selected_videos=[]
+ return json.dumps({"film": film, "scene":scene,"shot":shot,"isActive":isActive, "selected":selected_videos})
def POST(self):
global menuold, vumeterold
@@ -645,9 +667,7 @@ class api:
elif i.func == 'paste':
sendtocamera(ip,port,'paste')
elif i.scene!=None and i.shot!=None and i.film != None:
- sendtocamera(ip,port,'SCENE:'+str(i.scene))
- time.sleep(0.2)
- sendtocamera(ip,port,'SHOT:'+str(i.shot))
+ sendtocamera(ip,port,'SHOTSCENES:'+str(i.scene)+'|'+str(i.shot))
time.sleep(0.2)
sendtocamera(ip,port,'SELECTED:3')
interface=open('/dev/shm/interface','r')
diff --git a/srv/static/style2.css b/srv/static/style2.css
@@ -5,6 +5,7 @@ body
background-color:#000;
color: #f4f4f4;
font-family: monospace;
+ font-size: 10px;
width: 100%;
white-space: nowrap
}
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=4955" type="text/css" rel="stylesheet"/>
+ <link rel="stylesheet" href="/static/style2.css?v=5955" 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
@@ -1,4 +1,4 @@
-$def with (films, film, scenes, str, filmfolder, counttakes, countshots, countscenes, shots, scene, takes, shot, take, checkvideo,randhash, if_exist, createthumb,basedir,time,get_video_length)
+$def with (films, film, scenes, str, filmfolder, counttakes, countshots, countscenes, shots, scene, takes, shot, take, checkvideo,randhash, if_exist, createthumb,basedir,time,get_video_length, db, real_filmfolder)
$ video = ''
<script>
@@ -73,7 +73,7 @@ button {
.responsive-div {
display: none; /* Hide by default */
}
-@media (max-width: 500px) {
+@media (max-width: 700px) {
.responsive-div {
display: block; /* Show when screen width is 500px or less */
}
@@ -97,8 +97,9 @@ button {
</div>
</div>
+</div>
<br>
-
+<div id="content">
$ t=0
<br>
$if film != '' and scene != '' and shot != '':
@@ -110,16 +111,19 @@ $if film != '' and scene != '' and shot != '':
$ t = counttakes(i, filmfolder, s+1, 1)
$ shots = countshots(i, filmfolder, s+1)
$for s2 in range(shots):
- <div class='shotdata' data-film="$film" data-scene="${str(s+1)}" data-shot="${str(s2+1)}" style="padding:0px;">
- shot $str(s2+1)
- <button class="sendDataButton">
$ t2 = countshots(i, filmfolder, s+1)
$ p2 = counttakes(i, filmfolder, s+1, s2+1)
$ mp4_file = basedir+'/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '.mp4'
+ $ shot_file = real_filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/'
+ $ shot_mp4_file = real_filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '.mp4'
$ picture = basedir+'/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '.jpeg'
$ picture_url = '/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '.jpeg'
$ thumbnail = basedir+'/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '_thumb.jpeg'
$ thumbnail_url = '/'+filmfolder + i + '/scene' + str(s+1).zfill(3) + '/shot' + str(s2+1).zfill(3) + '/take' + str(p2).zfill(3) + '_thumb.jpeg'
+ <div class='shotdata' data-file="$shot_file" data-film="$film" data-scene="${str(s+1)}" data-shot="${str(s2+1)}" style="padding:0px;">
+ |$str(s2+1)|
+ $get_video_length(shot_mp4_file)
+ <button class="sendDataButton">
$ check=if_exist(thumbnail_url)
$if check == True:
<img style="vertical-align:middle; width:100%; max-width:80px; height:auto;" src="$thumbnail_url?$randhash" alt="scene=${str(s+1)}&shot=${str(s2+1)}"/>
@@ -132,7 +136,6 @@ $if film != '' and scene != '' and shot != '':
$else:
$ thumbnail_url = '/static/empty.jpeg'
<img style="vertical-align:middle; width:100%; max-width:80px; height:auto;" src="$thumbnail_url?$randhash" alt="scene=${str(s+1)}&shot=${str(s2+1)}"/>
- $#get_video_length(mp4_file)
</button>
</div>
</br>
@@ -157,11 +160,20 @@ $elif scene != None:
$ 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" alt="scene=$scene&shot=$shot&take=${str(t+1)}"/></a><br>
-
-
</div>
<script>
$$(document).ready(function() {
+function refreshPage() {
+ $$.ajax({
+ url: '/e/$film', // Replace with your server endpoint
+ method: 'GET',
+ success: function(html) {
+ },
+ error: function(error) {
+ console.error('Error refreshing page:', error);
+ }
+ });
+}
$$('.sendDataButton').click(function() {
// Retrieve data from the div
var shotname = $$('.sendDataButton').text(); //
@@ -308,6 +320,9 @@ $$('#MOVE').on('click', function () {
type: "Content-type",
url:"/api?func=move",
success: function(result) {
+ setTimeout(function() {
+ location.reload(); // Refresh the entire page
+},1500);
},
error: function(result) {
console.log('error', result);
@@ -353,9 +368,11 @@ $$('#PASTE').on('click', function () {
// Assuming JSON response like: { "scene": "1", "shot": "2" }
const currentScene = response.scene;
const currentShot = response.shot;
+ const fileList = response.selected;
// Reset all divs to transparent border
$$shotDivs.css('border', '1px solid transparent');
+ $$shotDivs.css('background', 'transparent');
// Find and update matching div
$$shotDivs.each(function() {
@@ -363,6 +380,9 @@ $$('#PASTE').on('click', function () {
if ($$div.data('scene') == currentScene && $$div.data('shot') == currentShot) {
$$div.css('border', '1px solid white'); // Draw border on matching div
}
+ if (fileList.includes($$div.data('file'))) {
+ $$div.css('background', 'grey');
+ }
});
},
error: function(xhr, status, error) {
@@ -377,7 +397,7 @@ $$('#PASTE').on('click', function () {
updateShotData();
// Set interval to call every second (1000ms)
- setInterval(updateShotData, 1000);
+ setInterval(updateShotData, 300);
});