Program Listing for File VideoEncoder.hpp

Return to documentation for file (include/depthai/pipeline/node/VideoEncoder.hpp)

#pragma once

#include <depthai/pipeline/Node.hpp>

// shared
#include <depthai-shared/properties/VideoEncoderProperties.hpp>

namespace dai {
namespace node {

class VideoEncoder : public NodeCRTP<Node, VideoEncoder, VideoEncoderProperties> {
   public:
    constexpr static const char* NAME = "VideoEncoder";

    VideoEncoder(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId);
    VideoEncoder(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props);

    Input input{*this, "in", Input::Type::SReceiver, true, 4, true, {{DatatypeEnum::ImgFrame, true}}};

    Output bitstream{*this, "bitstream", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    Output out{*this, "out", Output::Type::MSender, {{DatatypeEnum::EncodedFrame, false}}};

    // Sets default options for a specified size and profile
    void setDefaultProfilePreset(float fps, Properties::Profile profile);

    [[deprecated("Input width/height no longer needed, automatically determined from first frame")]] void setDefaultProfilePreset(int width,
                                                                                                                                  int height,
                                                                                                                                  float fps,
                                                                                                                                  Properties::Profile profile);

    [[deprecated("Input size no longer needed, automatically determined from first frame")]] void setDefaultProfilePreset(std::tuple<int, int> size,
                                                                                                                          float fps,
                                                                                                                          Properties::Profile profile);

    // node properties
    void setNumFramesPool(int frames);

    int getNumFramesPool() const;

    // encoder properties
    void setRateControlMode(Properties::RateControlMode mode);
    void setProfile(Properties::Profile profile);
    [[deprecated("Input size no longer needed, automatically determined from first frame")]] void setProfile(std::tuple<int, int> size,
                                                                                                             Properties::Profile profile);
    [[deprecated("Input width/height no longer needed, automatically determined from first frame")]] void setProfile(int width,
                                                                                                                     int height,
                                                                                                                     Properties::Profile profile);
    void setBitrate(int bitrate);
    void setBitrateKbps(int bitrateKbps);

    void setKeyframeFrequency(int freq);

    void setNumBFrames(int numBFrames);

    void setQuality(int quality);

    void setLossless(bool lossless);

    void setFrameRate(float frameRate);

    void setMaxOutputFrameSize(int maxFrameSize);

    Properties::RateControlMode getRateControlMode() const;
    Properties::Profile getProfile() const;
    int getBitrate() const;
    int getBitrateKbps() const;
    int getKeyframeFrequency() const;
    // int getMaxBitrate() const;
    int getNumBFrames() const;
    int getQuality() const;
    [[deprecated("Input size no longer available, it's determined when first frame arrives")]] std::tuple<int, int> getSize() const;
    [[deprecated("Input size no longer available, it's determined when first frame arrives")]] int getWidth() const;
    [[deprecated("Input size no longer available, it's determined when first frame arrives")]] int getHeight() const;
    float getFrameRate() const;
    bool getLossless() const;
    int getMaxOutputFrameSize() const;
};

}  // namespace node
}  // namespace dai