1

Assume that we have a GStreamer command such as the following and it runs on the console very well. How I can run this on a specific JFrame? When I run this command on the terminal, it opens a new video scene. But I need to run this video on a specific sized JFrame Form on Netbeans.

gst-launch-1.0 udpsrc port=5004 buffer-size=622080 ! avdec_h264 ! videoconvert ! fpsdisplaysink
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
muradaltay
  • 41
  • 7
  • Did you have a look at the [gstreamer-java](https://github.com/gstreamer-java) project? That was basically the first result a quick search for "gstreamer java" came up with and it seems to contain example of how to integrate the tool with UI frameworks such as Swing. – Thomas Aug 31 '21 at 06:40
  • Thanks Thomas, but these examples are not fit my problem. One of these examples is running a BasicPipeline that creates its own window. Anothers are for running saved video files, not running gstlaunch resulted video. – muradaltay Aug 31 '21 at 07:46
  • Actually I need Gst.main() alternative for this examples. This function creates a new window itself. But I need to control of generation of this window. – muradaltay Aug 31 '21 at 08:10
  • Here is the simplest solution that puts the gstreamer output into a user specified form screen; 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(); – muradaltay Sep 02 '21 at 05:28
  • If that worked for you I'd suggest you post it as an answer. That way you could format the code nicely for others to pick up and also add some more explanation or references to where you got that information. – Thomas Sep 02 '21 at 06:47

1 Answers1

1

Here is the solution below; (Çözümüm aşağıdadır.)

// Gstreamer init - İlklendir
Gst.init(Version.BASELINE, "BasicPipeline");

// Create a named pipeline - sink isimli bir pipeline yarat.
pipeline = (Pipeline) Gst.parseLaunch("videotestsrc ! appsink name=sink");

// Create am appsink that refers to pipeline - sink'ten bir appSink nesnesi yarat
AppSink sink = (AppSink) pipeline.getElementByName("sink");

// Create GstVideoComponent object - gstVc objesi yarat.
GstVideoComponent vc = new GstVideoComponent(sink);
vc.setSize(600, 560);
vc.setVisible(true);

// main screen is a form screen that is public static and has a jform named panel_video  - vc'yi form'a ekle
mainScreen.panel_video.add(vc);

// play video - video'yu koştur.
pipeline.play();

Thanks,

muradaltay
  • 41
  • 7