NvVideoEncoder::createVideoEncoder() returns NULL (Solved)

Here’s my program:

#include <stdio.h>
#include "NvVideoEncoder.h"

int main() {
  NvVideoEncoder *enc = NvVideoEncoder::createVideoEncoder("enc0", 0);
  if (enc == NULL) {
    fprintf(stderr, "encoder creation failed");
  return 0;

It fails to create a video encoder on Xavier with latest preview JetPack:

nvidia@xavier:/usr/local/xavier/capturizer$ ./build/capturizer
[ERROR] (src/NvV4l2Element.cpp:81) <enc0> Error in VIDIOC_QUERYCAP: Inappropriate ioctl for device
[ERROR] (src/NvV4l2ElementPlane.cpp:502) <enc0> Output Plane:Error in VIDIOC_REQBUFS at output plane: Inappropriate ioctl for device
[ERROR] (src/NvV4l2ElementPlane.cpp:502) <enc0> Capture Plane:Error in VIDIOC_REQBUFS at output plane: Inappropriate ioctl for device
encoder creation failed

What am I missing? Does this not work yet?

Now that I think about it: one difference is that I don’t use v4l2_ioctl() and v4l2_open(); instead I just raw open() and ioctl(), because I copy the necessary .cpp files out of the samples and into my own project.

Does the NvVideoEncoder code depend on the compatibility functions provided by libv4l2? If so, why wouldn’t you just do the right thing in your own code instead? The compatibility functions are generally slow and hard to control.

Hi snarky,
The implementation depends on libv4l-dev, so yu should use v4l2 interfaces.

The default reference sample runs fine.

nvidia@jetson-0422418042113:~/tegra_multimedia_api/samples/01_video_encode$ ./video_encode /home/nvidia/4K.yuv 3840 2160 H264 4k.h264
No protocol specified
nvbuf_utils: Could not get EGL display connection
Failed to query video capabilities: Inappropriate ioctl for device
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
H264: Profile = 66, Level = 51 
Could not read complete frame from input file
File read complete.
App run was successful