diff --git a/actions.py b/actions.py index 6d0da6f..5ddf080 100644 --- a/actions.py +++ b/actions.py @@ -278,6 +278,15 @@ class Actions(object): elif self.data.player_mode == 'next': self.data.player_mode = 'now' + def toggle_detour_mode(self): + if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled': + if self.data.detour_active: + self.data.detour_active = False + self.video_driver.osc_client.send_message("/detour/end", True) + else: + self.data.detour_active = True + self.video_driver.osc_client.send_message("/detour/start", True) + def set_the_camera_colour_u_continuous(self, amount): self.capture.set_colour(amount*255, None) diff --git a/data_centre/data.py b/data_centre/data.py index 685ac07..e5c0cc8 100644 --- a/data_centre/data.py +++ b/data_centre/data.py @@ -41,6 +41,7 @@ class Data(object): self.midi_port_index = 0 self.update_screen = True self.player_mode = 'now' + self.detour_active = False ### persisted data (use default if doesnt exits): self.bank_data = [self.create_empty_bank()] diff --git a/json_objects/current_bankslot_number.json b/json_objects/current_bankslot_number.json index 11f670d..7c1b0ff 100644 --- a/json_objects/current_bankslot_number.json +++ b/json_objects/current_bankslot_number.json @@ -1 +1 @@ -"1-0" \ No newline at end of file +"1-1" \ No newline at end of file diff --git a/json_objects/keypad_action_mapping.json b/json_objects/keypad_action_mapping.json index 10d7cca..0402e5e 100644 --- a/json_objects/keypad_action_mapping.json +++ b/json_objects/keypad_action_mapping.json @@ -64,10 +64,10 @@ "DEFAULT": ["load_slot_6_into_next_player","toggle_shaders"] }, "q": { - "DEFAULT": ["load_slot_7_into_next_player", "increase_speed"] + "DEFAULT": ["load_slot_7_into_next_player", "toggle_detour_mode"] }, "r": { - "DEFAULT": ["load_slot_8_into_next_player", "decrease_speed"] + "DEFAULT": ["load_slot_8_into_next_player"] }, "s": { "DEFAULT": ["load_slot_9_into_next_player","quit_the_program"] diff --git a/video_centre/of_capture.py b/video_centre/of_capture.py index a95ed30..fdd8cbd 100644 --- a/video_centre/of_capture.py +++ b/video_centre/of_capture.py @@ -3,6 +3,7 @@ import subprocess import datetime import fractions import picamera +import time class OfCapture(object): def __init__(self, root, osc_client, message_handler, data): @@ -27,7 +28,7 @@ class OfCapture(object): if not self.check_if_attached_with_picamera(): return - print('sending setup message !') + print('sending setup message !', self.capture_type) self.osc_client.send_message("/capture/setup", self.capture_type) self.has_capture = True return True @@ -124,39 +125,55 @@ class OfCapture(object): def stop_recording(self): #self.device.stop_recording() self.osc_client.send_message("/capture/record/stop", True) + self.is_recording = 'saving' + self.wait_for_raw_file() #set status to saving - mp4box_process, recording_name = self.convert_raw_recording() - self.is_recording = 'saving' - self.root.after(0, self.wait_for_recording_to_save, mp4box_process, recording_name) - self.update_capture_settings() - # return path to the video + + def wait_for_raw_file(self): + if os.path.exists(self.video_dir + 'raw.h264'): + mp4box_process, recording_name = self.convert_raw_recording() + + self.root.after(0, self.wait_for_recording_to_save, mp4box_process, recording_name) + self.update_capture_settings() + elif os.path.exists(self.video_dir + 'raw.mp4'): + recording_path , recording_name = self.generate_recording_path() + os.rename(self.video_dir + 'raw.mp4', recording_path ) + self.is_recording = False + print('usb name is ', recording_name) + self.root.after(10000, self.data.create_new_slot_mapping_in_first_open, recording_name) + + self.update_capture_settings() + else: + self.root.after(1000, self.wait_for_raw_file) def convert_raw_recording(self): - recording_path , recording_name = self.generate_recording_path() - try: - mp4box_process = subprocess.Popen(['MP4Box', '-add', self.video_dir + '/raw.h264', recording_path]) - return mp4box_process , recording_name - except Exception as e: - print(e) - if hasattr(e, 'message'): - error_info = e.message - else: - error_info = e + ### wait for omx to finish creating video ... + if os.path.exists(self.video_dir + 'raw.h264'): + recording_path , recording_name = self.generate_recording_path() + try: + mp4box_process = subprocess.Popen(['MP4Box', '-add', self.video_dir + 'raw.h264', recording_path]) + return mp4box_process , recording_name + except Exception as e: + print(e) + if hasattr(e, 'message'): + error_info = e.message + else: + error_info = e self.message_handler.set_message('ERROR',error_info) - + def wait_for_recording_to_save(self, process, name): print('the poll is {}'.format(process.poll())) if process.poll() is not None: self.is_recording = False - os.remove(self.video_dir + '/raw.h264') + os.remove(self.video_dir + 'raw.h264') self.data.create_new_slot_mapping_in_first_open(name) else: self.root.after(300, self.wait_for_recording_to_save, process, name) def generate_recording_path(self): - rec_dir = self.video_dir + '/recordings' + rec_dir = self.video_dir + 'recordings' if not os.path.exists(rec_dir): os.makedirs(rec_dir) date = datetime.datetime.now().strftime("%Y-%m-%d")