How to decode a still-image bitstream in MS bitmap format?

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

How to decode a still-image bitstream in MS bitmap format?

Zhou Weidong
Hello, All

I am a software engineer from NXElec and working in a project with bitstream in MS bitmap format.

Our target board receives a bitmap bitstream from USB port and we want to use gstreamer/decodebin3 to decode it.  The problem/issue we currently facing is that decodebin3 hang when the bitstream sent from the USB Host, and the log messages:
----------------------------------------------------------------------------------------------------
0:00:21.624243669  1105 0x73301c90 DEBUG             decodebin3 gstdecodebin3.c:1421:multiqueue_src_probe:<multiqueue0:src_0> Got event 0x733026b0 stream-start​
0:00:21.624541002  1105 0x73301c90 DEBUG             decodebin3 gstdecodebin3.c:1435:multiqueue_src_probe:<multiqueue0:src_0> Stream Start 'ce2a59a63435545d216d8dd3bf664d90b820d2e142b9991a4302ac38f839713f'​
0:00:21.629673335  1105 0x73301c90 DEBUG             decodebin3 gstdecodebin3.c:1421:multiqueue_src_probe:<multiqueue0:src_0> Got event 0x7f0ee8 segment​
0:00:21.630191002  1105 0x73301c90 DEBUG             decodebin3 gstdecodebin3.c:1421:multiqueue_src_probe:<multiqueue0:src_0> Got event 0x733025d8 stream-collection​
0:00:21.630709002  1105 0x73301c90 DEBUG             decodebin3 gstdecodebin3.c:1758:keyframe_waiter_probe:<multiqueue0:src_0> Buffer is keyframe or header, letting through and removing probe​
0:00:21.646895335  1105   0x9508f0 DEBUG             decodebin3 gstdecodebin3-parse.c:285:parse_chain_output_probe:<parsebin0:src_0> Seeing query allocation
-----------------------------------------------------------------------------------------------------

To compare with a similar situation, we save  an unique still image to a bitmap file and use gstreamer filesrc to decode it. 
This time, decode success. The log messages as below:
-----------------------------------------------------------------------------------------------------
42334   963  0x1e728f0 DEBUG             decodebin3 gstdecodebin3-parse.c:206:parse_chain_output_probe:<parsebin0:src_0> Got event segment
0:00:00.995926000   963  0x1e728f0 DEBUG             decodebin3 gstdecodebin3-parse.c:206:parse_chain_output_probe:<parsebin0:src_0> Got event stream-collection​
0:00:00.996847334   963  0x1e728f0 DEBUG             decodebin3 gstdecodebin3-parse.c:285:parse_chain_output_probe:<parsebin0:src_0> Seeing query allocation​
0:00:00.663242333   963 0x73201c90 DEBUG             decodebin3 gstdecodebin3.c:1215:gst_decodebin3_handle_message:<decodebin3-0> Got Message stream-status​
0:00:00.998781334   963 0x73201c90 DEBUG             decodebin3 gstdecodebin3.c:1421:multiqueue_src_probe:<multiqueue0:src_0> Got event 0x73202620 stream-start​
0:00:00.999220000   963 0x73201c90 DEBUG             decodebin3 gstdecodebin3.c:1435:multiqueue_src_probe:<multiqueue0:src_0> Stream Start 'ce2a59a63435545d216d8dd3bf664d90b820d2e142b9991a4302ac38f839713f'​
0:00:00.999591667   963 0x73201c90 DEBUG             decodebin3 gstdecodebin3.c:1421:multiqueue_src_probe:<multiqueue0:src_0> Got event 0x732026b0 stream-start​
0:00:00.999895667   963 0x73201c90 DEBUG             decodebin3 gstdecodebin3.c:1435:multiqueue_src_probe:<multiqueue0:src_0> Stream Start 'ce2a59a63435545d216d8dd3bf664d90b820d2e142b9991a4302ac38f839713f'​
0:00:01.000341334   963 0x73201c90 DEBUG             decodebin3 gstdecodebin3.c:1421:multiqueue_src_probe:<multiqueue0:src_0> Got event 0x1d12f30 caps
---------------------------------------------------------------------------------------------------- 

I noticed the difference between 2 scenarios is that decodebin3 detects an EOS signal when it read from a bitmap file. And in USB device mode, there is no EOS signal detecting and this leads decodebin3 hang...

So the question is how can we use decodebin3 to decode a bitmap bitstream? 
Bitmap bitstream here means a bitstream that contents consequent still images in MS Bitmap format. Currently we send this bitmap stream from Windows Host, I guess add some tags/delimiters among images in bitstream will let decodebin3 recognize and decode it properly. But I do not know how.

Thanks in advance if any suggestions/clues come. The current gstreamer/decodebin3 version we are using is 1.10.4.

Regards
Weidong
www.nxelec.com


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

Re: How to decode a still-image bitstream in MS bitmap format?

Antonio Ospite-2
On Sat, 5 Jan 2019 05:00:07 +0000
Zhou Weidong <[hidden email]> wrote:

> Hello, All
>
> I am a software engineer from NXElec and working in a project with
> bitstream in MS bitmap format.
>
> Our target board receives a bitmap bitstream from USB port and we want
> to use gstreamer/decodebin3 to decode it.  The problem/issue we
> currently facing is that decodebin3 hang when the bitstream sent from
> the USB Host, and the log messages:
[...]

I tried to simulate a test without involving USB:

$ gst-launch-1.0 videotestsrc pattern=ball num-buffers=100 !  avenc_bmp ! filesink location=multi_bmp.bin

And tried to decode multi_bmp.bin:

$ gst-launch-1.0 -e filesrc location=multi_bmp.bin ! typefind ! avdec_bmp ! videoconvert ! autovideosink

This fails (even for a single frame tho), because avdec_bmp does not get
the full frame:

ERROR libav :0:: not enough data (4096 < 307254), trying to decode anyway
ERROR   libav :0:: not enough data (4042 < 307200)

Using multifilesrc would work for a single file, but not for multiple
BMPs.

I used avdec_bmp because using decodebin3 (which picks up gdkpixbufdec)
did not work well for me with autovideosink.

> To compare with a similar situation, we save  an unique still image to
> a bitmap file and use gstreamer filesrc to decode it.  This time,
> decode success. The log messages as below:
[...]

> I noticed the difference between 2 scenarios is that decodebin3
> detects an EOS signal when it read from a bitmap file. And in USB
> device mode, there is no EOS signal detecting and this leads
> decodebin3 hang...
>

When loading a single frame you can pass it all at once to the decoder
and it will know how to decode it, I think the EOS marks the end of the
frame buffer in your second test.

When sending multiple frames without a container you need something to
tell when one frame ends or, I guess depending on the decoder, to pass
single full frames one by one to the decoder.

This is the job of a "parser" element in GStreamer.

> So the question is how can we use decodebin3 to decode a bitmap
> bitstream?  Bitmap bitstream here means a bitstream that contents
> consequent still images in MS Bitmap format. Currently we send this
> bitmap stream from Windows Host, I guess add some tags/delimiters
> among images in bitstream will let decodebin3 recognize and decode it
> properly. But I do not know how.
>

A possible solution is to write a bmpparse element to split the
bitstream into single frames:

$ gst-launch-1.0 -e filesrc location=multi_bmp.bin ! bmpparse ! avdec_bmp ! videoconvert ! autovideosink

I hacked up a proof-of-concept with an hardcoded buffer size in pyhton
and it seems to do the job.

> Thanks in advance if any suggestions/clues come. The current
> gstreamer/decodebin3 version we are using is 1.10.4.
>

Try to use the latest stable version if possible.

Ciao,
   Antonio

--
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

答复: How to decode a still-image bitstream in MS bitmap format?

Zhou Weidong
Ciao, Antonio

Thanks for efforts to explain more clear of my perspectives. 

Per your test results, does that mean gstreamer can produce a bitmap stream file through a video stream, but it does not have capability vice visa?
 ******test success*********
$ gst-launch-1.0 videotestsrc pattern=ball num-buffers=100 !  avenc_bmp ! filesink location=multi_bmp.bin
*****test fail*********
$ gst-launch-1.0 -e filesrc location=multi_bmp.bin ! typefind ! avdec_bmp ! videoconvert ! autovideosink

Should I have to implement a customized parser to de-mux the unique frame and deliver it to downstream from a still-image bitstream?
like:
$ cat /dev/myusbdev | gst-launch-1.0  fdsrc ! still-image-parse ! decodebin3 ! videoconvert ! fbdevsink
or can I directly write a C callback function to do the de-mux and delivery the frame to appsrc through g_signal_connect()?

I am new to gstreamer world and would like to find a solution with less efforts to dig into gstreamer hierarchy.

Thanks again for your instructions.
Weidong
www.nxelec.com



发件人: Antonio Ospite <[hidden email]>
发送时间: 2019年1月8日 0:36
收件人: [hidden email]
抄送: Zhou Weidong
主题: Re: How to decode a still-image bitstream in MS bitmap format?
 
On Sat, 5 Jan 2019 05:00:07 +0000
Zhou Weidong <[hidden email]> wrote:

> Hello, All
>
> I am a software engineer from NXElec and working in a project with
> bitstream in MS bitmap format.
>
> Our target board receives a bitmap bitstream from USB port and we want
> to use gstreamer/decodebin3 to decode it.  The problem/issue we
> currently facing is that decodebin3 hang when the bitstream sent from
> the USB Host, and the log messages:
[...]

I tried to simulate a test without involving USB:

$ gst-launch-1.0 videotestsrc pattern=ball num-buffers=100 !  avenc_bmp ! filesink location=multi_bmp.bin

And tried to decode multi_bmp.bin:

$ gst-launch-1.0 -e filesrc location=multi_bmp.bin ! typefind ! avdec_bmp ! videoconvert ! autovideosink

This fails (even for a single frame tho), because avdec_bmp does not get
the full frame:

ERROR   libav :0:: not enough data (4096 < 307254), trying to decode anyway
ERROR   libav :0:: not enough data (4042 < 307200)

Using multifilesrc would work for a single file, but not for multiple
BMPs.

I used avdec_bmp because using decodebin3 (which picks up gdkpixbufdec)
did not work well for me with autovideosink.

> To compare with a similar situation, we save  an unique still image to
> a bitmap file and use gstreamer filesrc to decode it.  This time,
> decode success. The log messages as below:
[...]

> I noticed the difference between 2 scenarios is that decodebin3
> detects an EOS signal when it read from a bitmap file. And in USB
> device mode, there is no EOS signal detecting and this leads
> decodebin3 hang...
>

When loading a single frame you can pass it all at once to the decoder
and it will know how to decode it, I think the EOS marks the end of the
frame buffer in your second test.

When sending multiple frames without a container you need something to
tell when one frame ends or, I guess depending on the decoder, to pass
single full frames one by one to the decoder.

This is the job of a "parser" element in GStreamer.

> So the question is how can we use decodebin3 to decode a bitmap
> bitstream?  Bitmap bitstream here means a bitstream that contents
> consequent still images in MS Bitmap format. Currently we send this
> bitmap stream from Windows Host, I guess add some tags/delimiters
> among images in bitstream will let decodebin3 recognize and decode it
> properly. But I do not know how.
>

A possible solution is to write a bmpparse element to split the
bitstream into single frames:

$ gst-launch-1.0 -e filesrc location=multi_bmp.bin ! bmpparse ! avdec_bmp ! videoconvert ! autovideosink

I hacked up a proof-of-concept with an hardcoded buffer size in pyhton
and it seems to do the job.

> Thanks in advance if any suggestions/clues come. The current
> gstreamer/decodebin3 version we are using is 1.10.4.
>

Try to use the latest stable version if possible.

Ciao,
   Antonio

--
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel