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

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


I've made some progress and getting closer to my final goal.

I used -f mpegts instead of mp4, and the video output is playing beautifully in all players! The command I use is:
/home/pi/FFmpeg/ffmpeg -y -nostdin -f v4l2 -threads auto -input_format yuyv422 -fflags +genpts -flags +global_header -i /dev/video0 -s 1280x720 -r 25 -vcodec h264_v4l2m2m -num_output_buffers 32 -num_capture_buffers 16 -keyint_min 25 -force_key_frames "expr:gte(t,n_forced*1)" -g 50 -b:v 6M -pix_fmt nv12 -f mpegts -muxdelay 0 -muxpreload 0 -movflags +faststart /home/pi/Videos/output.ts

My next step is to have the same video capture result but with the ' -f segment' to save the output in one-second parts, this is the command I use:

/home/pi/FFmpeg/ffmpeg -y -nostdin -f v4l2 -threads auto -input_format yuyv422 -fflags +genpts -flags +global_header -i /dev/video0 -s 1280x720 -r 25 -vcodec h264_v4l2m2m -num_output_buffers 32 -num_capture_buffers 16 -keyint_min 25 -force_key_frames "expr:gte(t,n_forced*1)" -g 50 -b:v 6M -pix_fmt nv12 -f mpegts -f segment -segment_time 1 -reset_timestamps 1 -segment_format mpegts -muxdelay 0 -muxpreload 0 -movflags +faststart /home/pi/Videos/%d-output.ts
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 @ 0x55a8058af0] 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 @ 0x55a8058af0] Dequeued v4l2 buffer contains corrupted data (0 bytes).
    Last message repeated 30 times
[h264_v4l2m2m @ 0x55a805cd40] Using device /dev/video11
[h264_v4l2m2m @ 0x55a805cd40] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode
[h264_v4l2m2m @ 0x55a805cd40] requesting formats: output=NV12 capture=H264
[h264_v4l2m2m @ 0x55a805cd40] Failed to set gop size: Invalid argument
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/0-output.ts' for writing
Output #0, segment, to '/home/pi/Videos/%d-output.ts':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (h264_v4l2m2m), nv12, 1280x720, q=-1--1, 6000 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.91.100 h264_v4l2m2m
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/1-output.ts' for writingp=21 speed=3.44e+04x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/2-output.ts' for writingp=22 speed=1.98e+04x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/3-output.ts' for writingp=22 speed=1.73e+04x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/4-output.ts' for writingop=22 speed=1.25e+04x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/5-output.ts' for writingop=22 speed=1.14e+04x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/6-output.ts' for writingop=22 speed=9.84e+03x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/7-output.ts' for writingop=22 speed=8.57e+03x    
[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/8-output.ts' for writingop=22 speed=7.64e+03x    
^C[segment @ 0x55a805b5c0] Opening '/home/pi/Videos/9-output.ts' for writing=22 speed=6.86e+03x    
frame=  226 fps= 21 q=-0.0 Lsize=N/A time=19:47:59.76 bitrate=N/A dup=45 drop=22 speed=6.56e+03x    
video:3210kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.

///////////////////////// END OF OUTPUT /////////////////////////

The problem now is that only the first part file '1-output.ts' is playable, the other parts, '2-output.ts' and onwards, are not playable when using ffplay:

ffplay version N-86265-gb946bd8 Copyright (c) 2003-2017 the FFmpeg developers
  built with gcc 7.1.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
[h264 @ 0000000000e06c00] non-existing PPS 0 referenced  0B f=0/0
[AVBSFContext @ 0000000000e0cb40] Invalid NAL unit 0, skipping.
[h264 @ 0000000000e06c00] non-existing PPS 0 referenced
[h264 @ 0000000000e06c00] decode_slice_header error
[h264 @ 0000000000e06c00] no frame!
[h264 @ 0000000000e06c00] non-existing PPS 0 referenced
[AVBSFContext @ 0000000000e0cb40] Invalid NAL unit 0, skipping.
[h264 @ 0000000000e06c00] non-existing PPS 0 referenced
[h264 @ 0000000000e06c00] decode_slice_header error
[h264 @ 0000000000e06c00] no frame!
[h264 @ 0000000000e06c00] non-existing PPS 0 referenced
.
.
.
.
///////////////////////// END OF OUTPUT /////////////////////////


More information about the ffmpeg-user mailing list