From b8e918b801499092c45a49846d53af11d89470c5 Mon Sep 17 00:00:00 2001 From: SenorPez Date: Fri, 20 Jan 2017 11:06:10 -0600 Subject: [PATCH 1/4] Version number changes for 0.5.2 development --- README.md | 2 +- replayenhancer/replayenhancer.py | 26 ++++++++++++++++++++++++-- setup.py | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 47c50f2..6e36a5a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Combines telemetry data with replay video to improve Project CARS replays. -Current release: 0.5 +Current release: 0.5.2 Current edge state: Getting There, Maybe diff --git a/replayenhancer/replayenhancer.py b/replayenhancer/replayenhancer.py index 082003e..c9f5222 100644 --- a/replayenhancer/replayenhancer.py +++ b/replayenhancer/replayenhancer.py @@ -136,8 +136,30 @@ def timecode_frame(time): ).subclip(start_time, end_time) else: + def timecode_frame(time): + timecode_image = Image.new('RGB', (100, 40)) + draw = ImageDraw.Draw(timecode_image) + draw.text((10, 10), "%.02f"%(time)) + return PIL_to_npimage(timecode_image) + + def et_frame(time): + et_image = Image.new('RGB', (100, 40)) + draw = ImageDraw.Draw(et_image) + draw.text((10, 10), "%.02f"%(race_data.elapsed_time)) + return PIL_to_npimage(et_image) + + def ct_frame(time): + ct_image = Image.new('RGB', (100, 40)) + draw = ImageDraw.Draw(ct_image) + draw.text((10, 10), "%.02f"%(race_data._next_packet.current_time)) + return PIL_to_npimage(ct_image) + + timecode_clip = mpy.VideoClip(timecode_frame, duration=source_video.duration).set_position(('center', 'top')) + et_clip = mpy.VideoClip(et_frame, duration=source_video.duration).set_position(('center', 'bottom')) + ct_clip = mpy.VideoClip(ct_frame, duration=source_video.duration).set_position(('right', 'center')) + main_event = mpy.CompositeVideoClip( - [source_video, standings_clip] + [source_video, standings_clip, timecode_clip, et_clip, ct_clip] ).set_duration(source_video.duration) pcre_starting_grid = StartingGrid( @@ -251,7 +273,7 @@ def main(): '-v', '--version', action='version', - version='Version 0.5 Release Candidate 2') + version='Version 0.5.2 Release Candidate 1') args = parser.parse_args() diff --git a/setup.py b/setup.py index f9ddf58..ea2add2 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ setup( name='replayenhancer', - version='0.5.1rc2', - description='Replay Enhancer 0.5.1 Release Candidate 2', + version='0.5.2rc1', + description='Replay Enhancer 0.5.2 Release Candidate 1', long_description=long_description, url='https://github.com/SenorPez/project-cars-replay-enhancer', author='Senor Pez', From 0a36be8b8d763476a28b0518e969bc8050dd2601 Mon Sep 17 00:00:00 2001 From: SenorPez Date: Fri, 20 Jan 2017 11:29:04 -0600 Subject: [PATCH 2/4] Fixes #128. Video and telemetry remain in sync. --- replayenhancer/RaceData.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/replayenhancer/RaceData.py b/replayenhancer/RaceData.py index a2a680c..9d0c652 100644 --- a/replayenhancer/RaceData.py +++ b/replayenhancer/RaceData.py @@ -37,7 +37,6 @@ def __init__(self, telemetry_directory, *, self._stopped_drivers = set() self.elapsed_time = 0.0 - self._add_time = 0.0 self._last_packet = None self._next_packet = None @@ -188,14 +187,6 @@ def get_data(self, at_time=None): self._next_packet = self._last_packet raise - self.elapsed_time, \ - self._add_time, \ - self._last_packet = \ - self._calc_elapsed_time( - self._next_packet, - self._add_time, - self._last_packet) - if (self._next_packet is not None and self._last_packet is None) \ or self._next_packet.num_participants \ @@ -223,6 +214,7 @@ def get_data(self, at_time=None): self.track = Track(self._next_packet.track_length) self._add_sector_times(self._next_packet) + self._calc_elapsed_time() if at_time is None or self.elapsed_time >= at_time: return self._next_packet @@ -284,20 +276,15 @@ def _best_sector(self, sector): except ValueError: return None - @staticmethod - def _calc_elapsed_time(next_packet, add_time, last_packet): - if next_packet.current_time == -1.0: - elapsed_time = 0.0 - add_time = 0.0 - last_packet = None + def _calc_elapsed_time(self): + if self._next_packet.current_time == -1.0: + self.elapsed_time = 0.0 + self._last_packet = None else: - if last_packet is not None and last_packet.current_time \ - - next_packet.current_time > 0.5: - add_time += last_packet.current_time - - elapsed_time = add_time + next_packet.current_time - - return elapsed_time, add_time, last_packet + driver = next( + driver for driver in self.drivers.values() + if driver.index == self._next_packet.viewed_participant_index) + self.elapsed_time = sum(driver.lap_times) + self._next_packet.current_time @staticmethod def _get_drivers(telemetry_data, count): From 29ec31299d62c066e8b92983c939b4ce4bdf218e Mon Sep 17 00:00:00 2001 From: SenorPez Date: Fri, 20 Jan 2017 11:30:33 -0600 Subject: [PATCH 3/4] Removing test code. --- replayenhancer/replayenhancer.py | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/replayenhancer/replayenhancer.py b/replayenhancer/replayenhancer.py index c9f5222..51555f5 100644 --- a/replayenhancer/replayenhancer.py +++ b/replayenhancer/replayenhancer.py @@ -136,30 +136,8 @@ def timecode_frame(time): ).subclip(start_time, end_time) else: - def timecode_frame(time): - timecode_image = Image.new('RGB', (100, 40)) - draw = ImageDraw.Draw(timecode_image) - draw.text((10, 10), "%.02f"%(time)) - return PIL_to_npimage(timecode_image) - - def et_frame(time): - et_image = Image.new('RGB', (100, 40)) - draw = ImageDraw.Draw(et_image) - draw.text((10, 10), "%.02f"%(race_data.elapsed_time)) - return PIL_to_npimage(et_image) - - def ct_frame(time): - ct_image = Image.new('RGB', (100, 40)) - draw = ImageDraw.Draw(ct_image) - draw.text((10, 10), "%.02f"%(race_data._next_packet.current_time)) - return PIL_to_npimage(ct_image) - - timecode_clip = mpy.VideoClip(timecode_frame, duration=source_video.duration).set_position(('center', 'top')) - et_clip = mpy.VideoClip(et_frame, duration=source_video.duration).set_position(('center', 'bottom')) - ct_clip = mpy.VideoClip(ct_frame, duration=source_video.duration).set_position(('right', 'center')) - main_event = mpy.CompositeVideoClip( - [source_video, standings_clip, timecode_clip, et_clip, ct_clip] + [source_video, standings_clip] ).set_duration(source_video.duration) pcre_starting_grid = StartingGrid( From e86483e578f3f0570eec226d305932cd73187a2d Mon Sep 17 00:00:00 2001 From: SenorPez Date: Mon, 23 Jan 2017 13:49:51 -0600 Subject: [PATCH 4/4] Updating versions for 0.5.2 release --- replayenhancer/replayenhancer.py | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/replayenhancer/replayenhancer.py b/replayenhancer/replayenhancer.py index 51555f5..1d7addc 100644 --- a/replayenhancer/replayenhancer.py +++ b/replayenhancer/replayenhancer.py @@ -251,7 +251,7 @@ def main(): '-v', '--version', action='version', - version='Version 0.5.2 Release Candidate 1') + version='Version 0.5.2') args = parser.parse_args() diff --git a/setup.py b/setup.py index ea2add2..6d6e1e0 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ setup( name='replayenhancer', - version='0.5.2rc1', - description='Replay Enhancer 0.5.2 Release Candidate 1', + version='0.5.2', + description='Replay Enhancer 0.5.2', long_description=long_description, url='https://github.com/SenorPez/project-cars-replay-enhancer', author='Senor Pez',