javaswingjframegstreamergst-launch-1.0

Gstreamer run on JavaForm


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

Solution

  • 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,