Class VideoEncoder

Synopsis

#include <Source/Falcor/Utils/Video/VideoEncoder.h>

class dlldecl VideoEncoder

Description

No description yet.

Structures

Desc

Methods

~VideoEncoder
appendFrame
createCreate a video encoder.
endCapture
getSupportedContainerForCodec
isFormatSupported

Source

Lines 38-94 in Source/Falcor/Utils/Video/VideoEncoder.h.

class dlldecl VideoEncoder
{
public:
    using UniquePtr = std::unique_ptr<VideoEncoder>;
    using UniqueConstPtr = std::unique_ptr<const VideoEncoder>;
    enum class Codec : int32_t
    {
        Raw,
        H264,
        HEVC,
        MPEG2,
        MPEG4,
    };
    struct Desc
    {
        uint32_t fps = 60;
        uint32_t width = 0;
        uint32_t height = 0;
        float bitrateMbps = 4;
        uint32_t gopSize = 10;
        Codec codec = Codec::Raw;
        ResourceFormat format = ResourceFormat::BGRA8UnormSrgb;
        bool flipY = false;
        std::string filename;
    };
    ~VideoEncoder();
    /** Create a video encoder.
        \param[in] desc Encoder settings.
        \return A new encoder object, or returns nullptr on error. For example, due unsupported encoder settings.
    */
    static UniquePtr create(const Desc& desc);
    void appendFrame(const void* pData);
    void endCapture();
    static bool isFormatSupported(ResourceFormat format);
    static FileDialogFilterVec getSupportedContainerForCodec(Codec codec);
private:
    VideoEncoder(const std::string& filename);
    bool init(const Desc& desc);
    AVFormatContext* mpOutputContext = nullptr;
    AVStream*        mpOutputStream  = nullptr;
    AVFrame*         mpFrame         = nullptr;
    SwsContext*      mpSwsContext    = nullptr;
    AVCodecContext*  mpCodecContext = nullptr;
    const std::string mFilename;
    ResourceFormat mFormat;
    uint32_t mRowPitch = 0;
    uint8_t* mpFlippedImage = nullptr; // Used in case the image memory layout if bottom->top
};





Add Discussion as Guest

Log in to DocsForge