Re: [FFmpeg-devel] [PATCH v1] avcodec/v4l2_m2m_enc: Set bitrate mode to cbr by default

2020-04-29 Thread Andriy Gelman
On Wed, 29. Apr 16:14, Ming Qian wrote:
> Without this setting, bitrate may have no effect
> if the default value of bitrate mode is VBR.
> 
> Signed-off-by: Ming Qian 
> ---
>  libavcodec/v4l2_m2m_enc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index 8454e2326c..6296ad88c6 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -191,6 +191,7 @@ static int v4l2_prepare_encoder(V4L2m2mContext *s)
>  
>  /* set ext ctrls */
>  v4l2_set_ext_ctrl(s, MPEG_CID(HEADER_MODE), 
> MPEG_VIDEO(HEADER_MODE_SEPARATE), "header mode", 0);
> +v4l2_set_ext_ctrl(s, MPEG_CID(BITRATE_MODE), 
> MPEG_VIDEO(BITRATE_MODE_CBR), "bit rate mode", 1);
>  v4l2_set_ext_ctrl(s, MPEG_CID(BITRATE) , avctx->bit_rate, "bit rate", 1);
>  v4l2_set_ext_ctrl(s, MPEG_CID(FRAME_RC_ENABLE), 1, "frame level rate 
> control", 0);
>  v4l2_set_ext_ctrl(s, MPEG_CID(GOP_SIZE), avctx->gop_size,"gop size", 1);
> -- 
> 2.26.0
> 

On the RPI4 it causes streamon to fail:

./ffmpeg -y -i 7799x264.mp4 -an -codec:v h264_v4l2m2m out.264
[h264_v4l2m2m @ 0x3d6e3b0] VIDIOC_STREAMON failed on output context
Video encoding failed   

Conversion failed!

[41648.654237] bcm2835-codec bcm2835-codec: bcm2835_codec_start_streaming: 
Failed enabling i/p port, ret -3
 
[41648.654243] [ cut here ]
[41648.654267] WARNING: CPU: 2 PID: 26254 at 
drivers/media/common/videobuf2/videobuf2-core.c:1365 
vb2_start_streaming+0xe4/0x160 [videobuf2_common]   
  
[41648.654271] Modules linked in: bnep hci_uart btbcm serdev bluetooth 
ecdh_generic 8021q garp stp llc vc4 v3d gpu_sched drm_kms_helper brcmfmac 
brcmutil drm snd_soc_core sha256_generic snd_compress snd_pcm_dmaengine 
drm_panel_orientation_quirks syscopyarea sysfillrect sysimgblt fb_sys_fops 
raspberrypi_hwmon cfg80211 hwmon snd_bcm2835(C) snd_pcm rfkill snd_timer 
bcm2835_v4l2(C) snd bcm2835_codec(C) v4l2_mem2mem v4l2_common 
bcm2835_mmal_vchiq(C) videobuf2_vmalloc videobuf2_dma_contig videobuf2_memops 
videobuf2_v4l2 videobuf2_common videodev media vc_sm_cma(C) rpivid_mem 
uio_pdrv_genirq uio ip_tables x_tables ipv6
[41648.654351] CPU: 2 PID: 26254 Comm: ffmpeg Tainted: GWC
4.19.97-v7l+ #1294
[41648.654355] Hardware name: BCM2835
[41648.654374] [] (unwind_backtrace) from [] 
(show_stack+0x20/0x24)
[41648.654383] [] (show_stack) from [] 
(dump_stack+0xe0/0x124)
[41648.654392] [] (dump_stack) from [] (__warn+0x104/0x11c)
[41648.654400] [] (__warn) from [] 
(warn_slowpath_null+0x50/0x58)
[41648.654414] [] (warn_slowpath_null) from [] 
(vb2_start_streaming+0xe4/0x160 [videobuf2_common]) 
 
[41648.654434] [] (vb2_start_streaming [videobuf2_common]) from 
[] (vb2_core_streamon+0x130/0x16c [videobuf2_common]) 
  
[41648.654451] [] (vb2_core_streamon [videobuf2_common]) from 
[] (vb2_streamon+0x40/0x60 [videobuf2_v4l2])  

[41648.654467] [] (vb2_streamon [videobuf2_v4l2]) from [] 
(v4l2_m2m_streamon+0x30/0x48 [v4l2_mem2mem])
  
[41648.654480] [] (v4l2_m2m_streamon [v4l2_mem2mem]) from 
[] (v4l2_m2m_ioctl_streamon+0x20/0x24 [v4l2_mem2mem]) 

[41648.654518] [] (v4l2_m2m_ioctl_streamon [v4l2_mem2mem]) from 
[] (v4l_streamon+0x28/0x2c [videodev])
  
[41648.654571] [] (v4l_streamon [videodev]) from [] 
(__video_do_ioctl+0x268/0x528 [videodev])   

[41648.654621] [] (__video_do_ioctl [videodev]) from [] 
(video_usercopy+0x218/0x600 [videodev]) 

[41648.654670] [] (video_usercopy [videodev]) from [] 
(video_ioctl2+0x20/0x24 [videodev]) 
  
[41648.654720] [] (video_ioctl2 [videodev]) from [] 
(v4l2_ioctl+0x4c/0x60 [videodev])   

[41648.654751] [] (v4l2_ioctl [videodev]) from [] 
(do_vfs_ioctl+0xbc/0x804)   
  
[41648.654759] [] (do_vfs_ioctl) from [] 
(ksys_ioctl+0x44/0x6c)
[41648.654765] [] (ksys_ioctl) from [] (sys_ioctl+0x18/0x1c)
[41648.654771] [] (sys_ioctl) from [] 
(ret_fast_syscall+0x0/0x28)
[41648.654775] Exception stack(0xc0157fa8 to 0xc0157ff0)
[41648.654780] 7fa0:    7fff 0005 40045612 
befe66d8 0005
[41648.654785] 7fc0:  7fff 0001 0036 0001 

[FFmpeg-devel] [PATCH v1] avcodec/v4l2_m2m_enc: Set bitrate mode to cbr by default

2020-04-29 Thread Ming Qian
Without this setting, bitrate may have no effect
if the default value of bitrate mode is VBR.

Signed-off-by: Ming Qian 
---
 libavcodec/v4l2_m2m_enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 8454e2326c..6296ad88c6 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -191,6 +191,7 @@ static int v4l2_prepare_encoder(V4L2m2mContext *s)
 
 /* set ext ctrls */
 v4l2_set_ext_ctrl(s, MPEG_CID(HEADER_MODE), 
MPEG_VIDEO(HEADER_MODE_SEPARATE), "header mode", 0);
+v4l2_set_ext_ctrl(s, MPEG_CID(BITRATE_MODE), MPEG_VIDEO(BITRATE_MODE_CBR), 
"bit rate mode", 1);
 v4l2_set_ext_ctrl(s, MPEG_CID(BITRATE) , avctx->bit_rate, "bit rate", 1);
 v4l2_set_ext_ctrl(s, MPEG_CID(FRAME_RC_ENABLE), 1, "frame level rate 
control", 0);
 v4l2_set_ext_ctrl(s, MPEG_CID(GOP_SIZE), avctx->gop_size,"gop size", 1);
-- 
2.26.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".