VCodecLibav C++ library v1.0.1

Low-latency video encoding and decoding library for H264, HEVC(H265) and JPEG codecs based on Libav library.

Overview

VCodecLibav C++ library provides video encoding and decoding functions for H264, HEVC(H265) and JPEG codecs. VCodecLibav video codec class inherits interface and data structures form VCodec library. VCodecLibav uses libav library from ffmpeg library. Version 1.0.1 supports only intel integrated GPU and uses intel hardware encoders and decoders via ffmpeg. Supported ffmpeg encoders and decoders:

  • Encoder H264h264_vaapi (Intel VAAPI based codec)

  • Encoder hevc_vaapi (Intel VAAPI based codec)

  • Encoder mjpeg_vaapi (Intel VAAPI based codec)

  • Decoder h264_qsv (Intel QuickSync based) - not tested

  • Decoder hevc_qsv (Intel QuickSync based) - not tested

  • Decoder mjpeg_qsv (Intel QuickSync based) - not tested

class VCodecLibav : public VCodec {
public:
    /// Encode video frame.
    bool transcode(Frame& src, Frame& dst);
    /// Set parameter value.
    bool setParam(VCodecParam id, float value);
    /// Get parameter value.
    float getParam(VCodecParam id);
    /// Execute command.
    bool executeCommand(VCodecCommand id);
};

How to use

Source code bellow is simple application which encodes video frames (NV12 pixel format, pseudo code used) by H264 codec and writes results to file:

#include "VCodecLibav.h"
using namespace cr::video;

int main(void) {
    // Create codec object and set parameters.
    VCodecLibav codec;
    codec.setParam(VCodecParam::BITRATE_KBPS, 2500);
    codec.setParam(VCodecParam::GOP, 30);
    codec.setParam(VCodecParam::FPS, 30);
    codec.setParam(VCodecParam::H264_PROFILE, 0);
    // Create input NV12 and output H264 frames.
    Frame dstH264; dstH264.fourcc = Fourcc::H264;
    Frame srcNv12;
    // Create output file.
    FILE *out = fopen("out.h264", "w+b");
    // Encode and record 200 frames.
    for (int n = 0; n < 200; ++n) {
        // Get NV12 frame pseudo code.
        srcNv12 = getNextFrame();
        // Encode.
        if (!codec.transcode(srcNv12, dstH264))
            continue;
        // Write to file.
        fwrite(dstH264.data, dstH264.size, 1, out);
    }
    // Close file.
    fclose(outputFile);
    return 1;
}

Price and Terms

The VCodecLibav C++ library is supplied under a GNU Lesser General Public License version 2.1 or later. Library pricing is available upon request info@constantrobotics.com

Downloads

VSourceLibav C++ library programmer’s manual: DOWNLOAD