我如何在javafx videoplayer中使用Gstreamer? [英] how can i use Gstreamer in javafx videoplayer?

查看:64
本文介绍了我如何在javafx videoplayer中使用Gstreamer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是javafx中的视频播放器.我们如何支持mkv,vob,avi等扩展? 可以在javafx中使用gstreamer来支持其他扩展吗? 我们该如何使用gstreamer,否则请说其他方法使视频播放器支持其他扩展...

this is a videoplayer in javafx.how we can support mkv,vob,avi etc extension ? is this possible to use gstreamer in javafx to support other extension? how can we use gstreamer or if not then plz say any other way to make the videoplayer other extension supported...

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;


public class MoviePlayer extends Application {

/**
 * 
 */
    public static void main(String args[])
    {
        launch(args);
    }

    @Override
    public void start(Stage arg0) throws Exception {

    final Stage stage=new Stage();
    stage.setTitle("Video Player");
    Group root = new Group();
    Media media = new Media("file:///C:/Users/vi/downloads/Video/a.mp4");
    final MediaPlayer player=new MediaPlayer(media);
    MediaView view=new MediaView(player);

    //  System.out.println("media.Width"+media.getWidth());

    final VBox vbox=new VBox();
    Slider slider=new Slider();


    root.getChildren().add(view);
    root.getChildren().add(vbox);
    root.getChildren().add(slider);

    Scene scene=new Scene(root, 400,400,Color.BLACK);
    stage.setScene(scene);
    stage.show();

    player.play();
    player.setOnReady(new Runnable() {

        @Override
        public void run() {
            int w=player.getMedia().getWidth();
            int h=player.getMedia().getHeight();

            stage.setMinWidth(w);
            stage.setMinHeight(h);

            vbox.setMinSize(w,100 );
            vbox.setTranslateY(h);

           }
        });



    }


}

推荐答案

是旧话题,但今天跌跌撞撞地提出了 GitHub上的gstreamer-java存储库.已经有几年了但是最近有新的gst1-java和gst1-java-fx项目.如11天前更新.尝试这些示例,看看它们是否可以接受其他电影格式将是很有趣的.但是看来文档很少.

Old topic, but stumbling around today brought up a gstreamer-java repo on GitHub. It's a few years old. But lately there are fresh gst1-java and gst1-java-fx projects there. As in updated 11 days ago. It would be interesting to try out the examples and see if they can accept other movie formats. But it looks like the documentation is sparse to none.

另一种替代方法是使用ffmpeg或手刹将视频重新混合为另一种容器格式.

Another alternative is to use ffmpeg or handbrake to remux the videos into another container format.

这篇关于我如何在javafx videoplayer中使用Gstreamer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆