How to set -e, --eos-on-shutdown in java

87 views
Skip to first unread message

vijay.p...@calumspro.com

unread,
Apr 17, 2019, 1:41:54 PM4/17/19
to gstreamer-java
Hello,

Is there a way to implement the  -e, --eos-on-shutdown (Force EOS on sources before shutting the pipeline down) in Java,

-e, --eos-on-shutdown is one of the gst-launch-1.0 option.


Thank You
Vijay

Neil C Smith

unread,
Apr 23, 2019, 4:58:07 AM4/23/19
to gstream...@googlegroups.com
On Wed, 17 Apr 2019 at 18:41, <vijay.p...@calumspro.com> wrote:
> Is there a way to implement the -e, --eos-on-shutdown (Force EOS on sources before shutting the pipeline down) in Java,
>
> -e, --eos-on-shutdown is one of the gst-launch-1.0 option.

That's only a CLI option. Without knowing your code, what I think you
most probably want to do is push an EOS event into the pipeline before
shutting it down.

Best wishes,

Neil



--
Neil C Smith
Artist & Technologist
www.neilcsmith.net

PraxisLIVE - hybrid visual live programming
for creatives, for programmers, for students, for tinkerers
www.praxislive.org

Nick

unread,
Feb 27, 2023, 3:50:11 PM2/27/23
to gstreamer-java
Hey,

So the pipeline I am using  looks like this:

gst-launch-1.0 decklinkvideosrc connection=sdi ! videoconvert ! videorate ! x264enc ! mp4mux ! filesink location=xyz.mp4 -e

and this works great, the video is saved correctly. The program I am using is this:

{
Gst.init();

Pipeline pipe = (Pipeline) Gst.parseLaunch( "decklinkvideosrc connection=sdi " + "! videoconvert " + "! videorate " + "! x264enc " + "! mp4mux " + "! filesink location=/xyz.mp4"); pipe.play();
ThreadTools.sleepSeconds(10);
pipe.sendEvent(new EOSEvent());
pipe.stop();
}

I am trying to replicate the (-e) at the end of the command line. But can't figure out why the saved video with the program doesn't work like (-e). Pushing an EOS event was suggested above put maybe I am doing that wrong.

Any help would be appreciated.

Thanks,
Nick

Neil C Smith

unread,
Feb 28, 2023, 5:18:24 AM2/28/23
to gstream...@googlegroups.com
On Mon, 27 Feb 2023 at 20:50, Nick <birdbr...@gmail.com> wrote:
> I am trying to replicate the (-e) at the end of the command line. But can't figure out why the saved video with the program doesn't work like (-e). Pushing an EOS event was suggested above put maybe I am doing that wrong.

It doesn't look like you're waiting for the event to propagate down
the pipeline to the sink before the process ends.

Firstly, try adding another sleep after you stop the pipeline and see
if the video is working.

You probably want to add an EOS listener to the pipeline bus and stop
the pipeline / quit the application from there using Gst.main() and
Gst.quit().

See also use of Gst.main() and Gst.quit(), and use of the scheduler
rather than sleeping at
https://github.com/gstreamer-java/gst1-java-examples/blob/master/BasicPipeline/src/main/java/org/freedesktop/gstreamer/examples/BasicPipeline.java#L70

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

Nick

unread,
Feb 28, 2023, 12:07:48 PM2/28/23
to gstreamer-java

Thanks!

That was all sorts of helpful, the implementation that I am using that worked for me was this:

{

Semaphore gotEOSPlayBin = new Semaphore(1);
Gst.init();

Pipeline pipe = (Pipeline) Gst.parseLaunch( "decklinkvideosrc connection=sdi " + "! videoconvert " + "! videorate " + "! x264enc " + "! mp4mux " + "! filesink location=/xyz.mp4");

pipe.getBus().connect((Bus.EOS) (source) ->
{
gotEOSPlayBin.release();
}

gotEOSPlayBin.drainPermits();
pipe.play();
ThreadTools.sleepSeconds(10);
pipe.sendEvent(new EOSEvent());
gotEOSPlayBin.acquire(1);
pipe.stop();
}

Thanks so much! Works great.
Reply all
Reply to author
Forward
0 new messages