From a81fb0691a98083231764b73619928eea1b0e140 Mon Sep 17 00:00:00 2001 From: langolierz Date: Wed, 4 Apr 2018 22:58:04 +0000 Subject: [PATCH] extended the time to prep a clip , reducing the issue with flickering change overs sometimes, focing audio out to local to avoid hdmi freezing issues (a known bug in omx player) added actions for hard-setting pal/ntsc composite options, added auto mode for screen size --- actions.py | 24 ++++++++--- data_centre/json_objects/display_data.json | 2 +- .../json_objects/next_bankslot_number.json | 3 +- data_centre/json_objects/settings.json | 2 +- display_centre/display.py | 10 ++--- .../LCD-show/boot/config-35.txt-180 | 2 +- .../LCD-show/boot/config-nomal.txt | 4 +- .../lcd_display_drivers/LCD-show/cmdline.txt | 2 +- dotfiles/lcd_display_drivers/README.md | 6 +++ dotfiles/set_composite_mode.sh | 3 ++ video_centre/video_driver.py | 3 +- video_centre/video_player.py | 41 +++++++++++-------- 12 files changed, 66 insertions(+), 36 deletions(-) create mode 100755 dotfiles/set_composite_mode.sh diff --git a/actions.py b/actions.py index 1799d86..93bf03f 100644 --- a/actions.py +++ b/actions.py @@ -134,7 +134,7 @@ class Actions(object): def set_playing_sample_start_to_current_duration(self): current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number) - current_position = self.video_driver.current_player.get_position() + current_position = round(self.video_driver.current_player.get_position(),3) self.data.update_slot_start_to_this_time(current_bank, current_slot, current_position) self.load_this_slot_into_next_player(current_slot) @@ -145,7 +145,7 @@ class Actions(object): def set_playing_sample_end_to_current_duration(self): current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number) - current_position = self.video_driver.current_player.get_position() + current_position = round(self.video_driver.current_player.get_position(),0) self.data.update_slot_end_to_this_time(current_bank, current_slot, current_position) self.load_this_slot_into_next_player(current_slot) @@ -170,9 +170,21 @@ class Actions(object): else: self.message_handler.set_message('INFO', 'must be in dev_mode to change display') - def run_script(self, script_name): + def set_composite_to_pal(self): + self.run_script('set_composite_mode','2') + self.message_handler.set_message('INFO', 'composite set to pal on next restart') + + def set_composite_to_ntsc(self): + self.run_script('set_composite_mode','0') + self.message_handler.set_message('INFO', 'composite set to ntsc on next restart') + + def run_script(self, script_name, script_argument=''): try: - subprocess.call(['/home/pi/r_e_c_u_r/dotfiles/{}.sh'.format(script_name)]) - except exception as e: - self.message_handler.set_message('ERROR',e.message) + subprocess.call(['/home/pi/r_e_c_u_r/dotfiles/{}.sh'.format(script_name),script_argument]) + except Exception as e: + if hasattr(e, 'message'): + error_info = e.message + else: + error_info = e + self.message_handler.set_message('ERROR',error_info) diff --git a/data_centre/json_objects/display_data.json b/data_centre/json_objects/display_data.json index ad288fd..0f1d633 100644 --- a/data_centre/json_objects/display_data.json +++ b/data_centre/json_objects/display_data.json @@ -1 +1 @@ -[[{"rate": 3.5, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4", "length": 49.28, "end": -1, "start": -1, "name": "colour_pixel_01.mp4"}, {"rate": 1, "location": "/media/pi/TIM1/videos_to_play/long_spinning.mp4", "length": 804.245, "end": -1, "start": -1, "name": "long_spinning.mp4"}, {"rate": 0.5, "location": "/media/pi/TIM1/Test.mp4", "length": 599.585, "end": -1, "start": -1, "name": "Test.mp4"}, {"rate": 3.0, "location": "/media/pi/TIM1/teaser1.mp4", "length": 3.114, "end": -1, "start": -1, "name": "teaser1.mp4"}, {"rate": 0.5, "start": -1, "length": 3.114, "end": -1, "location": "/media/pi/TIM1/teaser1.mp4", "name": "teaser1.mp4"}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}], [{"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}]] \ No newline at end of file +[[{"rate": 1, "end": -1, "location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_01.mp4", "start": -1, "length": 49.28, "name": "colour_pixal_01.mp4"}, {"rate": 1, "end": -1, "location": "/media/pi/5EB5-664C/recur test videos/test.mp4", "start": -1, "length": 599.608, "name": "test.mp4"}, {"rate": 1, "end": 52.0, "location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_02.mp4", "length": 87.04, "start": 39.615, "name": "colour_pixal_02.mp4"}, {"rate": 1, "end": -1, "location": "/media/pi/5EB5-664C/recur test videos/samplerloop3s3.mp4", "length": 3.008, "start": -1, "name": "samplerloop3s3.mp4"}, {"rate": 1, "end": -1, "location": "/media/pi/5EB5-664C/recur test videos/samplerloop3s3.mp4", "start": -1, "length": 3.008, "name": "samplerloop3s3.mp4"}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}], [{"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}, {"rate": 1, "end": -1, "location": "", "start": -1, "length": -1, "name": ""}]] \ No newline at end of file diff --git a/data_centre/json_objects/next_bankslot_number.json b/data_centre/json_objects/next_bankslot_number.json index f2b9505..1a32401 100644 --- a/data_centre/json_objects/next_bankslot_number.json +++ b/data_centre/json_objects/next_bankslot_number.json @@ -1,2 +1 @@ -"0-0" - +"0-0" \ No newline at end of file diff --git a/data_centre/json_objects/settings.json b/data_centre/json_objects/settings.json index 12117cd..3e621ea 100644 --- a/data_centre/json_objects/settings.json +++ b/data_centre/json_objects/settings.json @@ -1 +1 @@ -[{"name": "SCREEN_SIZE", "options": ["dev_mode", "composite", "XGA"]}, {"name": "quit_the_program", "options": ["run_action"]}, {"name": "switch_display_to_hdmi", "options": ["run_action"]}, {"name": "switch_display_to_lcd", "options": ["run_action"]}] \ No newline at end of file +[{"name": "SCREEN_SIZE", "options": ["dev_mode", "composite_pal", "composite_ntsc", "XGA", "auto"]}, {"name": "quit_the_program", "options": ["run_action"]}, {"name": "switch_display_to_hdmi", "options": ["run_action"]}, {"name": "switch_display_to_lcd", "options": ["run_action"]}, {"name": "set_composite_to_pal", "options": ["run_action"]}, {"name": "set_composite_to_ntsc", "options": ["run_action"]}] \ No newline at end of file diff --git a/display_centre/display.py b/display_centre/display.py index df3b35c..cf3b15f 100644 --- a/display_centre/display.py +++ b/display_centre/display.py @@ -49,7 +49,7 @@ class Display(object): self.display_text.pack() def _load_title(self): - self.display_text.insert(END, '================== r_e_c_u_r:beta ============= \n') + self.display_text.insert(END, '================== r_e_c_u_r ================== \n') self.display_text.tag_add("TITLE", 1.19, 1.28) def _load_player(self): @@ -75,13 +75,13 @@ class Display(object): bank_data = self.data.get_sampler_data()[self.bank_number] self.display_text.insert(END, '------------------ ------------------ \n') self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.29) - self.display_text.insert(END, '{:^6} {:<16} {:<4} {:<4} {:<4} {:<4} \n'.format( - '{}-slot'.format(self.bank_number), 'name', 'length', 'start', 'end', 'rate')) + self.display_text.insert(END, '{:^6} {:<16} {:<4} {:<4} {:<4} \n'.format( + '{}-slot'.format(self.bank_number), 'name', 'length', 'start', 'end')) for index, slot in enumerate(bank_data): name_without_extension = slot['name'].rsplit('.',1)[0] - self.display_text.insert(END, '{:^4} {:<18} {:<4} {:<4} {:<4} {:<4} \n'.format( + self.display_text.insert(END, '{:^4} {:<18} {:<4} {:<4} {:<4} \n'.format( index, name_without_extension[0:22], self.format_time_value(slot['length']), - self.format_time_value(slot['start']), self.format_time_value(slot['end']), slot['rate'])) + self.format_time_value(slot['start']), self.format_time_value(slot['end']))) current_bank , current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number) if current_bank is self.bank_number: self.selected_list_index = current_slot diff --git a/dotfiles/lcd_display_drivers/LCD-show/boot/config-35.txt-180 b/dotfiles/lcd_display_drivers/LCD-show/boot/config-35.txt-180 index ae65e5f..c868cd0 100755 --- a/dotfiles/lcd_display_drivers/LCD-show/boot/config-35.txt-180 +++ b/dotfiles/lcd_display_drivers/LCD-show/boot/config-35.txt-180 @@ -37,7 +37,7 @@ #config_hdmi_boost=4 # uncomment for composite PAL -sdtv_mode=2 +sdtv_mode=0 #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 diff --git a/dotfiles/lcd_display_drivers/LCD-show/boot/config-nomal.txt b/dotfiles/lcd_display_drivers/LCD-show/boot/config-nomal.txt index e12c7ba..8e360cf 100755 --- a/dotfiles/lcd_display_drivers/LCD-show/boot/config-nomal.txt +++ b/dotfiles/lcd_display_drivers/LCD-show/boot/config-nomal.txt @@ -22,7 +22,7 @@ #framebuffer_height=720 # uncomment if hdmi display is not detected and composite is being output -hdmi_force_hotplug=1 +#hdmi_force_hotplug=1 # uncomment to force a specific HDMI mode (this will force VGA) #hdmi_group=1 @@ -37,7 +37,7 @@ hdmi_force_hotplug=1 #config_hdmi_boost=4 # uncomment for composite PAL -sdtv_mode=2 +sdtv_mode=0 #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 diff --git a/dotfiles/lcd_display_drivers/LCD-show/cmdline.txt b/dotfiles/lcd_display_drivers/LCD-show/cmdline.txt index 6320e7c..e58e8dc 100755 --- a/dotfiles/lcd_display_drivers/LCD-show/cmdline.txt +++ b/dotfiles/lcd_display_drivers/LCD-show/cmdline.txt @@ -1 +1 @@ -dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 quiet splash logo.nologo +dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 quiet splash logo.nologo plymouth.ignore-serial-consoles diff --git a/dotfiles/lcd_display_drivers/README.md b/dotfiles/lcd_display_drivers/README.md index 9de37bc..2df918b 100644 --- a/dotfiles/lcd_display_drivers/README.md +++ b/dotfiles/lcd_display_drivers/README.md @@ -10,6 +10,12 @@ also some modifications might be needed to hide the boot text. i will document t ## changes to config-normal.txt +## changes to config-nomal.txt +- commenting out hdmi_force to allow composite output: `#hdmi_force_hotplug=1` + +## changes to the cmdline.txt + +`quiet splash logo.nologo plymouth.ignore-serial-consoles` for quiet boot with splash screen [LCD-show-170703]: www.waveshare.com/w/uplosd/0/00/LCD-show-170703.tar.gz diff --git a/dotfiles/set_composite_mode.sh b/dotfiles/set_composite_mode.sh new file mode 100755 index 0000000..04361e9 --- /dev/null +++ b/dotfiles/set_composite_mode.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo sed -i "s/sdtv_mode=./sdtv_mode=$1/g" ~/r_e_c_u_r/dotfiles/lcd_display_drivers/LCD-show/boot/config-nomal.txt ~/r_e_c_u_r/dotfiles/lcd_display_drivers/LCD-show/boot/config-35.txt-180 /boot/config.txt diff --git a/video_centre/video_driver.py b/video_centre/video_driver.py index a7e16b5..2a0a79b 100644 --- a/video_centre/video_driver.py +++ b/video_centre/video_driver.py @@ -56,10 +56,11 @@ class VideoDriver(object): self.last_player = self.current_player self.current_player = self.next_player self.next_player = temp_player - self.last_player.exit() + #self.last_player.exit() def play_video(self): self.current_player.play() + self.last_player.exit() self.next_player.try_load() self.in_current_playing_cycle = True self.wait_for_next_cycle() diff --git a/video_centre/video_player.py b/video_centre/video_player.py index 82b656a..1c74028 100644 --- a/video_centre/video_player.py +++ b/video_centre/video_player.py @@ -39,7 +39,8 @@ class video_player: def load(self): try: self.get_context_for_player() - self.arguments = ['--no-osd', '--win', self.set_screen_size(), '--alpha', '0'] + first_screen_arg, second_screen_arg = self.set_screen_size() + self.arguments = ['--no-osd', '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg] # , ] self.status = 'LOADING' print('the location is {}'.format(self.location)) self.omx_player = OMXPlayer(self.location, args=self.arguments, dbus_name=self.name) @@ -51,29 +52,31 @@ class video_player: self.start = 0 self.crop_length = self.end - self.start print('{}: the duration is {}'.format(self.name, self.total_length)) - if self.start > 0.5: - self.set_position(self.start - 0.5) + if self.start > 0.9: + self.set_position(self.start - 0.9) self.pause_at_start() - print('set rate to {}'.format(self.rate)) - self.omx_player.set_rate(self.rate) - self.load_attempts = 0 + #print('set rate to {}'.format(self.rate)) + #self.omx_player.set_rate(self.rate) + #self.load_attempts = 0 return True - except ValueError: - self.message_handler.set_message('ERROR', 'load attempt fail') + except (ValueError, SystemError): + #self.message_handler.set_message('ERROR', 'load attempt fail') return False def pause_at_start(self): - position = self.get_position() - start_threshold = self.start - 0.05 + position = self.get_position() + start_threshold = round(self.start - 0.05,2) + #print('is playing: {} , position : {} , start_threshold : {}'.format(self.omx_player.is_playing(), position, start_threshold)) if position > start_threshold: self.status = 'LOADED' - self.omx_player.pause() self.omx_player.set_alpha(255) + self.omx_player.pause() elif self.omx_running: self.root.after(5, self.pause_at_start) def play(self): self.status = 'PLAYING' + #self.omx_player.set_alpha(255) self.omx_player.play() self.pause_at_end() @@ -90,7 +93,7 @@ class video_player: def reload(self): self.exit() self.omx_running = False - self.load() + self.try_load() def is_loaded(self): return self.status is 'LOADED' @@ -151,11 +154,17 @@ class video_player: def set_screen_size(self): if self.data.get_screen_size_setting() == 'dev_mode': - return '50,350,550,750' - elif self.data.get_screen_size_setting() == 'composite': - return '45,15,970,760' + return '--win', '50,350,550,750' + elif self.data.get_screen_size_setting() == 'composite_pal': + return '--win', '0,0,768,576' + elif self.data.get_screen_size_setting() == 'composite_ntsc': + return '--win', '0,0,640,480' + elif self.data.get_screen_size_setting() == 'composite_converter': + return '--win', '45,15,970,760' elif self.data.get_screen_size_setting() == 'XGA': - return '0,0,1024,768' + return '--win', '0,0,1024,768' + else: + return '--aspect-mode', 'stretch' class fake_video_player: