I’m working on modifying FFmpeg’s v4l2_m2m code to support Jetson nano H264/HEVC.
There are problems with your v4l2 drivers that don’t allow the encoder to be added.
Issue with POLLIN flag
ffmpeg uses poll() to decide whether to deque the capture buffers. poll() is called with an infinite timeout so that it acts as a throttle from the hardware device. The issue is that even when the POLLIN flag is raised in revents (indicating that capture buffers can be dequeued without blocking), the ioctl call returns -1 with EAGAIN quite a lot of the time. This is incorrect behaviour and means there is no throttling.
Your v4l2 drivers need nvbuf_utils.h. At the moment this doesn’t have an open source license. Please release under something that’s LGPL compatible. Also, please provide pkg-config.pc file for nvbuf_utils that exists on your boards and lives in /usr/share/pkgconfig. This will make linking to nvbuf_utils a lot easier.
Hi,
ffmpeg with hardware acceleration is the feature we are evaluating to support in future release. Before NVIDIA delivers official package, you may refer to the community contribution:
I just tried this, but does not seem to work, the resolution is not used (not even with v4l2-ctl --set-fmt-video=width=1920,height=1080 and the output is all green frames (and hangs). I’m using raspberry V2 camera:
jetson@jetson:~$ ffmpeg -f v4l2 -input_format yuyv422 -video_size 1920x1080 -framerate 30 -i /dev/video0 -c:v h264_nvmpi test.mp4
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr/local --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --arch=arm64 --enable-gpl --disable-stripping --enable-nvmpi --enable-libx264 --enable-libvpx --enable-libopus
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[video4linux2,v4l2 @ 0x55a0845fe0] The V4L2 driver changed the video from 1920x1080 to 3264x2464
[video4linux2,v4l2 @ 0x55a0845fe0] ioctl(VIDIOC_G_PARM): Inappropriate ioctl for device
[video4linux2,v4l2 @ 0x55a0845fe0] Time per frame unknown
[video4linux2,v4l2 @ 0x55a0845fe0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 79563.524033, bitrate: N/A
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 3264x2464, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvmpi))
Press [q] to stop, [?] for help
[mp4 @ 0x55a08487b0] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 77, Level = 51
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 77, Level = 51
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (h264_nvmpi) (avc1 / 0x31637661), yuv420p, 3264x2464, q=-1--1, 2000 kb/s, 1000k fps, 1000k tbn, 1000k tbc
Metadata:
encoder : Lavc58.54.100 h264_nvmpi
More than 1000 frames duplicated
^C
jetson@jetson:~$
Hi,
Raspberry Pi V2 is a Bayer sensor. It goes through Argus to utilize hardware ISP engine for de-bayering. Suggest you use gstreamer or jetson_multimedia_api. You can run