mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
connecting up some of the new settings including switching video modes
This commit is contained in:
27
actions.py
27
actions.py
@@ -177,6 +177,33 @@ class Actions(object):
|
||||
output_range = max_param - min_param
|
||||
return int(( cc_value / 127 ) * output_range + min_param)
|
||||
|
||||
def change_output_mode(self, setting_value):
|
||||
if setting_value == 'hdmi':
|
||||
subprocess.call(['tvservice', '-p'])
|
||||
self._refresh_frame_buffer()
|
||||
elif setting_value == 'composite':
|
||||
self.change_composite_setting(setting_value)
|
||||
|
||||
def change_composite_setting(self, setting_value):
|
||||
if setting_value == 'composite':
|
||||
mode = self.data.settings['video']['COMPOSITE_TYPE']['value']
|
||||
aspect = self.data.settings['video']['COMPOSITE_RATIO']['value']
|
||||
progressive = ''
|
||||
if self.data.settings['video']['COMPOSITE_PROGRESSIVE']['value'] == 'yes':
|
||||
progressive = 'p'
|
||||
subprocess.call(['tvservice --sdtvon="{} {} {}"'.format(mode, aspect, progressive)],shell=True)
|
||||
self._refresh_frame_buffer()
|
||||
|
||||
@staticmethod
|
||||
def _refresh_frame_buffer():
|
||||
subprocess.run(["fbset -depth 16; fbset -depth 32; xrefresh -display :0" ], shell=True)
|
||||
|
||||
def switch_dev_mode(self, state):
|
||||
if state == 'on':
|
||||
self.run_script('switch_display_to_hdmi')
|
||||
elif state == 'off':
|
||||
self.run_script('switch_display_to_lcd')
|
||||
|
||||
def switch_display_to_hdmi(self):
|
||||
settings = self.data.settings
|
||||
current_screen_mode = [x['options'][0] for x in settings if x['name'] == 'SCREEN_SIZE']
|
||||
|
||||
@@ -47,10 +47,13 @@ class Data(object):
|
||||
|
||||
def _update_json(self, file_name, data):
|
||||
with open('{}{}'.format(self.PATH_TO_DATA_OBJECTS, file_name), 'w') as data_file:
|
||||
json.dump(data, data_file)
|
||||
json.dump(data, data_file, indent=4, sort_keys=True)
|
||||
|
||||
def get_dev_mode_status(self):
|
||||
return self.settings['other']['DEV_MODE_RESET']['value']
|
||||
def get_setting_and_folder_from_name(self, setting_name):
|
||||
for folder_key , folder_item in self.settings.items():
|
||||
for setting_key, setting_item in folder_item.items():
|
||||
if setting_key == setting_name:
|
||||
return folder_key, setting_key, setting_item
|
||||
|
||||
def create_new_slot_mapping_in_first_open(self, file_name):
|
||||
######## used for mapping current video to next available slot ########
|
||||
@@ -91,13 +94,6 @@ class Data(object):
|
||||
self.next_bankslot = '{}-{}'.format(self.bank_number,new_value)
|
||||
self._update_json(self.NEXT_BANKSLOT_JSON,self.next_bankslot)
|
||||
|
||||
def return_setting_details(self, name):
|
||||
for setting_folder_key, setting_folder_item in self.settings.items():
|
||||
for setting_key, setting_details in setting_folder_item.items():
|
||||
if setting_key == name:
|
||||
return setting_details
|
||||
|
||||
|
||||
def check_if_setting_selection_is_action_otherwise_cycle_value(self, setting_index):
|
||||
######## update the value of selected setting by cycling through valid options ########
|
||||
if(self.setting['options'][0] == 'run_action'):
|
||||
@@ -106,6 +102,11 @@ class Data(object):
|
||||
self.cycle_setting_value(setting_index)
|
||||
return False, None
|
||||
|
||||
def update_setting_value(self, setting_folder, setting_name, setting_value):
|
||||
self.settings[setting_folder][setting_name]['value'] = setting_value
|
||||
self._update_json(self.SETTINGS_JSON, self.settings)
|
||||
return self.settings[setting_folder][setting_name]
|
||||
|
||||
def cycle_setting_value(self, setting_index):
|
||||
this_setting_option = self.settings[setting_index]['options']
|
||||
this_setting_option= this_setting_option[len(this_setting_option)-1:]+this_setting_option[0:len(this_setting_option)-1]
|
||||
|
||||
@@ -1 +1,84 @@
|
||||
[[{"end": -1, "rate": 1, "length": 1132.04, "name": "mushroom-dreams.mp4", "location": "/media/pi/5EB5-664C/recur test videos/mushroom-dreams.mp4", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}, {"end": -1, "rate": 1, "length": -1, "name": "", "location": "", "start": -1}]]
|
||||
[
|
||||
[
|
||||
{
|
||||
"end": -1,
|
||||
"length": 1132.04,
|
||||
"location": "/media/pi/5EB5-664C/recur test videos/mushroom-dreams.mp4",
|
||||
"name": "mushroom-dreams.mp4",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": 6.96,
|
||||
"location": "/home/pi/Videos/recordings/rec-2018-04-25-1.mp4",
|
||||
"name": "rec-2018-04-25-1.mp4",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
},
|
||||
{
|
||||
"end": -1,
|
||||
"length": -1,
|
||||
"location": "",
|
||||
"name": "",
|
||||
"rate": 1,
|
||||
"start": -1
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -1,36 +1,166 @@
|
||||
{
|
||||
"midi":
|
||||
{
|
||||
"INPUT": {"value": "enabled", "action": "cycle_setting_options", "options": ["enabled", "disabled"] },
|
||||
"STATUS": {"value": "disconnected", "action": null, "options": [] },
|
||||
"CHANNEL": {"value": 1, "action": null, "options": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] }
|
||||
"capture": {
|
||||
"DEVICE": {
|
||||
"action": "enable_capture_device",
|
||||
"options": [],
|
||||
"value": "enabled"
|
||||
},
|
||||
"EFFECT": {
|
||||
"action": null,
|
||||
"options": [],
|
||||
"value": ""
|
||||
},
|
||||
"EXPOSURE": {
|
||||
"action": null,
|
||||
"options": [],
|
||||
"value": ""
|
||||
},
|
||||
"FRAMERATE": {
|
||||
"action": null,
|
||||
"options": [],
|
||||
"value": ""
|
||||
},
|
||||
"RESOLUTION": {
|
||||
"action": null,
|
||||
"options": [],
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"capture":
|
||||
{
|
||||
"DEVICE": {"value": "enabled", "action": "enable_capture_device", "options": [] },
|
||||
"RESOLUTION": {"value": "", "action": null, "options": [] },
|
||||
"FRAMERATE": {"value": "", "action": null, "options": [] },
|
||||
"EXPOSURE": {"value": "", "action": null, "options": [] },
|
||||
"EFFECT": {"value": "", "action": null, "options": [] }
|
||||
"midi": {
|
||||
"CHANNEL": {
|
||||
"action": null,
|
||||
"options": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16
|
||||
],
|
||||
"value": 1
|
||||
},
|
||||
"INPUT": {
|
||||
"action": "cycle_setting_options",
|
||||
"options": [
|
||||
"enabled",
|
||||
"disabled"
|
||||
],
|
||||
"value": "enabled"
|
||||
},
|
||||
"STATUS": {
|
||||
"action": null,
|
||||
"options": [],
|
||||
"value": "disconnected"
|
||||
}
|
||||
},
|
||||
"sampler":
|
||||
{
|
||||
"NEXT": {"value": "now", "action": "cycle_setting_options", "options": ["now", "random", "playlist"] },
|
||||
"TRIGGER": {"value": "loop", "action": "cycle_setting_options", "options": ["loop", "once", "once-gated"] },
|
||||
"FIXED_LENGTH_MODE": {"value": "off", "action": "cycle_setting_options", "options": ["on","off"] },
|
||||
"FIXED_LENGTH": {"value": "", "action": "set_fixed_length", "options": [] },
|
||||
"RAND_START_MODE": {"value": "off", "action": "cycle_setting_options", "options": ["on","off"] }
|
||||
"other": {
|
||||
"DEV_MODE_RESET": {
|
||||
"action": "switch_dev_mode",
|
||||
"options": [
|
||||
"on",
|
||||
"off"
|
||||
],
|
||||
"value": "on"
|
||||
},
|
||||
"QUIT": {
|
||||
"action": "quit_the_program",
|
||||
"options": [],
|
||||
"value": null
|
||||
}
|
||||
},
|
||||
"video":
|
||||
{
|
||||
"OUTPUT": {"value": "hdmi", "action": "change_output_mode", "options": [] },
|
||||
"COMPOSITE_TYPE": {"value": "pal", "action": "change_composite_output_mode", "options": [] },
|
||||
"SCREEN_MODE": {"value": "stretch", "action": "cycle_setting_options", "options": ["stretch","something else"] }
|
||||
"sampler": {
|
||||
"FIXED_LENGTH": {
|
||||
"action": "set_fixed_length",
|
||||
"options": [],
|
||||
"value": ""
|
||||
},
|
||||
"FIXED_LENGTH_MODE": {
|
||||
"action": "cycle_setting_options",
|
||||
"options": [
|
||||
"on",
|
||||
"off"
|
||||
],
|
||||
"value": "off"
|
||||
},
|
||||
"NEXT": {
|
||||
"action": "cycle_setting_options",
|
||||
"options": [
|
||||
"now",
|
||||
"random",
|
||||
"playlist"
|
||||
],
|
||||
"value": "now"
|
||||
},
|
||||
"RAND_START_MODE": {
|
||||
"action": "cycle_setting_options",
|
||||
"options": [
|
||||
"on",
|
||||
"off"
|
||||
],
|
||||
"value": "off"
|
||||
},
|
||||
"TRIGGER": {
|
||||
"action": "cycle_setting_options",
|
||||
"options": [
|
||||
"loop",
|
||||
"once",
|
||||
"once-gated"
|
||||
],
|
||||
"value": "loop"
|
||||
}
|
||||
},
|
||||
"other":
|
||||
{
|
||||
"DEV_MODE_RESET": {"value": "on", "action": "switch_dev_mode", "options": [] },
|
||||
"QUIT": {"value": null, "action": "quit_the_program", "options": [] }
|
||||
"video": {
|
||||
"COMPOSITE_PROGRESSIVE": {
|
||||
"action": "change_composite_setting",
|
||||
"options": [
|
||||
"off",
|
||||
"on"
|
||||
],
|
||||
"value": "off"
|
||||
},
|
||||
"COMPOSITE_RATIO": {
|
||||
"action": "change_composite_setting",
|
||||
"options": [
|
||||
"4:3",
|
||||
"14:9",
|
||||
"16:9"
|
||||
],
|
||||
"value": "4:3"
|
||||
},
|
||||
"COMPOSITE_TYPE": {
|
||||
"action": "change_composite_setting",
|
||||
"options": [
|
||||
"PAL",
|
||||
"NTSC"
|
||||
],
|
||||
"value": "PAL"
|
||||
},
|
||||
"OUTPUT": {
|
||||
"action": "change_output_mode",
|
||||
"options": [
|
||||
"hdmi",
|
||||
"composite"
|
||||
],
|
||||
"value": "hdmi"
|
||||
},
|
||||
"SCREEN_MODE": {
|
||||
"action": "cycle_setting_options",
|
||||
"options": [
|
||||
"stretch",
|
||||
"letterbox",
|
||||
"fill"
|
||||
],
|
||||
"value": "letterbox"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,8 +146,8 @@ class SettingsMenu(Menu):
|
||||
for setting_folder_key, setting_folder_item in self.data.settings.items():
|
||||
if setting_folder_key in self.open_folders:
|
||||
self.menu_list.append(dict(name='{}/'.format(setting_folder_key), value=''))
|
||||
for setting_key, setting_details in setting_folder_item.items():
|
||||
self.menu_list.append(dict(name=' {}'.format(setting_key), value=self.data.make_empty_if_none(setting_details['value'])))
|
||||
for setting_details_key, setting_details_item in setting_folder_item.items():
|
||||
self.menu_list.append(dict(name=' {}'.format(setting_details_key), value=self.data.make_empty_if_none(setting_details_item['value'])))
|
||||
else:
|
||||
self.menu_list.append(dict(name='{}|'.format(setting_folder_key), value=''))
|
||||
|
||||
@@ -155,7 +155,13 @@ class SettingsMenu(Menu):
|
||||
is_file, name = self.extract_file_type_and_name_from_menu_format(
|
||||
self.menu_list[self.selected_list_index]['name'])
|
||||
if is_file:
|
||||
return True, self.data.return_setting_details(name)
|
||||
folder, setting_name, setting_details = self.data.get_setting_and_folder_from_name(name)
|
||||
if setting_details['value'] in setting_details['options']:
|
||||
current_value_index = setting_details['options'].index(setting_details['value'])
|
||||
new_value_index = (current_value_index + 1) % len(setting_details['options'])
|
||||
setting_details = self.data.update_setting_value(folder, setting_name, setting_details['options'][new_value_index])
|
||||
self.generate_settings_list()
|
||||
return True, setting_details
|
||||
else:
|
||||
self.update_open_folders(name)
|
||||
self.generate_settings_list()
|
||||
|
||||
@@ -36,7 +36,7 @@ class Capture(object):
|
||||
return True
|
||||
|
||||
def set_preview_screen_size(self):
|
||||
if self.data.get_screen_size_setting() == 'dev_mode':
|
||||
if self.data.settings['other']['DEV_MODE_RESET']['value'] == 'on':
|
||||
self.device.preview.fullscreen = False
|
||||
self.device.preview.window = (50, 350, 500, 400)
|
||||
else:
|
||||
@@ -92,7 +92,7 @@ class Capture(object):
|
||||
def convert_raw_recording(self):
|
||||
recording_path , recording_name = self.generate_recording_path()
|
||||
try:
|
||||
mp4box_process = subprocess.Popen(['MP4Box -add {} {}'.format(self.video_dir + '/raw.h264', recording_path)],shell=True)
|
||||
mp4box_process = subprocess.Popen(['MP4Box', '-add', self.video_dir + '/raw.h264', recording_path])
|
||||
return mp4box_process , recording_name
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -108,10 +108,7 @@ class Capture(object):
|
||||
if process.poll() is not None:
|
||||
self.is_recording = False
|
||||
os.remove(self.video_dir + '/raw.h264')
|
||||
#this is a bit clumsy and should be improved1
|
||||
i = 0
|
||||
while not self.data.create_new_slot_mapping_in_first_open(name, i):
|
||||
i += i
|
||||
self.data.create_new_slot_mapping_in_first_open(name)
|
||||
else:
|
||||
self.root.after(300, self.wait_for_recording_to_save, process, name)
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ class VideoPlayer:
|
||||
def load(self):
|
||||
try:
|
||||
self.get_context_for_player()
|
||||
first_screen_arg, second_screen_arg = self.set_screen_size()
|
||||
is_dev_mode, first_screen_arg, second_screen_arg = self.set_screen_size_for_dev_mode()
|
||||
self.arguments = ['--no-osd', '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg]
|
||||
if not is_dev_mode:
|
||||
self.arguments.append('-b')
|
||||
self.status = 'LOADING'
|
||||
print('the location is {}'.format(self.location))
|
||||
self.omx_player = OMXPlayer(self.location, args=self.arguments, dbus_name=self.name)
|
||||
@@ -148,11 +150,12 @@ class VideoPlayer:
|
||||
except:
|
||||
pass
|
||||
|
||||
def set_screen_size(self):
|
||||
def set_screen_size_for_dev_mode(self):
|
||||
## only dev mode is needed now that auto handles all modes... can be removed probably ...
|
||||
if self.data.get_dev_mode_status() == 'on':
|
||||
return '--win', '50,350,550,750'
|
||||
if self.data.settings['other']['DEV_MODE_RESET']['value'] == 'on':
|
||||
return True, '--win', '50,350,550,750'
|
||||
else:
|
||||
return '--aspect-mode', 'stretch'
|
||||
aspect_mode = self.data.settings['video']['SCREEN_MODE']['value']
|
||||
return False, '--aspect-mode', aspect_mode
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user