From fafe0a57bb75e22c8c9222ec636eaa9a1b685c06 Mon Sep 17 00:00:00 2001 From: Stephen Ward Date: Tue, 9 Mar 2021 13:17:44 +0100 Subject: [PATCH 1/4] Initial cursor support --- dot.png | Bin 0 -> 656 bytes make-xges.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 dot.png diff --git a/dot.png b/dot.png new file mode 100644 index 0000000000000000000000000000000000000000..3e448bbca7bdae01000d32f7233510f01de9314d GIT binary patch literal 656 zcmV;B0&o3^P)EX>4Tx04R}tkv&MmKpe$iQ>8^K4t5Z6$WWauh!%0wDionYs1;guFuC*#ni!H4 z7e~Rh;NZt%)xpJCR|i)?5c~jfa&%I3krMxx6k5c1aNLh~_a1le0HIN3n$)O(glehxvqHp#<}FOz%!#}HZw;YB^FB^taLCdn;LO~IHqbk=bb^8^S!16O+6ztI4uKS{5* zwb&8RzYSbmw>4!CxZD8-pA6ZQT`5RYC>DYDGy0}HFmMa>ta`n*_Hp_EWT~t44RCM> zjFu>S&F9_W&ffk#)9UXBskL&w@C_P600006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNlirueSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{003x7L_t&-(~Z!<4TCTcMA7H1#GODXl#*7`iKzs4vK+9Y z2!+6x_B3A_?Uc-s)LRdO=g$WEJul7eDE (key + 1): + + e['duration'] = round(float(root[key + 1].attrib['timestamp'])* Gst.SECOND) - e['timestamp'] + + else: + e['duration'] = 1 + + events.append(e) + + for key, event in enumerate(events): + + if float(event['coords'][0]) != -1 and float(event['coords'][1]) != -1: + + self._add_clip(layer, dot, event['timestamp'], 0, event["duration"], self.slides_width*float(event['coords'][0]), 1080*float(event['coords'][1]), 10, 10) + + def add_deskshare(self): doc = ET.parse(os.path.join(self.opts.basedir, 'deskshare.xml')) events = doc.findall('./event') From 7af83ebcc2d98e6a38b15c32ceadb8f5451eccd5 Mon Sep 17 00:00:00 2001 From: Stephen Ward Date: Fri, 26 Mar 2021 08:06:04 +0100 Subject: [PATCH 2/4] Fixed layer order Cursor was being rendered under slides. --- make-xges.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make-xges.py b/make-xges.py index a912808..a5fe155 100755 --- a/make-xges.py +++ b/make-xges.py @@ -38,8 +38,8 @@ def __init__(self, opts): self.set_project_metadata() self.add_credits() self.add_webcams() - self.add_slides() self.add_cursor() + self.add_slides() self.add_deskshare() self.add_backdrop() From 429fd0bda5a9dd696ff64d9c22de862721130102 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Sun, 28 Mar 2021 14:16:10 +0800 Subject: [PATCH 3/4] make-xges: clean up cursor movement --- make-xges.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/make-xges.py b/make-xges.py index a5fe155..c9a0acc 100755 --- a/make-xges.py +++ b/make-xges.py @@ -189,31 +189,31 @@ def add_slides(self): def add_cursor(self): layer = self._add_layer('Cursor') doc = ET.parse(os.path.join(self.opts.basedir, 'cursor.xml')) - root = doc.getroot() - events = [] dot = self._get_asset('dot.png') - - - for key, event in enumerate(root): - - e={} - e['coords'] = event[0].text.split(' ') - e['timestamp'] = round(float(event.attrib['timestamp'])* Gst.SECOND) - - if len(root) > (key + 1): - - e['duration'] = round(float(root[key + 1].attrib['timestamp'])* Gst.SECOND) - e['timestamp'] - + dot_width, dot_height = self._get_dimensions(dot) + + events = [] + for event in doc.iterfind('./event'): + x, y = event.find('./cursor').text.split() + timestamp = round(float(event.attrib['timestamp']) * Gst.SECOND) + events.append((float(x), float(y), timestamp)) + + for i, (x, y, start) in enumerate(events): + # negative positions are used to indicate that no cursor + # should be displayed. + if x < 0 and y < 0: + continue + + # Show cursor until next event or if it is the last event, + # the end of recording. + if i + 1 < len(events): + end = events[i + 1][2] else: - e['duration'] = 1 - - events.append(e) - - for key, event in enumerate(events): - - if float(event['coords'][0]) != -1 and float(event['coords'][1]) != -1: - - self._add_clip(layer, dot, event['timestamp'], 0, event["duration"], self.slides_width*float(event['coords'][0]), 1080*float(event['coords'][1]), 10, 10) + end = self.end_time + + self._add_clip(layer, dot, start, 0, end - start, + round(self.slides_width*x - dot_width/2), + round(1080*.75*y - dot_height/2), dot_width, dot_height) def add_deskshare(self): From 00ba4ff05d693c9599296ab1167e841d310df13e Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Sun, 28 Mar 2021 17:58:24 +0800 Subject: [PATCH 4/4] make-xges: scale cursor positions based on dimensions of current slide --- make-xges.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/make-xges.py b/make-xges.py index c9a0acc..4863dc0 100755 --- a/make-xges.py +++ b/make-xges.py @@ -188,16 +188,25 @@ def add_slides(self): def add_cursor(self): layer = self._add_layer('Cursor') - doc = ET.parse(os.path.join(self.opts.basedir, 'cursor.xml')) dot = self._get_asset('dot.png') dot_width, dot_height = self._get_dimensions(dot) + doc = ET.parse(os.path.join(self.opts.basedir, 'cursor.xml')) events = [] for event in doc.iterfind('./event'): x, y = event.find('./cursor').text.split() timestamp = round(float(event.attrib['timestamp']) * Gst.SECOND) events.append((float(x), float(y), timestamp)) + # Cursor positions are relative to the size of the current slide + doc = ET.parse(os.path.join(self.opts.basedir, 'shapes.svg')) + slides = [] + for img in doc.iterfind('./{http://www.w3.org/2000/svg}image'): + start = round(float(img.get('in')) * Gst.SECOND) + width = int(img.get('width')) + height = int(img.get('height')) + slides.append((start, width, height)) + for i, (x, y, start) in enumerate(events): # negative positions are used to indicate that no cursor # should be displayed. @@ -211,10 +220,17 @@ def add_cursor(self): else: end = self.end_time - self._add_clip(layer, dot, start, 0, end - start, - round(self.slides_width*x - dot_width/2), - round(1080*.75*y - dot_height/2), dot_width, dot_height) + # Find the width/height of the slide corresponding to this + # point in time + while len(slides) > 1 and slides[1][0] <= start: + del slides[0] + width, height = self._constrain( + (slides[0][1], slides[0][2]), + (self.slides_width, self.opts.height)) + self._add_clip(layer, dot, start, 0, end - start, + round(width*x - dot_width/2), + round(height*y - dot_height/2), dot_width, dot_height) def add_deskshare(self): doc = ET.parse(os.path.join(self.opts.basedir, 'deskshare.xml'))