ClutterGST only shows external subtitles if same filename as video file

93 Views Asked by At

I'm debugging an elementery Videos issue where external subtitles files are only loaded when they have the same name as the video (issue #32).

It looks like ClutterGst.Playback.set_subtitle_uri only works if it's the same filename. There are no errors, not even when giving it a non existing file path. The "subtitle-uri" signal is always called.

Gstreamer1.0 itself doesn't seem to have an issue with this, I've tested that with gst-launch:

gst-launch-1.0 playbin uri=file:///home/peteruithoven/Videos/ed_hd_512kb.mp4 suburi=file:///home/peteruithoven/Videos/ed.srt 

I've created the following simplified example of the issue.

namespace Test {
    public class Application : Gtk.Application {

        public GtkClutter.Embed clutter;
        private Clutter.Actor video_actor;
        private Clutter.Stage stage;
        private ClutterGst.Playback playback;

        public Application () {
            Object (
                application_id: "com.github.peteruithoven.subtitles-test",
                flags: ApplicationFlags.FLAGS_NONE
            );
        }

        protected override void activate () {

            var main_window = new Gtk.ApplicationWindow (this);
            main_window.default_height = 400;
            main_window.default_width = 500;
            main_window.title = "Hello World";

            playback = new ClutterGst.Playback ();
            playback.set_seek_flags (ClutterGst.SeekFlags.ACCURATE);
            clutter = new GtkClutter.Embed ();
            stage = (Clutter.Stage)clutter.get_stage ();
            stage.background_color = {0, 0, 0, 0};

            video_actor = new Clutter.Actor ();
            var aspect_ratio = new ClutterGst.Aspectratio ();

            ((ClutterGst.Aspectratio) aspect_ratio).paint_borders = false;
            ((ClutterGst.Content) aspect_ratio).player = playback;
            video_actor.content = aspect_ratio;

            video_actor.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.WIDTH, 0));
            video_actor.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.HEIGHT, 0));

            stage.add_child (video_actor);
            main_window.add (clutter);
            main_window.show_all ();

            playback.notify["subtitle-uri"].connect (() => {
                stdout.printf ("playback.notify subtitle-uri: %s\n", playback.subtitle_uri);
            });

            playback.uri = "file:///home/peteruithoven/Videos/ed_hd_512kb.mp4";
            playback.set_subtitle_uri ("file:///home/peteruithoven/Videos/ed.srt"); // doesn't work
            // playback.set_subtitle_uri ("file:///home/peteruithoven/Videos/ed_hd_512kb.srt"); // works
            playback.playing = true;
        }

        public static int main (string[] args) {

            var err = GtkClutter.init (ref args);
            if (err != Clutter.InitError.SUCCESS) {
                error ("Could not initalize clutter! "+err.to_string ());
            }

            Gst.init (ref args);

            var app = new Application ();
            return app.run (args);
        }
    }
}

This example in a repo: https://github.com/peteruithoven/subtitles-test

0

There are 0 best solutions below