Video export ask for filename, check cam type != 0

This commit is contained in:
ABelliqueux 2024-02-27 11:05:22 +01:00
parent b6cf074362
commit 1856d42ab4
1 changed files with 12 additions and 10 deletions

View File

@ -117,7 +117,7 @@ class KISStopmo(tk.Tk):
def __init__(self, *args, **kargs): def __init__(self, *args, **kargs):
self.check_config() self.check_config()
if project_settings['camera_type']: if project_settings['camera_type'] != 0:
from picamera2 import Picamera2 from picamera2 import Picamera2
# Default config # Default config
# Set script settings according to config file # Set script settings according to config file
@ -216,11 +216,11 @@ class KISStopmo(tk.Tk):
root.bind("<f>", lambda event: root.attributes("-fullscreen", True)) root.bind("<f>", lambda event: root.attributes("-fullscreen", True))
root.bind("<n>", self.next_frame) root.bind("<n>", self.next_frame)
root.bind("<b>", self.previous_frame) root.bind("<b>", self.previous_frame)
root.bind("<o>", self.toggle_onionskin) root.bind("<B>", self.toggle_onionskin)
root.bind("<p>", self.preview_animation) root.bind("<N>", self.preview_animation)
root.bind("<e>", self.trigger_export_animation) root.bind("<e>", self.trigger_export_animation)
root.bind("<d>", self.remove_frame) root.bind("<d>", self.remove_frame)
root.bind("<a>", self.print_imglist) # ~ root.bind("<a>", self.print_imglist)
if project_settings['trigger_mode'] != 'event': if project_settings['trigger_mode'] != 'event':
root.bind("<j>", self.capture_image) root.bind("<j>", self.capture_image)
@ -665,7 +665,7 @@ class KISStopmo(tk.Tk):
next_filename = self.return_next_frame_number(self.get_last_frame(self.savepath)) next_filename = self.return_next_frame_number(self.get_last_frame(self.savepath))
# build full path to file # build full path to file
target_path = os.path.join(self.savepath, next_filename) target_path = os.path.join(self.savepath, next_filename)
if project_settings['camera_type']: if project_settings['camera_type'] != 0:
self.camera.start(show_preview=False) self.camera.start(show_preview=False)
self.camera.set_controls({"LensPosition": self.camera_lenspos}) self.camera.set_controls({"LensPosition": self.camera_lenspos})
self.camera.capture_file(target_path, 'main', format='jpeg') self.camera.capture_file(target_path, 'main', format='jpeg')
@ -714,7 +714,8 @@ class KISStopmo(tk.Tk):
self.input_filename, self.input_filename,
self.input_options) self.input_options)
.output( .output(
self.output_filename, # ~ self.output_filename,
self.export_filename,
self.output_options self.output_options
) )
) )
@ -722,15 +723,16 @@ class KISStopmo(tk.Tk):
await ffmpeg.execute() await ffmpeg.execute()
def trigger_export_animation(self, event): def trigger_export_animation(self, event):
output_folder = filedialog.askdirectory() # ~ output_folder = filedialog.askdirectory()
self.output_filename = "{folder}{sep}{filename}".format(folder=output_folder, sep=os.sep, filename=self.output_filename) # ~ self.export_filename = "{folder}{sep}{filename}".format(folder=output_folder, sep=os.sep, filename=self.output_filename)
print(_("Exporting to {}").format(self.output_filename)) self.export_filename = filedialog.asksaveasfilename(defaultextension='.mp4', filetypes=((_("Mp4 files"), '*.mp4'),))
print(_("Exporting to {}").format(self.export_filename))
self.export_task = asyncio.run(self.export_animation()) self.export_task = asyncio.run(self.export_animation())
# check with self.export_task.done() == True ? https://stackoverflow.com/questions/69350645/proper-way-to-retrieve-the-result-of-tasks-in-asyncio # check with self.export_task.done() == True ? https://stackoverflow.com/questions/69350645/proper-way-to-retrieve-the-result-of-tasks-in-asyncio
def end_bg_loop(KISStopmo): def end_bg_loop(KISStopmo):
if KISStopmo.camera is not False: if KISStopmo.camera is not False:
if project_settings['camera_type']: if project_settings['camera_type'] != 0:
KISStopmo.camera.stop() KISStopmo.camera.stop()
else: else:
KISStopmo.camera.exit() KISStopmo.camera.exit()