Page 1 of 1

Issue with Gstreamer pipeline

Posted: Sun Aug 17, 2014 2:58 am
by nicbaz
Hi All,

I was wondering if anyone can help me with the following pipeline I am having issues with.
I have dabbled with compiling Gstreamer 1.2 on the Pi, but have settled with the pre-built one.

The following pipeline works, but seems to default the framerate to 25 fps, rather than 12, resulting in the video playing too fast!

sudo gst-launch-1.0 multifilesrc location=/var/www/timelapse/1577/frame%05d.jpg index=1 do-timestamp=1 caps="image/jpeg,framerate=40/1" ! progressreport name=Progress: ! jpegdec ! omxh264enc ! h264parse ! mp4mux dts-method=asc presentation-time=1 ! filesink location=/var/www/timelapse/1577/video.mp4

Any help would be greatly appreciated! :)

Thanks

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 08, 2015 11:12 am
by nitschkecm
Hi
have you ever gotten it to work ? If yes can you share how you did it ?

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 08, 2015 12:29 pm
by nicbaz
I have ended up using the following (called in python script).

os.system('sudo gst-launch-1.0 multifilesrc location=' + fulldir + 'frame%06d.jpg index=1 do-timestamp=1 caps="image/jpeg,framerate=40/1" ! progressreport name=Progress: ! jpegdec ! omxh264enc ! h264parse ! mp4mux dts-method=asc presentation-time=1 ! filesink location=' + fulldir + 'video.mp4')

It's not perfect, and depending on the amount of movement, the framerate it out, but it serves the purpose.

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 08, 2015 2:00 pm
by nitschkecm
Hi
I am having problems with the Pipeline and and cannot get it to work correctly. Would you be able / mind to share your working image ? I basically need this to encode video fast for a time-lapse script I have. Happy to share with you.

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 08, 2015 3:20 pm
by jamesh
Note that an H264 file by itself has no frame rate information - it's just a bitstream. So although the camera might be specified at 25 or whatever, I'm not sure that will make it past the H264 encode stage.

So you may need to mux it in to the mp4 container (or similar ) which does have fps information, and provide an fps at that point. IIRC.

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 08, 2015 3:48 pm
by nitschkecm
Hi,

I just ran

Code: Select all

gst-launch-1.0 -e multifilesrc location=image_%04d.jpg ! image/jpeg, framerate=12/1 ! decodebin ! video/x-raw, width=1296, height=976 ! progressreport name=progress ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4  --gst-debug-level=3
and got this result

Code: Select all

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
0:00:00.559496121  2341   0x3d7a00 FIXME                default gstutils.c:3649:gst_pad_create_stream_id_printf_valist:<multifilesrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.638541432  2341   0x3d7a00 WARN            videodecoder gstvideodecoder.c:1993:gst_video_decoder_chain:<jpegdec0> Received buffer without a new-segment. Assuming timestamps start from 0.
0:00:01.239358192  2341   0x3d7a00 WARN                 basesrc gstbasesrc.c:2865:gst_base_src_loop:<multifilesrc0> error: Internal data flow error.
0:00:01.240340183  2341   0x3d7a00 WARN                 basesrc gstbasesrc.c:2865:gst_base_src_loop:<multifilesrc0> error: streaming task paused, reason not-linked (-1)
ERROR: from element /GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2865): gst_base_src_loop (): /GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0:
streaming task paused, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
Does this mean anything ?

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 15, 2015 8:07 pm
by Defiant
Try to decode the pictures with the cpu and only the encoding with omx by replacing "decodebin" with "jpegdec", an additional "videoscale" might be needed if you want to resize the pictures (will cost more cpu time), e.g.:

Code: Select all

gst-launch-1.0 -v multifilesrc location=image_%04d.jpg ! jpegdec ! videoscale ! video/x-raw, width=1296, height=976 ! progressreport name=progress ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4

Re: Issue with Gstreamer pipeline

Posted: Fri Jun 19, 2015 9:45 am
by nitschkecm
Just tried your command on a fresh raspbian install (latest version) after update / upgrade and installing the Gstreamer tools 1.0

Code: Select all

gst-launch-1.0 -v multifilesrc location=image_%04d.jpg ! jpegdec ! videoscale ! video/x-raw, width=1296, height=976 ! progressreport name=progress ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4 --gst-debug-level=4 > log3 2>&1
Attached is the log file. The good news is that it started to do something. The bad news is that it somehow still does not finish.
Thanks for the additional help

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 23, 2015 5:35 pm
by Defiant
Looks like we got an "No corresponding frame found"-error, no idea on that one :(

- Do you have a missing number in between the images?
- Is that an rpi1 or 2?
- What is the cpu load on this? Can you try without the rescale?

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 23, 2015 5:37 pm
by nitschkecm
Hi
i have all images in the series but I will make it a smaller one (just 10 for the try)
it is RPI 1 B+
I will take out the rescale of the command you have provided and will try again. Come back to you !!!

I checked the files and there was a problem with one missing in between. I took a new series now of 290 pics (filelist included in archive)
It starts to work and creates an mp4 file of 975k. Then it breaks log file included. When I removed the resize it did have a problem directly. I can run it happily without the resize comment if you like / need.

When I manually stop the process I get the following error message

Code: Select all

^Chandling interrupt.
Interrupt: Stopping pipeline ...

(gst-launch-1.0:2448): GLib-CRITICAL **: Source ID 32 was not found when attempting to remove it
Execution ended after 0:01:41.902761490
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Thanks a lot !

Re: Issue with Gstreamer pipeline

Posted: Sun Jun 28, 2015 8:21 am
by Defiant
Well the documentation for multifilesrc mentions to add the framerate in the caps, which sounds like a real logic thing to do, so lets try this:

Code: Select all

gst-launch-1.0 -v multifilesrc location=image_%04d.jpg do-timestamp=true caps="image/jpeg,framerate=\(fraction\)20/1" ! jpegdec ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4
I've also enabled the timestamp option and split the decoding from the encoding with the queue element.

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 29, 2015 7:15 am
by nitschkecm
Hi

thanks again for the support on this. However the result was not positive of this latest try

running the mentioned command results in

Code: Select all

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0.GstPad:src: caps = image/jpeg, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:sink: caps = image/jpeg, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
and there it stops

Re: Issue with Gstreamer pipeline

Posted: Mon Jun 29, 2015 8:04 pm
by Defiant
uhm this doesn't look like the complete output?

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 30, 2015 6:18 am
by nitschkecm
I re-ran the test. First with Image series from image_0000.jpg to image_0009.jpg

the output stopped for more than 5 minutes just before the "^Chandling interrupt."
gst-launch-1.0 -v multifilesrc location=image_%04d.jpg do-timestamp=true caps="image/jpeg,framerate=\(fraction\)20/1" ! jpegdec ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0.GstPad:src: caps = image/jpeg, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:sink: caps = image/jpeg, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)2592, height=(int)1978, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
^Chandling interrupt.
Interrupt: Stopping pipeline ...

(gst-launch-1.0:2430): GLib-CRITICAL **: Source ID 1 was not found when attempting to remove it
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
^C

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 30, 2015 5:19 pm
by Defiant
Can you upload the 10 images somewhere?

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 30, 2015 8:16 pm
by nitschkecm

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 30, 2015 10:46 pm
by Defiant
ah fun, well lets re-add the rescale command...

Code: Select all

gst-launch-1.0 -v multifilesrc location=image_%04d.jpg do-timestamp=true caps="image/jpeg,framerate=\(fraction\)20/1" ! jpegdec ! queue ! videoscale ! video/x-raw, width=1296, height=976 ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4

Re: Issue with Gstreamer pipeline

Posted: Wed Jul 01, 2015 8:47 am
by nitschkecm
What I did:
- I took a new set of pictures since I made some changes to my timelapse.
Pictures are attached here https://www.dropbox.com/s/82xhi900uccjj ... e.zip?dl=0
then I ran your command an the good news is that it worked (finished) and produced a video file
The log is here https://www.dropbox.com/s/p8ylgnsuuq2zcld/log3?dl=0
and the Video is here https://www.dropbox.com/s/239i3e9fo8xzjxb/test.mp4?dl=0

Interesting enough if I reproduce the Video with QT player (on a mac) I see something different than I see with VLC on the same mac..
Is not really a fluent video but we have gone a step further. I would like to see:
- is there a a way to make the video more fluent ?
- why does it behave different depending on the player ?
- Would it work with a large imageset ?

Many thanks !!! We have moved !

Edit:
I have just tried to do the "fireprobe" and took 1056 files into a new directory all are named correctly and started the above command. It starts to work but stops

Code: Select all

gst-launch-1.0 -v multifilesrc location=image_%04d.jpg do-timestamp=true caps="image/jpeg,framerate=\(fraction\)20/1" ! jpegdec ! queue ! videoscale ! video/x-raw, width=1296, height=976 ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=test.mp4
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0.GstPad:src: caps = image/jpeg, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:sink: caps = image/jpeg, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)1920, height=(int)1106, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)1920, height=(int)1106, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)1920, height=(int)1106, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstVideoScale:videoscale0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstQueue:queue1.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstVideoScale:videoscale0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)1920, height=(int)1106, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)1:4:0:0, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstOMXH264Enc-omxh264enc:omxh264enc-omxh264enc0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)high, level=(string)4, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter1.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)high, level=(string)4, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)high, level=(string)4, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter1.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)high, level=(string)4, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, framerate=(fraction)20/1
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, profile=(string)high, level=(string)4, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, framerate=(fraction)20/1, parsed=(boolean)true, codec_data=(buffer)01640028ffe1000e27640028ac2b402883dd00f1226a01000528ee025cb0
/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:video_0: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, profile=(string)high, level=(string)4, width=(int)1296, height=(int)976, pixel-aspect-ratio=(fraction)19520/14931, framerate=(fraction)20/1, parsed=(boolean)true, codec_data=(buffer)01640028ffe1000e27640028ac2b402883dd00f1226a01000528ee025cb0
/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps = video/quicktime, variant=(string)iso
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/quicktime, variant=(string)iso
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
when I interrupt with ctrl-c I get

Code: Select all

^Chandling interrupt.
Interrupt: Stopping pipeline ...

(gst-launch-1.0:2482): GLib-CRITICAL **: Source ID 38 was not found when attempting to remove it
Execution ended after 0:01:58.084503046
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Re: Issue with Gstreamer pipeline

Posted: Fri Jul 03, 2015 10:18 am
by nitschkecm
I have checked my images and there was a mistake in the way I renamed them. Problem solved and now I can encode rather fast the video of 852 pictures (that is the test I have made).

The only issue I have left is that the video seems to be stuttering and if I would apply the logic of 25fps than I should have a video of 24 seconds however it is almost 10 minutes long. Which Parameter do I need to change in order o fix this last issue ?

Many thanks in advance !

Re: Issue with Gstreamer pipeline

Posted: Fri Jul 03, 2015 6:34 pm
by Defiant
Can you try without the "do-timestamp" option?

Re: Issue with Gstreamer pipeline

Posted: Sat Jul 04, 2015 9:51 am
by nitschkecm
That did it !!!! Many thanks !!!!!!!!
;) ;) ;) ;)
last question what is the impact does the target-bitrate have ?

Re: Issue with Gstreamer pipeline

Posted: Tue Jun 07, 2016 9:40 am
by nitschkecm
Hello again,

after several month of working like a charm, I have now a new problem. Probably it is not directly related to the Streamer app but...
I still create my video but when I upload to youtube I have the following anomalies.
The video takes ages to process
Youtube shows me that the video is like 39 minutes long whilst when I play it on my mac with VLC it is 1 minute and 2 seconds. I guess there is something wrong with the format, but I am not sure where to look for.
I love the Gstreamer since it is really fast, for the moment I have reverted back to mencoder (really slow). If anybody has a good idea I would be very happy to listen!

My GST command looks like this

Code: Select all

gst-launch-1.0 -v multifilesrc location=image_%04d.jpg caps="image/jpeg,framerate=\(fraction\)30/1" ! jpegdec ! queue ! videoscale ! video/x-raw, width=1296, height=976 ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=todays_video.mp4