h264_v4l2m2m Failed to set gop size: Invalid argument
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.
Hi, On Fri, 11. Dec 00:03, Ram Shaffir wrote:
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:
Does it work in ffplay? For debugging you may want to simplify the problem. Try to encode another video with h264_v4lm2m. Does a software encoder work with v4l2 input?
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.
This means that the parameter is not supported on the hardware encoder. Nothing to be concerned about. -- Andriy
Hello Andriy, thank you for taking the time and try to help me!
Does it work in ffplay?
Yes it does play in 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 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '64b.mp4':sq= 0B f=0/0 Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Duration: 00:00:08.84, start: 63109.080000, bitrate: 6535 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 6534 kb/s, 25 fps, 25 tbr, 12800 tbn, 60 tbc (default) Metadata: handler_name : VideoHandler 63118.33 M-V: -0.034 fd= 5 aq= 0KB vq= 0KB sq= 0B f=0/0 /////////////////////// END OF OUTPUT ///////////////////////
For debugging you may want to simplify the problem. Try to encode another video with h264_v4lm2m. Does a software encoder work with v4l2 input?
The following call was the simplest one I could get any video output, and the video output also doesn't play in "dump" player but it does play in ffplay and vlc (it produced the same result with and without -f v4l2): /home/pi/FFmpeg/ffmpeg -f v4l2 -input_format yuyv422 -i /dev/video0 -vcodec h264_v4l2m2m -pix_fmt nv12 /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 Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 63684.175099, 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 File '/home/pi/Videos/64b.mp4' already exists. Overwrite? [y/N] y Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m)) Press [q] to stop, [?] for help [h264_v4l2m2m @ 0x5573d864e0] Using device /dev/video11 [h264_v4l2m2m @ 0x5573d864e0] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode [h264_v4l2m2m @ 0x5573d864e0] requesting formats: output=NV12 capture=H264 [h264_v4l2m2m @ 0x5573d864e0] 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, 1920x1080, q=-1--1, 200 kb/s, 59.94 fps, 14026 tbn, 59.94 tbc Metadata: encoder : Lavc58.91.100 h264_v4l2m2m frame= 453 fps= 42 q=-0.0 Lsize= 497kB time=00:00:07.54 bitrate= 539.6kbits/s dup=367 drop=0 speed=0.693x video:494kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.528277% Exiting normally, received signal 2. /////////////////////// END OF OUTPUT ///////////////////////
This means that the parameter is not supported on the hardware encoder. Nothing to be concerned about.
That’s very good to know! If so, what is the root of the problem? Once again, many thanks, I appreciate it much!
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 /////////////////////////
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:
I've told that to fix the problem I'm facing with the V4L2 H264 encoder (repeat headers), I should enable V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER in the call v4l2_set_ext_ctrl (https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/v4l2_m2m_enc.c#L53) Does it mean that I need to add it like this and recompile?: static inline int v4l2_get_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning) { struct v4l2_ext_controls ctrls = { { 0 } }; struct v4l2_ext_control ctrl = { 0 }; int ret; /* like this? */ V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER = 1; /* set ctrls */ ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ctrls.controls = &ctrl; ctrls.count = 1; /* set ctrl*/ ctrl.id = id ; ret = ioctl(s->fd, VIDIOC_G_EXT_CTRLS, &ctrls); if (ret < 0) { av_log(s->avctx, log_warning || errno != EINVAL ? AV_LOG_WARNING : AV_LOG_DEBUG, "Failed to get %s\n", name); return ret; } *value = ctrl.value; return 0; }
On Tue, 15 Dec 2020 at 02:54, Ram Shaffir <ram@ram.sh> wrote:
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:
I've told that to fix the problem I'm facing with the V4L2 H264 encoder (repeat headers), I should enable V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER in the call v4l2_set_ext_ctrl ( https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/v4l2_m2m_enc.c#L53)
Does it mean that I need to add it like this and recompile?:
static inline int v4l2_get_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning) { struct v4l2_ext_controls ctrls = { { 0 } }; struct v4l2_ext_control ctrl = { 0 }; int ret;
/* like this? */ V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER = 1;
/* set ctrls */ ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ctrls.controls = &ctrl; ctrls.count = 1;
/* set ctrl*/ ctrl.id = id ;
ret = ioctl(s->fd, VIDIOC_G_EXT_CTRLS, &ctrls); if (ret < 0) { av_log(s->avctx, log_warning || errno != EINVAL ? AV_LOG_WARNING : AV_LOG_DEBUG, "Failed to get %s\n", name); return ret; }
*value = ctrl.value;
return 0; }
You should be able to set the option with the attached patch. Haven't had time to test though. -- Andriy
Success!! I've applied your patch, and it works. You're a lifesaver!! Thank you so very much, RS.
-----Original Message----- From: ffmpeg-user <ffmpeg-user-bounces@ffmpeg.org> On Behalf Of Andriy Gelman Sent: Wednesday, December 16, 2020 7:56 AM To: FFmpeg user questions <ffmpeg-user@ffmpeg.org> Subject: Re: [FFmpeg-user] h264_v4l2m2m Failed to set gop size: Invalid argument
On Tue, 15 Dec 2020 at 02:54, Ram Shaffir <ram@ram.sh> wrote:
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:
I've told that to fix the problem I'm facing with the V4L2 H264 encoder (repeat headers), I should enable V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER in the call
v4l2_set_ext_ctrl (
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/v4l2_m2m_en c.c
#L53)
Does it mean that I need to add it like this and recompile?:
static inline int v4l2_get_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning) { struct v4l2_ext_controls ctrls = { { 0 } }; struct v4l2_ext_control ctrl = { 0 }; int ret;
/* like this? */ V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER = 1;
/* set ctrls */ ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; ctrls.controls = &ctrl; ctrls.count = 1;
/* set ctrl*/ ctrl.id = id ;
ret = ioctl(s->fd, VIDIOC_G_EXT_CTRLS, &ctrls); if (ret < 0) { av_log(s->avctx, log_warning || errno != EINVAL ? AV_LOG_WARNING : AV_LOG_DEBUG, "Failed to get %s\n", name); return ret; }
*value = ctrl.value;
return 0; }
You should be able to set the option with the attached patch. Haven't had time to test though.
-- Andriy
participants (2)
-
Andriy Gelman -
Ram Shaffir