cannot play mp4 file

1,046 views
Skip to first unread message

Farshid Bakhtyari

unread,
Apr 14, 2018, 3:15:19 AM4/14/18
to gstreamer-java
Hello All,

I am using the following:

Bin bin = Bin.launch("tee name=t t. ! queue ! videoconvert ! autovideosink "

           + "t. ! queue ! videoconvert ! videoscale ! capsfilter caps=video/x-raw,width=640,height=480 ! appsink name=appsink "

                + "t. ! queue !  videoconvert ! avenc_mpeg4 ! mp4mux  ! filesink location=./farshids2.mp4 "   , true);




I am currently updating the MultiSinkExample.java that came with the package. 

I am trying to display and at the same time save the video by using the above "bin." I can display the source which is an IP camera. 

I do get the farshid2.mp4 with some volume created. The file size is some where between 2 to 5 meg but then I cannot play it (via QuickTime). I tried on VLC as well, nothing.



Any idea?


Thanks,

Farshid

Farshid Bakhtyari

unread,
Apr 16, 2018, 10:45:50 AM4/16/18
to gstreamer-java
 Can someone help me here? I would greatly appreciate the help.

Thanks,
Farshid

Bob F

unread,
Apr 16, 2018, 11:37:06 AM4/16/18
to gstream...@googlegroups.com
The first thing I can think of is that MP4 files can not be played without an moov atom, and you can't compute the moov atom until you have all of the video and audio samples (unless you are using moof fragments instead of moovs).  Are you sure you closed all the streams and made them finish writing all the mp4 atoms?  I'm not actually sure what API calls do this.

Farshid Bakhtyari

unread,
Apr 16, 2018, 11:47:29 AM4/16/18
to gstream...@googlegroups.com
Thanks for your response. I am not really tied up to any specific format (MP4 or else), I just want to save the video (any format, and the least amount of storage space should be fine). Meanwhile, I will look at the moovs and moof fragments.  If you have ideas on saving with other format, I am all ears, and would like to hear your suggestions.  Thanks, Farshid


On Mon, Apr 16, 2018 at 11:37 AM, Bob F <thot...@gmail.com> wrote:
The first thing I can think of is that MP4 files can not be played without an moov atom, and you can't compute the moov atom until you have all of the video and audio samples (unless you are using moof fragments instead of moovs).  Are you sure you closed all the streams and made them finish writing all the mp4 atoms?  I'm not actually sure what API calls do this.

--
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-java+unsubscribe@googlegroups.com.
To post to this group, send email to gstreamer-java@googlegroups.com.
Visit this group at https://groups.google.com/group/gstreamer-java.
For more options, visit https://groups.google.com/d/optout.

Stuart Marshall

unread,
Apr 16, 2018, 11:48:37 AM4/16/18
to gstream...@googlegroups.com
When using get-launch the -e argument tells it to close the file on shutdown. This probably works with bin.launch too.

Stuart

To unsubscribe from this group and stop receiving emails from it, send an email to gstreamer-jav...@googlegroups.com.
To post to this group, send email to gstream...@googlegroups.com.

Bob F

unread,
Apr 16, 2018, 11:54:07 AM4/16/18
to gstream...@googlegroups.com
MPEG transport streams are a streaming format used in cable TV and many other situations.  It is possible to play media from transport stream before all of the frames have been written.  I think the gstreamer element is called "mpegtsmux" .

On Mon, Apr 16, 2018 at 11:48 AM, Stuart Marshall <stu...@seelye.net> wrote:
When using get-launch the -e argument tells it to close the file on shutdown. This probably works with bin.launch too.

Stuart

On Apr 16, 2018, at 8:47 AM, Farshid Bakhtyari <farsh...@gmail.com> wrote:

Thanks for your response. I am not really tied up to any specific format (MP4 or else), I just want to save the video (any format, and the least amount of storage space should be fine). Meanwhile, I will look at the moovs and moof fragments.  If you have ideas on saving with other format, I am all ears, and would like to hear your suggestions.  Thanks, Farshid

On Mon, Apr 16, 2018 at 11:37 AM, Bob F <thot...@gmail.com> wrote:
The first thing I can think of is that MP4 files can not be played without an moov atom, and you can't compute the moov atom until you have all of the video and audio samples (unless you are using moof fragments instead of moovs).  Are you sure you closed all the streams and made them finish writing all the mp4 atoms?  I'm not actually sure what API calls do this.


--
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-java+unsubscribe@googlegroups.com.
To post to this group, send email to gstream...@googlegroups.com.
Visit this group at https://groups.google.com/group/gstreamer-java.
For more options, visit https://groups.google.com/d/optout.
--
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-java+unsubscribe@googlegroups.com.
To post to this group, send email to gstreamer-java@googlegroups.com.
Visit this group at https://groups.google.com/group/gstreamer-java.
For more options, visit https://groups.google.com/d/optout.

Farshid Bakhtyari

unread,
Apr 16, 2018, 12:18:23 PM4/16/18
to gstreamer-java
Tried to use the "-e" in the following bin :

 Bin bin = Bin.launch("tee name=t t. ! queue ! videoconvert ! autovideosink "

           + "t. ! queue ! videoconvert ! videoscale ! capsfilter caps=video/x-raw,width=640,height=480 ! appsink name=appsink "

                + "t.   ! queue ! videoconvert ! avenc_mpeg4 ! mp4mux  ! filesink location=./farshids2.mp4 "   , true);

I kept getting syntax error. 
 Any suggestion on where I should introduce the "-e"  on the bin object?

Thanks, 


On Saturday, April 14, 2018 at 3:15:19 AM UTC-4, Farshid Bakhtyari wrote:

Neil C Smith

unread,
Apr 16, 2018, 12:30:37 PM4/16/18
to gstream...@googlegroups.com
On Mon, 16 Apr 2018 at 17:18 Farshid Bakhtyari <farsh...@gmail.com> wrote:
Tried to use the "-e" in the following bin :

 Bin bin = Bin.launch("tee name=t t. ! queue ! videoconvert ! autovideosink "

           + "t. ! queue ! videoconvert ! videoscale ! capsfilter caps=video/x-raw,width=640,height=480 ! appsink name=appsink "

                + "t.   ! queue ! videoconvert ! avenc_mpeg4 ! mp4mux  ! filesink location=./farshids2.mp4 "   , true);

I kept getting syntax error. 
 Any suggestion on where I should introduce the "-e"  on the bin object?

You can't, although make sure you stop the pipeline cleanly before exiting.

And there might also be issues with using Bin for this.  I'd start with something using Pipeline launch to get a whole top level pipeline going first.  Maybe build up from replicating something like the example pipeline at https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good/html/gst-plugins-good-plugins-mp4mux.html

Best wishes,

Neil
--
Neil C Smith
Artist & Technologist

Praxis LIVE - hybrid visual IDE for creative coding - www.praxislive.org

Farshid Bakhtyari

unread,
Apr 16, 2018, 1:48:35 PM4/16/18
to gstreamer-java
Here is my result from executing teh following command line command :

 gst-launch-1.0 v4l2src device=/dev/video0  num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4

WARNING: erroneous pipeline: no element "v4l2src"



I get teh error message "no element "v4l2src"

What am I missing?

On Saturday, April 14, 2018 at 3:15:19 AM UTC-4, Farshid Bakhtyari wrote:

Neil C Smith

unread,
Apr 16, 2018, 1:57:46 PM4/16/18
to gstream...@googlegroups.com
On Mon, 16 Apr 2018 at 18:48 Farshid Bakhtyari <farsh...@gmail.com> wrote:
Here is my result from executing teh following command line command :

 gst-launch-1.0 v4l2src device=/dev/video0  num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4

WARNING: erroneous pipeline: no element "v4l2src"



I get teh error message "no element "v4l2src"

Sorry, should have said if you're not on Linux, switch that to autovideosrc.

And once you have gst-launch-1.0  working (possibly with the -e as mentioned earlier) then use that in Pipeline.launch(..)

Best wishes,

Neil

Farshid Bakhtyari

unread,
Apr 16, 2018, 3:39:24 PM4/16/18
to gstreamer-java
Thanks for your suggestions and support. I made some progress but something is not kosher on the Mac Installation of gstreamer. 

Here is what I did:

I issue the following, using, the gst-launch-1.0 and it worked fine with the "-e" flag.  Note I used the gst-launch-1.0 one that is located in the "Library" folder (some where under there)


/Library/Frameworks/GStreamer.framework/Commands/gst-launch-1.0 -e autovideosrc  num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4   

 

 It worked fine and I was able to play mp4 file.

 

 

 Then I tried to the following:


sudo gst-launch-1.0  autovideosrc  num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4

WARNING: erroneous pipeline: no element "x264enc"

 

Then I did  "which gst-launch-1.0". it seams that the get-launch-1.0 is at different place

Farshid-MacBook-Pro:/ farshid$ which gst-launch-1.0

/usr/local/bin/gst-launch-1.0

Farshid- -MacBook-Pro:/ farshid$ ls -al /usr/local/bin/gst-launch-1.0

lrwxr-xr-x  1 farshid  admin  47 Mar 21 15:55 /usr/local/bin/gst-launch-1.0 -> ../Cellar/gstreamer/1.14.0_1/bin/gst-launch-1.0




/usr/local/bin/gst-launch-1.0  --version

gst-launch-1.0 version 1.14.0

GStreamer 1.14.0

Unknown package origin


Is this normal? "Unknown Package Origin"







On Saturday, April 14, 2018 at 3:15:19 AM UTC-4, Farshid Bakhtyari wrote:

Neil C Smith

unread,
Apr 17, 2018, 4:37:16 AM4/17/18
to gstream...@googlegroups.com
On Mon, 16 Apr 2018 at 20:39 Farshid Bakhtyari <farsh...@gmail.com> wrote:
Thanks for your suggestions and support. I made some progress but something is not kosher on the Mac Installation of gstreamer.
...

/Library/Frameworks/GStreamer.framework/Commands/gst-launch-1.0 -e autovideosrc num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4
...

sudo gst-launch-1.0 autovideosrc num-buffers=50 ! queue ! x264enc ! mp4mux ! filesink location=video.mp4
...

Farshid-MacBook-Pro:/ farshid$ which gst-launch-1.0
/usr/local/bin/gst-launch-1.0

At a guess have you installed GStreamer from both the upstream project and something like homebrew?  It looks like you may have two installations.

Using sudo for gst-launch seems really strange, but I use my Mac as little as possible for testing, so maybe I'm missing some reason why you'd do this?! :-\

Best wishes,

Neil

Farshid Bakhtyari

unread,
Apr 17, 2018, 6:32:00 AM4/17/18
to gstreamer-java
The reason being is that all the installed files have the "Admin" permission.  

One more question, how can I add the "-e" flag/option to a pipeline as you suggested.


On Saturday, April 14, 2018 at 3:15:19 AM UTC-4, Farshid Bakhtyari wrote:

Neil C Smith

unread,
Apr 17, 2018, 9:30:15 AM4/17/18
to gstream...@googlegroups.com
On Tue, 17 Apr 2018 at 11:32 Farshid Bakhtyari <farsh...@gmail.com> wrote:
The reason being is that all the installed files have the "Admin" permission. 

Like I said, have you installed GStreamer from two different places?  Next time I'm testing on the Mac I'll have a look, but I think you should only have GStreamer under the /Library/Frameworks location.  And to get this to work with the Java bindings you'll need to set jna.library.path to include /Library/Frameworks/GStreamer.framework/Libraries/

If you're not setting jna.library.path and it's partly working, that might explain some of the issues you're seeing.

One more question, how can I add the "-e" flag/option to a pipeline as you suggested.

You can't!  You need to replicate what that flag does.  Which as far as I can tell means shutting down the pipeline cleanly before exiting?

So, if the pipeline hasn't stopped -

pipeline.stop();
pipeline.getState();

before exiting should work I think?

There's also an example that I haven't yet pulled in that might be useful to look at - https://github.com/gstreamer-java/gst1-java-examples/pull/8/files

Best wishes,

Neil

Farshid Bakhtyari

unread,
Apr 17, 2018, 10:19:00 AM4/17/18
to gstreamer-java

ThanksNeil. 

I truly appreciate your patience and support. I removed the  brew version of install on my machine. I tried to run the sample program and I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load library: gstreamer

at org.freedesktop.gstreamer.lowlevel.GstNative.load(GstNative.java:56)

at org.freedesktop.gstreamer.lowlevel.GstNative.load(GstNative.java:46)

at org.freedesktop.gstreamer.lowlevel.GstAPI.<clinit>(GstAPI.java:36)

at org.freedesktop.gstreamer.Gst.init(Gst.java:295)

at org.freedesktop.gstreamer.Gst.init(Gst.java:262)

at org.freedesktop.gstreamer.examples.MultiSinkExample.main(MultiSinkExample.java:50)

 I know I read somewhere I have to set the jan library path, am I right? 

I am running in my Eclipse IDE installed on Mac OS. 

Thanks,
Farshid


On Saturday, April 14, 2018 at 3:15:19 AM UTC-4, Farshid Bakhtyari wrote:

Farshid Bakhtyari

unread,
Apr 17, 2018, 10:30:58 AM4/17/18
to gstreamer-java

Please ignore my last comment. I have the jna path link set up. My apologies.

Thanks a lot for your help.

Take care,
Farshid
On Saturday, April 14, 2018 at 3:15:19 AM UTC-4, Farshid Bakhtyari wrote:
Reply all
Reply to author
Forward
0 new messages