gstreamer recording to file problem

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

gstreamer recording to file problem

xargon
I have a gstreamer pipeline which works perfectly and takes a camera stream, encodes it as H.264 video, saves it to a file AND displays it on the screen as follows:

gst-launch-1.0 -v autovideosrc ! tee name = t ! queue ! omxh264enc !
'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux !
filesink location=test.mp4 t. ! queue ! videoscale ! video/x-raw,
width=480,height=270 ! xvimagesink -e sync=false

Now, I am trying to do something even simple and just record the stream to a file (without displaying on screen) and this does not seem to work! It writes a file but the file is unplayable. What I have tried so far is:

gst-launch-1.0 -v autovideosrc ! queue ! omxh264enc ! 'video/x-h264,
stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink
location=test.mp4 sync=false

I can also remove the queue element but with the same result:

gst-launch-1.0 -v autovideosrc ! omxh264enc ! 'video/x-h264,
stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink
location=test.mp4 sync=false

They do not output any errors but just does not write a valid stream to my filesink, it seems.


Reply | Threaded
Open this post in threaded view
|

Re: gstreamer recording to file problem

Arjen Veenhuizen
When running gst-launch-1.0, it does not properly force an EOS on the bus before shutting down. Since the MP4 container requires an index (the MOOV atom, see: http://www.adobe.com/devnet/video/articles/mp4_movie_atom.html) and mp4mux only writes this index after receiving an EOS, you will write an invalid mp4 to disk when no EOS is detected. You can fix this by adding -e to your command line, e.g.:

gst-launch-1.0 -e -v autovideosrc ! queue ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 sync=false 

This will send an EOS on the pipeline just before shutting down.
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer recording to file problem

xargon
That was it! Thanks. I was trying so many things. I completely missed that the -e flag is missing.

Thank you!