Problem capturing video from Java but command line works

127 views
Skip to first unread message

Nick

unread,
Feb 6, 2023, 1:57:22 PM2/6/23
to gstreamer-java
Hi

When running GStreamer from the command line with this example the recorded video looks great:
gst-launch-1.0 decklinkvideosrc device-number=0 connection=sdi mode=auto ! videoconvert ! jpegenc ! avimux ! filesink location=decklinkCapture.mov

But when using these elements in Java it doesn't work. Here is the main function that I am using to try to save to file that doesn't work. The saved file just has the number 1 in it.

Double.png

Does this not work like the command line? I'm fairly new to GStreamer but can't figure out why this works on the command line and not in a java class?

Let me know if you can help.

Thanks,
Nick

Neil C Smith

unread,
Feb 6, 2023, 2:15:01 PM2/6/23
to gstream...@googlegroups.com
Hi Nick,

Welcome!

Firstly, please share code as actual text rather than an image.  It helps reading, and when trying to respond with comments on particular lines!

Note that parseBinFromDescription is not the same as you're doing on the command line.  That creates a container (Bin) with the elements inside it.  One of multiple issues with that is the use of ghostUnlinkedPads, which with elements with dynamic pads in the pipeline may not behave as you expect.

The command line creates a Pipeline, with all elements at the top level.  To do that in Java you would use Gst.parseLaunch, which you will have to cast to Pipeline.  There are a number of threads on here that have covered this recently, eg. https://groups.google.com/g/gstreamer-java/c/IjCb4WyeqeY/m/C5xK9n41BgAJ

The other problem with what you're doing is that if you want to save and display the video at the same time, you will need two sinks, which means that you'll have to use a tee element, and probably a queue on one or both branches.  You're probably best searching example pipelines for that - I haven't used a decklinkvideosrc for a few years, so not sure what implications that might have.

The branch for display will need to end with a named appsink (eg. appsink name=sink) - example of using that and passing to the Swing component is also in the code in that thread above.

Best wishes,

Neil

--
You received this message because you are subscribed to the Google Groups "gstreamer-java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gstreamer-jav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gstreamer-java/b9a794cd-817f-4777-ab1d-16384359182bn%40googlegroups.com.


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

Nick

unread,
Feb 6, 2023, 3:17:12 PM2/6/23
to gstreamer-java
Hi Neil,

Ok thanks for the help, looks like I was able to save to the file correctly by using Gst.parshLaunch and not trying to view anything.

This code worked great:

Gst.init();

Pipeline pipe = (Pipeline) Gst.parseLaunch(
"decklinkvideosrc device-number=0 connection=sdi mode=auto " +
"! videoconvert " +
"! jpegenc " +
"! avimux " +
"! filesink location=/home/nick/decklinkCapture.mov");

pipe.play();

One of the reasons I was looking at using SampleVideoComponent is because of the access to where the frames are being generated. I'm trying to get the System.nanotime() of when each frame is generated. I haven't seen much on how to do this. Do you have any insights on where the frames are getting generated?

Please let me know,

Thanks,
Nick

Neil C Smith

unread,
Feb 6, 2023, 3:48:02 PM2/6/23
to gstream...@googlegroups.com
On Mon, 6 Feb 2023 at 20:17, Nick <birdbr...@gmail.com> wrote:
> One of the reasons I was looking at using SampleVideoComponent is because of the access to where the frames are being generated. I'm trying to get the System.nanotime() of when each frame is generated. I haven't seen much on how to do this.

Well, you could look at adding a pad probe to access the buffer as it
passes through. See the example at
https://github.com/gstreamer-java/gst1-java-examples/blob/master/BufferProbe/src/main/java/org/freedesktop/gstreamer/examples/BufferProbe.java

It might be useful to get the timestamp info from the buffer. See the
test code at https://github.com/gstreamer-java/gst1-java-core/blob/master/test/org/freedesktop/gstreamer/video/VideoTimeCodeMetaTest.java#L65

Best wishes,

Neil

Nick

unread,
Feb 7, 2023, 10:43:56 AM2/7/23
to gstreamer-java
Ok so I've been looking into the options that you suggested and ran into another issue.


When running this command on the command line: gst-launch-1.0 decklinkvideosrc device-number=0 connection=sdi mode=auto ! videoconvert ! videoscale ! video/x-raw, width=800, height=600, pixel-aspect-ratio=1/1, format=BGRx ! videoconvert ! jpegenc ! avimux ! filesink location=decklinkCapture.mov -e

I run into an Internal data stream error and I'm not sure what that means. Here is what outputs for the error:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstDecklinkVideoSrc:decklinkvideosrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstDecklinkVideoSrc:decklinkvideosrc0:
streaming stopped, reason not-negotiated (-4)
EOS on shutdown enabled -- waiting for EOS after Error


Any tips on how to fix this error? It seems when I added the videoscale elements things stopped working.

Thanks,
Nick

Nick

unread,
Feb 7, 2023, 4:06:55 PM2/7/23
to gstreamer-java
So it turns out I was able to solve this issue with a better understanding of the Caps for both the src and the sink elements. I was trying to pass in pad templates that were not compatible with decklinkvideosrc so it was causing problems.

Thanks for all the help! Glad I was able to get this working.
Reply all
Reply to author
Forward
0 new messages