From 206183f5da1fe20196eb246847a21f84098c1aec Mon Sep 17 00:00:00 2001 From: j Date: Thu, 9 Nov 2023 00:32:32 +0100 Subject: [PATCH 1/2] fix player --- player/player-back.service | 2 +- player/player-front.service | 2 +- player/player.py | 3 ++- player/saxophone.service | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/player/player-back.service b/player/player-back.service index 1ae4193..30cbe5f 100644 --- a/player/player-back.service +++ b/player/player-back.service @@ -8,4 +8,4 @@ KillSignal=SIGINT ExecStart=/srv/pandora/t_for_time/player/player.py --mode peer --playlist /srv/t_for_time/render/back.m3u [Install] -WantedBy=default.target +WantedBy=graphical-session.target diff --git a/player/player-front.service b/player/player-front.service index 6090352..856a32b 100644 --- a/player/player-front.service +++ b/player/player-front.service @@ -8,4 +8,4 @@ KillSignal=SIGINT ExecStart=/srv/pandora/t_for_time/player/player.py --mode main --playlist /srv/t_for_time/render/front.m3u [Install] -WantedBy=default.target +WantedBy=graphical-session.target diff --git a/player/player.py b/player/player.py index 89395d3..a408a54 100755 --- a/player/player.py +++ b/player/player.py @@ -80,7 +80,8 @@ class Sync(Thread): if self._tick and abs(time.time() - self._tick) > 60: logger.error("player is stuck") self._tick = 0 - self.quit() + self.stop() + self.mpv.stop() def q_binding(self, *args): self.stop() diff --git a/player/saxophone.service b/player/saxophone.service index dc6ce7a..2b9d2f0 100644 --- a/player/saxophone.service +++ b/player/saxophone.service @@ -8,4 +8,4 @@ ExecStart=/usr/bin/mpv --quiet --loop /srv/t_for_time/render/Saxophone-5.1.mp4 KillSignal=SIGINT [Install] -WantedBy=default.target +WantedBy=graphical-session.target From 069eec802da6c5724c1e84788cbe2078c3b0eacc Mon Sep 17 00:00:00 2001 From: j Date: Thu, 9 Nov 2023 00:33:06 +0100 Subject: [PATCH 2/2] fix audio duration --- render.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/render.py b/render.py index b551831..f7adb21 100644 --- a/render.py +++ b/render.py @@ -253,33 +253,30 @@ def get_scene_duration(scene): def render(root, scene, prefix=''): fps = 24 files = [] + scene_duration = int(get_scene_duration(scene) * 24) for timeline, data in scene.items(): #print(timeline) project = KDEnliveProject(root) tracks = [] + track_durations = {} for track, clips in data.items(): #print(track) for clip in clips: project.append_clip(track, clip) + track_durations[track] = int(sum([c['duration'] for c in clips]) * 24) + if timeline.startswith('audio-'): + track_duration = project.get_duration() + delta = scene_duration - track_duration + if delta > 0: + for track in track_durations: + if track_durations[track] == track_duration: + project.append_clip(track, {'blank': True, "duration": delta/24}) + break path = os.path.join(root, prefix + "%s.kdenlive" % timeline) with open(path, 'w') as fd: fd.write(project.to_xml()) files.append(path) - if timeline == "audio": - duration = project.get_duration() - for track, clips in data.items(): - project = KDEnliveProject(root) - for clip in clips: - project.append_clip(track, clip) - track_duration = project.get_duration() - delta = duration - track_duration - if delta > 0: - project.append_clip(track, {'blank': True, "duration": delta/24}) - path = os.path.join(root, prefix + "%s-%s.kdenlive" % (timeline, track)) - with open(path, 'w') as fd: - fd.write(project.to_xml()) - files.append(path) return files def get_fragments(clips, voice_over, prefix): @@ -451,8 +448,8 @@ def render_all(options): for cmd in cmds: #print(" ".join([str(x) for x in cmd])) subprocess.call(cmd) - ft = ox.avinfo(fragment_prefix / "front-5.1.mp4")['duration'] - bt = ox.avinfo(fragment_prefix / "back.mp4")['duration'] + ft = ox.avinfo(str(fragment_prefix / "front-5.1.mp4"))['duration'] + bt = ox.avinfo(str(fragment_prefix / "back.mp4"))['duration'] if ft != bt: print(ft, fragment_prefix / "front-5.1.mp4") print(bt, fragment_prefix / "back.mp4")