[FFmpeg-user] h264_v4l2m2m Failed to set gop size: Invalid argument

Ram Shaffir ram at ram.sh
Fri Dec 11 02:03:14 EET 2020


Hello,

I'm using RPI4 running RaspiOS 64bit:
Linux Dev64b 5.4.79-v8+ #1373 SMP PREEMPT Mon Nov 23 13:32:41 GMT 2020 aarch64 GNU/Linux

I compiled FFmpeg ver 4.3 from this git:
git clone --depth 1 --branch release/4.3 https://github.com/FFmpeg/FFmpeg.git

(I realized after the build that I used the '--enable-nonfree' as I was following a walkthrough tutorial and copy/paste some of the configuration params; I'm planning on rebuilding it without '--enable-nonfree')

my goal is to capture a video stream from a webcam to a file; however, I can't find the right parameters to have the video output played in "dumb" video players; most of the players show a black image or the first frame; I tried to add the following parameters but got the same result:
-force_key_frames "expr:gte(t,n_forced*1)" 
-keyint_min 25
-g 50

I searched for the error: " Failed to set gop size: Invalid argument " when using the h264_v4l2m2m encoder but didn't find anything I can use to fix it; I would be very grateful if you could help me with this issue.

Thank you all in advance!

Below is the output of my current command:
/home/pi/FFmpeg/ffmpeg -nostdin -threads auto -y -f v4l2 -thread_queue_size 4096 -input_format yuyv422 -fflags +genpts -flags +global_header -i /dev/video0 -vcodec h264_v4l2m2m -num_output_buffers 32 -num_capture_buffers 16 -an -s 1280x720 -r 25 -sc_threshold 0 -pix_fmt nv12 -b:v 10M -minrate 10M -maxrate 10M -bufsize 20M  /home/pi/Videos/64b.mp4
ffmpeg version ca55240 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/home/pi/ffmpeg_build --pkg-config-flags='pkg-config --static' --extra-cflags=-I/home/pi/ffmpeg_build/include --extra-ldflags=-L/home/pi/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/pi/bin --enable-gpl --enable-gnutls --disable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --disable-libx265 --enable-nonfree --arch=aarch64 --disable-libxml2 --enable-libwebp --enable-libdrm
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[video4linux2,v4l2 @ 0x555ea669c0] Dequeued v4l2 buffer contains corrupted data (0 bytes).
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 0.000000, bitrate: 1988671 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080, 1988671 kb/s, 59.94 fps, 59.94 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m))
[video4linux2,v4l2 @ 0x555ea669c0] Dequeued v4l2 buffer contains corrupted data (0 bytes).
    Last message repeated 30 times
[h264_v4l2m2m @ 0x555ea6a850] Using device /dev/video11
[h264_v4l2m2m @ 0x555ea6a850] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode
[h264_v4l2m2m @ 0x555ea6a850] requesting formats: output=NV12 capture=H264
[h264_v4l2m2m @ 0x555ea6a850] Failed to set gop size: Invalid argument
Output #0, mp4, to '/home/pi/Videos/64b.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (h264_v4l2m2m) (avc1 / 0x31637661), nv12, 1280x720, q=-1--1, 10000 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.91.100 h264_v4l2m2m
frame=    5 fps=0.0 q=-0.0 size=       0kB time=07:19:10.60 bitrate=   0.0kbits/s dup=0 drop=2 speed=4.7
frame=    9 fps=8.4 q=-0.0 size=       0kB time=07:19:10.76 bitrate=   0.0kbits/s dup=0 drop=8 speed=2.4
frame=   13 fps=8.1 q=-0.0 size=       0kB time=07:19:10.92 bitrate=   0.0kbits/s dup=0 drop=14 speed=1.
frame=   18 fps=8.5 q=-0.0 size=       0kB time=07:19:11.12 bitrate=   0.0kbits/s dup=0 drop=21 speed=1.
frame=   30 fps= 11 q=-0.0 size=     256kB time=07:19:11.60 bitrate=   0.1kbits/s dup=1 drop=22 speed=9.
frame=   42 fps= 13 q=-0.0 size=     256kB time=07:19:12.04 bitrate=   0.1kbits/s dup=3 drop=22 speed=8.
frame=   51 fps= 14 q=-0.0 size=     512kB time=07:19:12.44 bitrate=   0.2kbits/s dup=3 drop=22 speed=7.
frame=   63 fps= 15 q=-0.0 size=     512kB time=07:19:12.88 bitrate=   0.2kbits/s dup=5 drop=22 speed=6.
frame=   75 fps= 16 q=-0.0 size=     768kB time=07:19:13.40 bitrate=   0.2kbits/s dup=8 drop=22 speed=5.
frame=   89 fps= 17 q=-0.0 size=    1280kB time=07:19:13.92 bitrate=   0.4kbits/s dup=12 drop=22 speed=5
frame=  102 fps= 18 q=-0.0 size=    2048kB time=07:19:14.48 bitrate=   0.6kbits/s dup=15 drop=22 speed=4
frame=  116 fps= 18 q=-0.0 size=    2304kB time=07:19:15.04 bitrate=   0.7kbits/s dup=19 drop=22 speed=4
frame=  118 fps= 18 q=-0.0 Lsize=    2675kB time=07:19:15.16 bitrate=   0.8kbits/s dup=20 drop=22 speed=4.06e+03x    
^C
video:2674kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.049414%
Exiting normally, received signal 2.



More information about the ffmpeg-user mailing list