linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* coda: Unable to use encoder video_bitrate
@ 2014-12-18 16:44 Frédéric Sureau
  2014-12-18 16:52 ` Philipp Zabel
  0 siblings, 1 reply; 11+ messages in thread
From: Frédéric Sureau @ 2014-12-18 16:44 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Jean-Michel Hautbois, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi

I am trying to use the coda encoder through Gstreamer on an iMX6-based 
board.

I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
https://github.com/hizukiayaka/gst-plugins-good

This pipeline works fine:
gst-launch-1.0 -vvv v4l2src device=/dev/video4 ! 
"video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc ! 
h264parse ! mp4mux ! filesink location=test.mp4

When encoder has no bitrate param set (default=0), video encoding works 
well, but bitrate reaches ~2.5Mbps

When I try to set the bitrate with whatever value like 100,000 or 
1,000,000, the encoder produces video with bitrate around 480kbps and a 
very poor quality.

Here is the gstreamer pipeline I use with bitrate set:
gst-launch-1.0 -vvv v4l2src device=/dev/video4 ! 
"video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc 
extra-controls="controls,video_bitrate=1000000;" ! h264parse ! mp4mux ! 
filesink location=test.mp4

The video_bitrate control seems to be correctly passed to the driver by 
GStreamer since I can see the VIDIOC_S_CTRL call.

Any idea ?

Thanks
Fred

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-18 16:44 coda: Unable to use encoder video_bitrate Frédéric Sureau
@ 2014-12-18 16:52 ` Philipp Zabel
  2014-12-18 16:55   ` Jean-Michel Hautbois
  2014-12-22 15:24   ` Frédéric Sureau
  0 siblings, 2 replies; 11+ messages in thread
From: Philipp Zabel @ 2014-12-18 16:52 UTC (permalink / raw)
  To: Frédéric Sureau
  Cc: Jean-Michel Hautbois, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi Frédéric,

Am Donnerstag, den 18.12.2014, 17:44 +0100 schrieb Frédéric Sureau:
> Hi
> 
> I am trying to use the coda encoder through Gstreamer on an iMX6-based 
> board.
> 
> I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
> https://github.com/hizukiayaka/gst-plugins-good
> 
> This pipeline works fine:
> gst-launch-1.0 -vvv v4l2src device=/dev/video4 ! 
> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc ! 
> h264parse ! mp4mux ! filesink location=test.mp4
> 
> When encoder has no bitrate param set (default=0), video encoding works 
> well, but bitrate reaches ~2.5Mbps
> 
> When I try to set the bitrate with whatever value like 100,000 or 
> 1,000,000, the encoder produces video with bitrate around 480kbps and a 
> very poor quality.
> 
> Here is the gstreamer pipeline I use with bitrate set:
> gst-launch-1.0 -vvv v4l2src device=/dev/video4 ! 
> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc 
> extra-controls="controls,video_bitrate=1000000;" ! h264parse ! mp4mux ! 
> filesink location=test.mp4
> 
> The video_bitrate control seems to be correctly passed to the driver by 
> GStreamer since I can see the VIDIOC_S_CTRL call.
> 
> Any idea ?

There is a bug in the register definitions that causes the driver to
apply a wrong mask before writing the bitrate to the register.
I've got a fix for this in the pipeline, sending it right now.

regards
Philipp


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-18 16:52 ` Philipp Zabel
@ 2014-12-18 16:55   ` Jean-Michel Hautbois
  2014-12-18 17:09     ` Philipp Zabel
  2014-12-22 15:24   ` Frédéric Sureau
  1 sibling, 1 reply; 11+ messages in thread
From: Jean-Michel Hautbois @ 2014-12-18 16:55 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Frédéric Sureau, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi Philipp,

2014-12-18 17:52 GMT+01:00 Philipp Zabel <p.zabel@pengutronix.de>:
> Hi Frédéric,
>
> Am Donnerstag, den 18.12.2014, 17:44 +0100 schrieb Frédéric Sureau:
>> Hi
>>
>> I am trying to use the coda encoder through Gstreamer on an iMX6-based
>> board.
>>
>> I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
>> https://github.com/hizukiayaka/gst-plugins-good
>>
>> This pipeline works fine:
>> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
>> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc !
>> h264parse ! mp4mux ! filesink location=test.mp4
>>
>> When encoder has no bitrate param set (default=0), video encoding works
>> well, but bitrate reaches ~2.5Mbps
>>
>> When I try to set the bitrate with whatever value like 100,000 or
>> 1,000,000, the encoder produces video with bitrate around 480kbps and a
>> very poor quality.
>>
>> Here is the gstreamer pipeline I use with bitrate set:
>> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
>> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc
>> extra-controls="controls,video_bitrate=1000000;" ! h264parse ! mp4mux !
>> filesink location=test.mp4
>>
>> The video_bitrate control seems to be correctly passed to the driver by
>> GStreamer since I can see the VIDIOC_S_CTRL call.
>>
>> Any idea ?
>
> There is a bug in the register definitions that causes the driver to
> apply a wrong mask before writing the bitrate to the register.
> I've got a fix for this in the pipeline, sending it right now.

Where can we find the register definitions ? In order to look at it
before asking you :) ?

Thanks,
JM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-18 16:55   ` Jean-Michel Hautbois
@ 2014-12-18 17:09     ` Philipp Zabel
  2014-12-18 17:10       ` Jean-Michel Hautbois
  0 siblings, 1 reply; 11+ messages in thread
From: Philipp Zabel @ 2014-12-18 17:09 UTC (permalink / raw)
  To: Jean-Michel Hautbois
  Cc: Frédéric Sureau, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi Jean-Michel,

Am Donnerstag, den 18.12.2014, 17:55 +0100 schrieb Jean-Michel Hautbois:
> Hi Philipp,
> 
> 2014-12-18 17:52 GMT+01:00 Philipp Zabel <p.zabel@pengutronix.de>:
> > Hi Frédéric,
> >
> > Am Donnerstag, den 18.12.2014, 17:44 +0100 schrieb Frédéric Sureau:
> >> Hi
> >>
> >> I am trying to use the coda encoder through Gstreamer on an iMX6-based
> >> board.
> >>
> >> I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
> >> https://github.com/hizukiayaka/gst-plugins-good
> >>
> >> This pipeline works fine:
> >> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
> >> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc !
> >> h264parse ! mp4mux ! filesink location=test.mp4
> >>
> >> When encoder has no bitrate param set (default=0), video encoding works
> >> well, but bitrate reaches ~2.5Mbps
> >>
> >> When I try to set the bitrate with whatever value like 100,000 or
> >> 1,000,000, the encoder produces video with bitrate around 480kbps and a
> >> very poor quality.
> >>
> >> Here is the gstreamer pipeline I use with bitrate set:
> >> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
> >> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc
> >> extra-controls="controls,video_bitrate=1000000;" ! h264parse ! mp4mux !
> >> filesink location=test.mp4
> >>
> >> The video_bitrate control seems to be correctly passed to the driver by
> >> GStreamer since I can see the VIDIOC_S_CTRL call.
> >>
> >> Any idea ?
> >
> > There is a bug in the register definitions that causes the driver to
> > apply a wrong mask before writing the bitrate to the register.
> > I've got a fix for this in the pipeline, sending it right now.
> 
> Where can we find the register definitions ? In order to look at it
> before asking you :) ?

Sorry, forgot to put all of you on Cc: for the "[media] coda: fix
encoder rate control parameter masks" patch. The coda driver is in
drivers/media/platform/coda, register definitions in coda_regs.h.
The CODA_RATECONTROL_BITRATE_MASK is 0x7f, but it should be 0x7fff.

regards
Philipp


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-18 17:09     ` Philipp Zabel
@ 2014-12-18 17:10       ` Jean-Michel Hautbois
  2014-12-19 10:28         ` Philipp Zabel
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Michel Hautbois @ 2014-12-18 17:10 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Frédéric Sureau, Fabio Estevam, linux-media,
	Nicolas Dufresne

2014-12-18 18:09 GMT+01:00 Philipp Zabel <p.zabel@pengutronix.de>:
> Hi Jean-Michel,
>
> Am Donnerstag, den 18.12.2014, 17:55 +0100 schrieb Jean-Michel Hautbois:
>> Hi Philipp,
>>
>> 2014-12-18 17:52 GMT+01:00 Philipp Zabel <p.zabel@pengutronix.de>:
>> > Hi Frédéric,
>> >
>> > Am Donnerstag, den 18.12.2014, 17:44 +0100 schrieb Frédéric Sureau:
>> >> Hi
>> >>
>> >> I am trying to use the coda encoder through Gstreamer on an iMX6-based
>> >> board.
>> >>
>> >> I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
>> >> https://github.com/hizukiayaka/gst-plugins-good
>> >>
>> >> This pipeline works fine:
>> >> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
>> >> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc !
>> >> h264parse ! mp4mux ! filesink location=test.mp4
>> >>
>> >> When encoder has no bitrate param set (default=0), video encoding works
>> >> well, but bitrate reaches ~2.5Mbps
>> >>
>> >> When I try to set the bitrate with whatever value like 100,000 or
>> >> 1,000,000, the encoder produces video with bitrate around 480kbps and a
>> >> very poor quality.
>> >>
>> >> Here is the gstreamer pipeline I use with bitrate set:
>> >> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
>> >> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc
>> >> extra-controls="controls,video_bitrate=1000000;" ! h264parse ! mp4mux !
>> >> filesink location=test.mp4
>> >>
>> >> The video_bitrate control seems to be correctly passed to the driver by
>> >> GStreamer since I can see the VIDIOC_S_CTRL call.
>> >>
>> >> Any idea ?
>> >
>> > There is a bug in the register definitions that causes the driver to
>> > apply a wrong mask before writing the bitrate to the register.
>> > I've got a fix for this in the pipeline, sending it right now.
>>
>> Where can we find the register definitions ? In order to look at it
>> before asking you :) ?
>
> Sorry, forgot to put all of you on Cc: for the "[media] coda: fix
> encoder rate control parameter masks" patch. The coda driver is in
> drivers/media/platform/coda, register definitions in coda_regs.h.
> The CODA_RATECONTROL_BITRATE_MASK is 0x7f, but it should be 0x7fff.
>

Well, I meant, the datasheet of the CODA960 because we don't know,
just by reading the coda_regs.h which register is where and does what.
But it may be confidential ?

JM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-18 17:10       ` Jean-Michel Hautbois
@ 2014-12-19 10:28         ` Philipp Zabel
  2014-12-19 10:33           ` Jean-Michel Hautbois
  0 siblings, 1 reply; 11+ messages in thread
From: Philipp Zabel @ 2014-12-19 10:28 UTC (permalink / raw)
  To: Jean-Michel Hautbois
  Cc: Frédéric Sureau, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi Jean-Michel,

Am Donnerstag, den 18.12.2014, 18:10 +0100 schrieb Jean-Michel Hautbois:
> > Sorry, forgot to put all of you on Cc: for the "[media] coda: fix
> > encoder rate control parameter masks" patch. The coda driver is in
> > drivers/media/platform/coda, register definitions in coda_regs.h.
> > The CODA_RATECONTROL_BITRATE_MASK is 0x7f, but it should be 0x7fff.
> >
> 
> Well, I meant, the datasheet of the CODA960 because we don't know,
> just by reading the coda_regs.h which register is where and does what.

I wish. If you search for "cnm-codadx6-datasheet-v2.9.pdf" with a search
engine of your choice, on chipsnmedia.com you can get documentation for
the very oldest coda version supported by the driver. That's all I have
in addition to the old GPLed Freescale imx-vpu-lib for reference.

regards
Philipp


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-19 10:28         ` Philipp Zabel
@ 2014-12-19 10:33           ` Jean-Michel Hautbois
  0 siblings, 0 replies; 11+ messages in thread
From: Jean-Michel Hautbois @ 2014-12-19 10:33 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Frédéric Sureau, Fabio Estevam, linux-media,
	Nicolas Dufresne

2014-12-19 11:28 GMT+01:00 Philipp Zabel <p.zabel@pengutronix.de>:
> Hi Jean-Michel,
>
> Am Donnerstag, den 18.12.2014, 18:10 +0100 schrieb Jean-Michel Hautbois:
>> > Sorry, forgot to put all of you on Cc: for the "[media] coda: fix
>> > encoder rate control parameter masks" patch. The coda driver is in
>> > drivers/media/platform/coda, register definitions in coda_regs.h.
>> > The CODA_RATECONTROL_BITRATE_MASK is 0x7f, but it should be 0x7fff.
>> >
>>
>> Well, I meant, the datasheet of the CODA960 because we don't know,
>> just by reading the coda_regs.h which register is where and does what.
>
> I wish. If you search for "cnm-codadx6-datasheet-v2.9.pdf" with a search
> engine of your choice, on chipsnmedia.com you can get documentation for
> the very oldest coda version supported by the driver. That's all I have
> in addition to the old GPLed Freescale imx-vpu-lib for reference.

Uh, ok, didn't think about this. Thx a lot !
JM

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-18 16:52 ` Philipp Zabel
  2014-12-18 16:55   ` Jean-Michel Hautbois
@ 2014-12-22 15:24   ` Frédéric Sureau
  2014-12-22 15:28     ` Nicolas Dufresne
  2014-12-22 16:02     ` Philipp Zabel
  1 sibling, 2 replies; 11+ messages in thread
From: Frédéric Sureau @ 2014-12-22 15:24 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Jean-Michel Hautbois, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi Philipp,

Le 18/12/2014 17:52, Philipp Zabel a écrit :
> Hi Frédéric,
>
> Am Donnerstag, den 18.12.2014, 17:44 +0100 schrieb Frédéric Sureau:
>> Hi
>>
>> I am trying to use the coda encoder through Gstreamer on an iMX6-based
>> board.
>>
>> I use the (rebased and slightly modified) gstv4l2h264enc plugin from:
>> https://github.com/hizukiayaka/gst-plugins-good
>>
>> This pipeline works fine:
>> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
>> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc !
>> h264parse ! mp4mux ! filesink location=test.mp4
>>
>> When encoder has no bitrate param set (default=0), video encoding works
>> well, but bitrate reaches ~2.5Mbps
>>
>> When I try to set the bitrate with whatever value like 100,000 or
>> 1,000,000, the encoder produces video with bitrate around 480kbps and a
>> very poor quality.
>>
>> Here is the gstreamer pipeline I use with bitrate set:
>> gst-launch-1.0 -vvv v4l2src device=/dev/video4 !
>> "video/x-raw,width=1280,height=720" ! videoconvert ! v4l2video0h264enc
>> extra-controls="controls,video_bitrate=1000000;" ! h264parse ! mp4mux !
>> filesink location=test.mp4
>>
>> The video_bitrate control seems to be correctly passed to the driver by
>> GStreamer since I can see the VIDIOC_S_CTRL call.
>>
>> Any idea ?
> There is a bug in the register definitions that causes the driver to
> apply a wrong mask before writing the bitrate to the register.
> I've got a fix for this in the pipeline, sending it right now.
>
> regards
> Philipp
>
Thanks for the patch!
It works fine now after forcing framerate to 30fps (which seems to be 
hardcoded in the driver)

Fred

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-22 15:24   ` Frédéric Sureau
@ 2014-12-22 15:28     ` Nicolas Dufresne
  2014-12-22 16:02     ` Philipp Zabel
  1 sibling, 0 replies; 11+ messages in thread
From: Nicolas Dufresne @ 2014-12-22 15:28 UTC (permalink / raw)
  To: Frédéric Sureau, Philipp Zabel
  Cc: Jean-Michel Hautbois, Fabio Estevam, linux-media


Le 2014-12-22 10:24, Frédéric Sureau a écrit :
> Thanks for the patch!
> It works fine now after forcing framerate to 30fps (which seems to be 
> hardcoded in the driver) 

Can you comment about this on gnome bug. Would make sense for the 
encoder element in GStreamer to relay the framerate to the driver, so 
the driver can make any sense out of the bitrate.

https://bugzilla.gnome.org/show_bug.cgi?id=728438

Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-22 15:24   ` Frédéric Sureau
  2014-12-22 15:28     ` Nicolas Dufresne
@ 2014-12-22 16:02     ` Philipp Zabel
  2014-12-22 16:06       ` Nicolas Dufresne
  1 sibling, 1 reply; 11+ messages in thread
From: Philipp Zabel @ 2014-12-22 16:02 UTC (permalink / raw)
  To: Frédéric Sureau
  Cc: Philipp Zabel, Jean-Michel Hautbois, Fabio Estevam, linux-media,
	Nicolas Dufresne

Hi Frédéric,

On Mon, Dec 22, 2014 at 04:24:20PM +0100, Frédéric Sureau wrote:
> Thanks for the patch!
> It works fine now after forcing framerate to 30fps (which seems to
> be hardcoded in the driver)

That is a good point, rate control can only work if the encoder has
an idea about the framerate. I've sent a patch that allows to use
VIDIOC_S_PARM to set it:
"[media] coda: Use S_PARM to set nominal framerate for h.264 encoder"

regards
Philipp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: coda: Unable to use encoder video_bitrate
  2014-12-22 16:02     ` Philipp Zabel
@ 2014-12-22 16:06       ` Nicolas Dufresne
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Dufresne @ 2014-12-22 16:06 UTC (permalink / raw)
  To: Philipp Zabel, Frédéric Sureau
  Cc: Philipp Zabel, Jean-Michel Hautbois, Fabio Estevam, linux-media,
	k.debski


Le 2014-12-22 11:02, Philipp Zabel a écrit :
> That is a good point, rate control can only work if the encoder has
> an idea about the framerate. I've sent a patch that allows to use
> VIDIOC_S_PARM to set it:
> "[media] coda: Use S_PARM to set nominal framerate for h.264 encoder"
Thanks, I'll sort out what is needed on Gst side. Kamil, do MFC need to 
be looked at too ?

Nicolas

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-12-22 16:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 16:44 coda: Unable to use encoder video_bitrate Frédéric Sureau
2014-12-18 16:52 ` Philipp Zabel
2014-12-18 16:55   ` Jean-Michel Hautbois
2014-12-18 17:09     ` Philipp Zabel
2014-12-18 17:10       ` Jean-Michel Hautbois
2014-12-19 10:28         ` Philipp Zabel
2014-12-19 10:33           ` Jean-Michel Hautbois
2014-12-22 15:24   ` Frédéric Sureau
2014-12-22 15:28     ` Nicolas Dufresne
2014-12-22 16:02     ` Philipp Zabel
2014-12-22 16:06       ` Nicolas Dufresne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).