GStreamer Video player in a Swing Component

177 views
Skip to first unread message

Castillejos Nicolas

unread,
May 18, 2016, 4:05:36 AM5/18/16
to gstreamer-java

Hi,

I'm trying to make a java application that reads a ".m4v" file in a 
JFrame using the SimpleVideoComponent class from the gstreamer examples.
But my problem is that I can only watch the first picture of the video, 
however the sound is working great.

look at my code :

EventQueue.invokeLater(new Runnable() {

             @Override
             public void run() {
                 vc = new SimpleVideoComponent();
                 bin = new PlayBin("VideoPlayer");

                 bin.setInputFile(new File("./test.m4v"));

                 f.add(vc);
                 vc.setPreferredSize(new Dimension(320, 240));

                 bin.setVideoSink(vc.getElement());
                 bin.play();

                 f.pack();
                 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 f.setVisible(true);

             }
         });

When i comment this line : bin.setVideoSink(vc.getElement());
the video is playing great in an other frame called "internal frame"
but when I want to play in my own frame inside the SimpleVideoComponent 
it shows only the first picture.

The method newBuffer() in the AppSinkListener of the 
SimpleVideoComponent class is called only once.
And I don't know why...

Do you have an idea to help me resolve this ?

Thank you,


More Informations : I use GStreamer 1.6.4 on Windows 32 bits and the Java Mapping gstreamer1.x-java (https://github.com/gstreamer-java/gst1-java-core)

Castillejos Nicolas

unread,
May 18, 2016, 5:55:29 AM5/18/16
to gstreamer-java
I've found the problem , there is a little error in the java binding :

In the class org.freedesktop.gstreamer.elements.AppSink
Int the method connect(final NEW_SAMPLE listener)
the GstCallback have a callback method that returns void,
And I've look the C++ code, this method must returns a FlowReturn
I've made a fast correction :

connect(NEW_SAMPLE.class, listener, new GstCallback() {
            @SuppressWarnings("unused")
            public FlowReturn callback(AppSink elem) {
                listener.newBuffer(elem);
                return FlowReturn.OK;
            }
        });

And now it works great !
Reply all
Reply to author
Forward
0 new messages