i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

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

i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

Gerbaum
Hi,

I'm using an i.MX6 quad on a Gateworks board.

My problem is, that I try to get a MPJEG stream from a USB camera, decode
it, encode it to h264 and set up RTSP Server on Top
What's the best way to do it? RAW stream from USB camera would work, but
cause of USB limitiation the fps (3) at 1080p is too low.

My ideas:


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! v4l2jpegdec !  fakesink*
Working with low CPU load


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! v4l2jpegdec !
v4l2h264enc ! fakesink*
ERROR           v4l2videodec
gstv4l2videodec.c:751:gst_v4l2_video_dec_handle_frame:<v4l2jpegdec0> not
negotiated
I guess that's because V4l2h264enc needs NV12


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  v4l2convert !  fakesink*
Works, low CPU and no lost frames


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  v4l2convert !
video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,colorimetry=bt709
! v4l2h264enc ! fakesink*
ERROR         v4l2bufferpool
gstv4l2bufferpool.c:909:gst_v4l2_buffer_pool_start:<v4l2h264enc0:pool:src>
we received 1 buffer from device '/dev/video8', we want at least 2
ERROR             bufferpool
gstbufferpool.c:559:gst_buffer_pool_set_active:<v4l2h264enc0:pool:src> start
failed
Maybe I'm using too much of my Coda960 pipes?


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  videoconvert !  x264enc ! fakesink*
Works, but maxes out CPU and loses too much frames


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  v4l2convert !  x264enc ! fakesink*
Work, but again way and too much CPU and lost frames

Any idea? Running Kernel 5.4 Gstreamer 1.16.

Is it possible to V4l2jpegdec to NV12? So I could skip v4l2convert...

What's the best way to limit FPS? Maybe I could work with 15 fps...

Thx




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

Re: i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

Nicolas Dufresne-5


Le mar. 5 janv. 2021 08 h 00, Gerbaum <[hidden email]> a écrit :
Hi,

I'm using an i.MX6 quad on a Gateworks board.

My problem is, that I try to get a MPJEG stream from a USB camera, decode
it, encode it to h264 and set up RTSP Server on Top
What's the best way to do it? RAW stream from USB camera would work, but
cause of USB limitiation the fps (3) at 1080p is too low.

My ideas:


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! v4l2jpegdec !  fakesink*
Working with low CPU load


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! v4l2jpegdec !
v4l2h264enc ! fakesink*
ERROR           v4l2videodec
gstv4l2videodec.c:751:gst_v4l2_video_dec_handle_frame:<v4l2jpegdec0> not
negotiated
I guess that's because V4l2h264enc needs NV12


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  v4l2convert !  fakesink*
Works, low CPU and no lost frames


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  v4l2convert !
video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,colorimetry=bt709
! v4l2h264enc ! fakesink*
ERROR         v4l2bufferpool
gstv4l2bufferpool.c:909:gst_v4l2_buffer_pool_start:<v4l2h264enc0:pool:src>
we received 1 buffer from device '/dev/video8', we want at least 2
ERROR             bufferpool
gstbufferpool.c:559:gst_buffer_pool_set_active:<v4l2h264enc0:pool:src> start
failed
Maybe I'm using too much of my Coda960 pipes?

Does v4l2h264enc works at all ? Note that you can play with io-modes to try and get zero-copy, but in 1.16 you aren't guaranteed to get good image when it works.



*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  videoconvert !  x264enc ! fakesink*

Try to add tune=zerolatency to x264enc, the default encoding configuration is very expensive.

Works, but maxes out CPU and loses too much frames


*gst-launch-1.0 v4l2src -v device=/dev/video13 !
image/jpeg,width=1920,height=1080,framerate=30/1,colorimetry=bt709 !
v4l2jpegdec !  v4l2convert !  x264enc ! fakesink*
Work, but again way and too much CPU and lost frames

Any idea? Running Kernel 5.4 Gstreamer 1.16.

Is it possible to V4l2jpegdec to NV12? So I could skip v4l2convert...

What's the best way to limit FPS? Maybe I could work with 15 fps...

Thx




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

Gerbaum
Thanks for your help.

v4l2h264enc works.

gst-launch-1.0 -v v4l2src device=/dev/video4 !
video/x-raw,format=YUY2,width=1920,height=1080,framerate=6/1 ! videoconvert
!  v4l2h264enc ! fakesink

But gives my 6 Fps, thats the maximum of my USB camera, which is too low.


I tried to limit fps:

 gst-launch-1.0 -v v4l2src -v device=/dev/video4 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! videorate !
image/jpeg,width=1920,height=1080,framerate=10/1 ! v4l2jpegdec !  
video/x-raw, format=Y42B, width=1920, height=1080, colorimetry=1:4:7:1 !
videoconvert !
video/x-raw,width=1920,height=1080,format=I420,colorimetry=bt601 ! fakesink


That's working. Videorate limits fps and CPU usage is much lower.


Source pad of V4l2jpegdec is:

caps = video/x-raw, format=(string)Y42B, width=(int)1920, height=(int)1080,
interlace-mode=(string)progressive, multiview-mode=(string)mono,
multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono,
pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2,
colorimetry=(string)1:4:7:1, framerate=(fraction)10/1




If I add v4l2h264enc before fakesink

gst-launch-1.0 -v v4l2src -v device=/dev/video4 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! videorate !
image/jpeg,width=1920,height=1080,framerate=10/1 ! v4l2jpegdec !  
"video/x-raw, format=Y42B, width=1920, height=1080,colorimetry=1:4:7:1" !
videoconvert !
video/x-raw,width=1920,height=1080,format=I420,colorimetry=bt601 !
v4l2h264enc ! fakesink

 I get error message:

v4l2videodec
gstv4l2videodec.c:751:gst_v4l2_video_dec_handle_frame:<v4l2jpegdec0> not
negotiated

I guess thats because of framerate cap:

 gst-launch-1.0 -v v4l2src -v device=/dev/video4 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! videorate !
image/jpeg,width=1920,height=1080,framerate=10/1 ! v4l2jpegdec !  
video/x-raw, format=Y42B, width=1920, height=1080, framerate=(fraction)10/1,
colorimetry=1:4:7:1 ! videoconvert !
video/x-raw,width=1920,height=1080,format=I420,colorimetry=bt601 ! fakesink

Same error.


Without framerate caps:

gst-launch-1.0 -v v4l2src -v device=/dev/video4 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! videorate !
image/jpeg,width=1920,height=1080,framerate=10/1 ! v4l2jpegdec !
video/x-raw, format=Y42B, width=1920, height=1080, colorimetry=1:4:7:1 !
videoconvert !
video/x-raw,width=1920,height=1080,format=I420,colorimetry=bt601 ! fakesink

That's working!



I guess that somehow v4l2h264enc wants a specific framerate which cant be
negotiated with v4l2jpegdec.


But i cant even try with caps to test that framerate, because everytime I
add a framerate parameter manually to caps, it doesnt'work. The source of
v4l2jpegdec just wants no framerate parameter.

Do you have any idea?






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

Re: i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

Gerbaum
This post was updated on .
Without videorate filter I got the same problem:

gst-launch-1.0 -v v4l2src -v device=/dev/video4 !
image/jpeg,width=1920,height=1080,framerate=30/1 !  v4l2jpegdec !  
"video/x-raw, format=Y42B, width=1920, height=1080, colorimetry=1:4:7:1" !
videoconvert !
video/x-raw,width=1920,height=1080,format=I420,colorimetry=bt601 !  fakesink

That's working


gst-launch-1.0 -v v4l2src -v device=/dev/video4 !
image/jpeg,width=1920,height=1080,framerate=30/1 !  v4l2jpegdec !  
"video/x-raw, format=Y42B, width=1920, height=1080, colorimetry=1:4:7:1,framerate=30/1" !
videoconvert !
video/x-raw,width=1920,height=1080,format=I420,colorimetry=bt601
!  fakesink

Not working



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

Gerbaum
After countless hours I could not get v4l2h264enc running after v4l2jpegdec.

Somehow v4l2h264enc demands a framerate value that v4l2jpegdec could not
deliver.

It worked with:

gst-launch-1.0 -v v4l2src -v device=/dev/video0 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! videorate !
image/jpeg,width=1920,height=1080,framerate=10/1 ! jpegdec ! videoconvert !
v4l2h264enc ! fakesink


But uses 60% CPU, cause of no hardware decoding...








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

Re: i.MX 6 gstreamer v4l2jpegdec with v4l2h264enc

Nicolas Dufresne-5


Le dim. 10 janv. 2021 15 h 15, Gerbaum <[hidden email]> a écrit :
After countless hours I could not get v4l2h264enc running after v4l2jpegdec.

Somehow v4l2h264enc demands a framerate value that v4l2jpegdec could not
deliver.

It worked with:

gst-launch-1.0 -v v4l2src -v device=/dev/video0 !
image/jpeg,width=1920,height=1080,framerate=30/1 ! videorate !
image/jpeg,width=1920,height=1080,framerate=10/1 ! jpegdec ! videoconvert !
v4l2h264enc ! fakesink


But uses 60% CPU, cause of no hardware decoding...

Sorry, I haven't had time too look into this, note that your issue might not only be GStreamer related, it is important to look under the hood with embedded platforms.









--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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