VCodecLibva C++ lib. Fast HEVC, H264 and JPEG encoding/decoding based on Intel Libva (VAAPI)

€1,500.00

VCodecLibva C++ library provides video encoding and decoding functions for H264, HEVC(H265) and JPEG codecs for Linux OS based on Intel Libva.

LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE.

VCodecLibva C++ library provides video encoding and decoding functions for H264, HEVC(H265) and JPEG codecs for Linux OS based on Intel Libva.

LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE.

Overview

The VCodecLibva C++ library provides hardware video encoding for H264, HEVC and JPEG codecs based on the LibVAIntel library (Hardware accelerated encoding based on VAAPIinterface) on Linux only. The VCodecLibva video codec class inherits interface and data structures from the VCodec interface library. The library depends on the open-source VCodec library (provides codec interface, source code included, Apache 2.0 license), the open-source LibVA library, and the open-source Logger(provides functions to print logs, source code included, Apache 2.0 license). The library uses the C++17 standard.

Documentation

Documentation: GO TO DOCUMENTATION

Simple interface

class VCodecLibva : public VCodec
{
public:
    /// Get library version.
    static std::string getVersion();

    /// 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);
};

Simple example

#include <iostream>
#include "VCodecLibva.h"

int main(void)
{
    // Create codec object and set params.
    cr::video::VCodec* encoder = new cr::video::VCodecLibva();
    encoder->setParam(cr::video::VCodecParam::BITRATE_KBPS, 10000);
    encoder->setParam(cr::video::VCodecParam::FPS, 20);
    encoder->setParam(cr::video::VCodecParam::GOP, 30);
    encoder->setParam(cr::video::VCodecParam::H264_PROFILE, 0);
    // Image size.
    const int width = 640;
    const int height = 480;
    // Source frame.
    cr::video::Frame srcFrame(width, height, cr::video::Fourcc::NV12);
    // Result frame H264.
    cr::video::Frame dstFrame(width, height, cr::video::Fourcc::H264);

    // Main loop.
    uint8_t valueOffset;
    while (true)
    {
        // Generate random data for source frame. Fill NV12 frame data.
        for (int i = 0; i < srcFrame.size; ++i)
            srcFrame.data[i] = (uint8_t)i + valueOffset;
        valueOffset++;

        // Encode data.
        if (!encoder->transcode(srcFrame, dstFrame))
        {
            std::cout << "Can't encode frame" << std::endl;
            continue;
        }

        // Show info.
        std::cout << "[" << dstFrame.frameId << "] Size " <<
        dstFrame.size << " Compression ratio : %" <<
        (int)(100.0f * ((float)dstFrame.size / (float)srcFrame.size)) <<
        std::endl;
    }
}