Making a Java InputStream Video Player

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Making a Java InputStream Video Player

Nicolas Castillejos
Hi,

I'm trying to make a Java Video Player that can load a source from a
Java InputStream.
To do this, I'm using the gstreamer-java bindings.
My technique is to make an AppSrc that I put at the start of the
pipeline, then I feed the buffer of the AppSrc with the bytes I read on
the Java InputStream.

My problem is that I can only see the first picture of the video I try
to read ( it's a .m4v file that I use for my tests).
I really don't know what is the problem.

You can find a zip at this address :
http://nicolas.castillejos.free.fr/InputStreamJavaPlayer.zip

It contains :

- the java source code of my InputStreamJavaPlayer that contains a
simple main() method to test it.
- a .m4v file that I use for my test.
- the Debug log file
- the Graph (.png file) of my pipeline.

If somebody could look at it and maybe test it , to see if there is a
problem in my pipeline construction or something, I would be very grateful.

Thank you,

Nicolas Castillejos

*Versions Info :*

GStreamer Version : 1.6.4
Java Binding : latest version (26 April) on
https://github.com/gstreamer-java/gst1-java-core
Java Version : 1.8.0_60
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making a Java InputStream Video Player

Nicolas Castillejos
Ok I've found a solution !

But I don't know why I have to do this to get it work, if you could
explain me, it would be great !
This is the modification I've made to get it Work :

1) setLive(true) on the AppSrc
2) Listen Bus messages : when the Video Bin Element State goes to
GST_STATE_PAUSED , I do a "pipe.pause();" then "pipe.play();"

And the video start !!

For me it looks like a hack ... why do I have to do this ?


Le 01/07/2016 à 14:07, Nicolas Castillejos a écrit :

> Hi,
>
> I'm trying to make a Java Video Player that can load a source from a
> Java InputStream.
> To do this, I'm using the gstreamer-java bindings.
> My technique is to make an AppSrc that I put at the start of the
> pipeline, then I feed the buffer of the AppSrc with the bytes I read
> on the Java InputStream.
>
> My problem is that I can only see the first picture of the video I try
> to read ( it's a .m4v file that I use for my tests).
> I really don't know what is the problem.
>
> You can find a zip at this address :
> http://nicolas.castillejos.free.fr/InputStreamJavaPlayer.zip
>
> It contains :
>
> - the java source code of my InputStreamJavaPlayer that contains a
> simple main() method to test it.
> - a .m4v file that I use for my test.
> - the Debug log file
> - the Graph (.png file) of my pipeline.
>
> If somebody could look at it and maybe test it , to see if there is a
> problem in my pipeline construction or something, I would be very
> grateful.
>
> Thank you,
>
> Nicolas Castillejos
>
> *Versions Info :*
>
> GStreamer Version : 1.6.4
> Java Binding : latest version (26 April) on
> https://github.com/gstreamer-java/gst1-java-core
> Java Version : 1.8.0_60


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Making a Java InputStream Video Player

Enrique Ocaña González
El Viernes, 1 de julio de 2016 16:55:05 Nicolas Castillejos escribió:

> > You can find a zip at this address :
> > http://nicolas.castillejos.free.fr/InputStreamJavaPlayer.zip
>
> 1) setLive(true) on the AppSrc
> 2) Listen Bus messages : when the Video Bin Element State goes to
> GST_STATE_PAUSED , I do a "pipe.pause();" then "pipe.play();"
>
> For me it looks like a hack ... why do I have to do this ?

I don't know much about the peculiarities of gstreamer-java, but there's
something really weird in the code of your zip file: You never call
"Gst.main()"!

GStreamer (and GLib/GObject) are event-driven. This means that the main
program must engage in a loop at some point (the "main loop") and keep looping
there indefinitely. API calls made by your program will change things here and
there. Some changes will trigger events and the main loop will call to the
functions you have defined to attend them (event handlers). At some point, one
of your event handlers will decide to stop the loop and exit, the main loop
will break, and your main program will continue its course.

Gst.main() is the function which enters into the main loop and keeps there
forever. You need to call it, at the very least, after player.play().

I hope it helps.

--
Enrique Ocaña González
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel