From 4ed04d98bb6205b3d96ab924991a1adc7a9465f3 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sun, 27 Nov 2016 16:05:47 +0100 Subject: [PATCH] Fix converting paths to URIs In particular this fixes adding clips with a filename which has to be quoted when becoming part of a URI, like sample_F#5.mkv --- examples/ges-simple-player.py | 2 +- vidi-player.py | 7 +++---- vidi/Timeline.py | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/ges-simple-player.py b/examples/ges-simple-player.py index bfcf330..c7946c0 100755 --- a/examples/ges-simple-player.py +++ b/examples/ges-simple-player.py @@ -38,7 +38,7 @@ def play_clip(video_path): timeline = GES.Timeline.new_audio_video() layer = timeline.append_layer() - video_uri = "file://" + video_path + video_uri = Gst.filename_to_uri(video_path) asset = GES.UriClipAsset.request_sync(video_uri) clip = layer.add_asset(asset, 0, 0, asset.get_duration(), GES.TrackType.UNKNOWN) diff --git a/vidi-player.py b/vidi-player.py index dbd5a75..04c8941 100755 --- a/vidi-player.py +++ b/vidi-player.py @@ -65,9 +65,9 @@ def timeline_from_midi(midi_file, video_font_path): print("Note name: %s start_time: %f duration: %f" % (note.name, start_time, duration)) - video_sample_uri = "file://%s/sample_%s.mkv" % (video_font_path, note.name) + video_sample_path = "%s/sample_%s.mkv" % (video_font_path, note.name) - timeline.add_clip(video_sample_uri, start_time, duration) + timeline.add_clip(video_sample_path, start_time, duration) return timeline @@ -103,8 +103,7 @@ def main(): timeline = timeline_from_midi(midi_file, video_font_path) if len(sys.argv) > 3: - destination_uri = 'file://' + os.path.realpath(sys.argv[3]) - timeline.save(destination_uri) + timeline.save(sys.argv[3]) else: timeline.play() diff --git a/vidi/Timeline.py b/vidi/Timeline.py index 48c6181..43bb9c9 100755 --- a/vidi/Timeline.py +++ b/vidi/Timeline.py @@ -43,7 +43,8 @@ class Timeline(object): self.layer = self.timeline.append_layer() - def add_clip(self, clip_uri, start_time, duration): + def add_clip(self, clip_path, start_time, duration): + clip_uri = Gst.filename_to_uri(clip_path) asset = GES.UriClipAsset.request_sync(clip_uri) self.layer.add_asset(asset, start_time * Gst.SECOND, 0, duration * Gst.SECOND, GES.TrackType.UNKNOWN) @@ -55,5 +56,6 @@ class Timeline(object): ges_pipeline.set_timeline(self.timeline) Player(ges_pipeline).play() - def save(self, uri): + def save(self, path): + uri = Gst.filename_to_uri(path) self.project.save(self.timeline, uri, None, False) -- 2.1.4