我正在调试elementery Videos问题,其中外部字幕文件仅在与视频同名时加载(问题#32)。
看起来ClutterGst.Playback.set_subtitle_uri只有在文件名相同时才有效。没有错误,即使给它一个非现有的文件路径也没有。 "副标题 - "总是调用信号。
Gstreamer1.0本身似乎没有问题,我已用gst-launch
对其进行了测试:
gst-launch-1.0 playbin uri=file:///home/peteruithoven/Videos/ed_hd_512kb.mp4 suburi=file:///home/peteruithoven/Videos/ed.srt
我已经创建了以下问题的简化示例。
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);
}
}
}