About GStreamer 1.x Java Swing

115 views
Skip to first unread message

Ozan Şenyayla

unread,
Sep 1, 2021, 6:52:17 AM9/1/21
to gstreamer-java
Hi All,

How to success to play pipeline on "GStreamer 1.x Java Swing example"?

Im creating a JForm and Im adding GstVideoComponent object inside it. But later, I could not play video inside this component. I can play pipeline that is attached to GstVideoComponent object. But it creates a new window to run video. I need to run video inside my JForm?

Could anyone help me?

Thanks,
Ozan Sonyoyle

Neil C Smith

unread,
Sep 1, 2021, 7:18:59 AM9/1/21
to gstream...@googlegroups.com
Do the existing Swing examples work OK for you?

https://github.com/gstreamer-java/gst1-java-examples/tree/master/SwingCamera
https://github.com/gstreamer-java/gst1-java-examples/tree/master/SwingPlayer

Make sure you don't have another video sink element in the pipeline,
other than an appsink passed into GstVideoComponent constructor, or
the appsink from GstVideoComponent::getElement (if using the no-arg
constructor).

If you're still stuck, you'll need to share some actual code.

Best wishes,

Neil


--
Neil C Smith
Codelerity Ltd.
www.codelerity.com

Codelerity Ltd. is a company registered in England and Wales
Registered company number : 12063669
Registered office address : Office 4 219 Kensington High Street,
Kensington, London, England, W8 6BD

Ozan Şenyayla

unread,
Sep 1, 2021, 9:55:15 AM9/1/21
to gstream...@googlegroups.com
Hi All,

I applied the example codes but it could not fit me. Here is my simplified solution in below;

public static void main(String[] args) {

        mainScreen ms = new mainScreen();
        ms.setVisible(true);
             
        Gst.init(Version.BASELINE, "BasicPipeline");
       
        pipeline = (Pipeline) Gst.parseLaunch("videotestsrc ! autovideosink");
       
        GstVideoComponent vc = new GstVideoComponent();
       
        // Missing a connection bw GstVideoComponent and pipeline
       
        // The code on Swing Exapmle
        //playbin = new PlayBin("playbin");      // Actually I have a pipeline instead
        //playbin.setVideoSink(vc.getElement()); // pipeline have not method such
                                               // setVideoSink

        Element level = ElementFactory.make("level", "level");
        //playbin.set("audio-filter", level);

        // Panel that should run the pipeline inside.
        // ms.videoPanel ??
        ms.videoPanel.add(vc);
        vc.setPreferredSize(new Dimension(800, 600));

        pipeline.play(); // Opens a new window
        Gst.main();
    }

I have an issue in connecting pipeline and GstVideoComponent AND
running pipeline on a JForm in another java form. When I call pipeline.play() it opens a new window.

Thanks,
Ozan,

Neil C Smith <ne...@codelerity.com>, 1 Eyl 2021 Çar, 14:19 tarihinde şunu yazdı:
--
You received this message because you are subscribed to a topic in the Google Groups "gstreamer-java" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gstreamer-java/DK1UzxdBg6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gstreamer-jav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gstreamer-java/CAPxOS5GBYNuc7%2B4FNgadXsu5vxb3XxuFZA%2BYqjk3tDrH00R%3DOg%40mail.gmail.com.

Neil C Smith

unread,
Sep 1, 2021, 10:02:46 AM9/1/21
to gstream...@googlegroups.com
On Wed, 1 Sept 2021 at 14:55, Ozan Şenyayla <ozan.s...@opsin.com.tr> wrote:
> I applied the example codes but it could not fit me. Here is my simplified solution in below;
...
> pipeline = (Pipeline) Gst.parseLaunch("videotestsrc ! autovideosink");
>
> GstVideoComponent vc = new GstVideoComponent();
>
> // Missing a connection bw GstVideoComponent and pipeline

See the camera example!

Or if you really need a pipeline and not a bin, you can do something like this -

pipeline = (Pipeline) Gst.parseLaunch("videotestsrc ! appsink name=sink");
AppSink sink = (AppSink) pipeline.getElementByName("sink");
GstVideoComponent vc = new GstVideoComponent(sink);

You need to remove autovideosink, or you'll get a separate window.

Ozan Şenyayla

unread,
Sep 2, 2021, 1:25:47 AM9/2/21
to gstream...@googlegroups.com
Hi Neil,

Thank you for your support, I got it! Here is the simplest code that works that may be useful for the rest.

mainScreen ms = new mainScreen();
ms.setVisible(true);
Gst.init(Version.BASELINE, "BasicPipeline");
pipeline = (Pipeline) Gst.parseLaunch("videotestsrc ! appsink name=sink");
AppSink sink = (AppSink) pipeline.getElementByName("sink");
GstVideoComponent vc = new GstVideoComponent(sink);
vc.setSize(200, 200);
vc.setVisible(true);
ms.videoPanel.add(vc);
pipeline.play();

Thanks again,
Ozan

Neil C Smith <ne...@codelerity.com>, 1 Eyl 2021 Çar, 17:02 tarihinde şunu yazdı:
--
You received this message because you are subscribed to a topic in the Google Groups "gstreamer-java" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gstreamer-java/DK1UzxdBg6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gstreamer-jav...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages