Video Encoding using C on Jetson options FFmpeg / Gstreamer / Multimedia API Questions

I have a existing C Linux / x86-64 application with uses the FFMPEG libraries (libavcodec libavformat etc) to do video encoding, using h264_nvenc, which has worked on the x86-64 platform and the Quadro family.

I have tried to port this application to the Jetson, but I am running into stumbling blocks. It appears that the h264_nvenc encoders are not supported by the FFMPEG libraries on the Jetson. My application works with software encoding on the jetson, but its impractically slow when using the FFMPEG software encoding.

My application has been designed for a specific use case where I have a raw yuv 420 buffer, which is encoded into a h264 compressed packet. This is explicitly controlled on a frame by frame and packet by packet basis, rather than a stream.

My questions are,

  • As GStreamer is recommended, is there a C sample somewhere which has a discrete function where you can pass it a raw yuv420 buffer and obtain a single h264 compressed packet?
  • Is the recommended Jetson Multimedia API only for C++? or if is there some C version somewhere? Its just when looking in it, there appears to be a rules.mk file which specifies the link libraries and directories, and a common directory full of C++ classes. ie are all underlying libraries C++? The samples work, but are there some instructions on the recommended way of using it into an existing application? Or do you just read the make files and rules.mk and include the common directory in your application? Will I have to just recompile my application as a C++ application and interface it with the Jetson Multimedia API as is?
  • It appears that when running the ffmpeg -encoders command, it shows the h264_vaapi encoder, does this work with the hardware encoders on the jetson using libavcodec? I would think this would only work with the NV12 pix format.

Hi,
For utilizing hardware encode/decode engines in Jetson, we suggest use gstreamer or jetson_multimedia_api. Please take a look at documents:
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/accelerated_gstreamer.html#
Jetson Linux API Reference: Main Page | NVIDIA Docs

Please take a look. Below is a gstreamer command for video encoding:

$ gst-launch-1.0 videotestsrc num-buffers=100 ! nvvidconv ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=a.mp4

The jetson_multimedia_api sample is in

/usr/src/jetson_multimedia_api/samples/01_video_encode/

We have a package to enable hardware decoding in ffmpeg. And there is a community contribution enabling both encoding and decoding. Please take a look at
Jetson Nano FAQ
[Q: Is hardware acceleration enabled in ffmpeg?]

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.