UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VideoEncoder.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "CoreMinimal.h"
8#include "HAL/Platform.h"
9#include "Misc/FrameRate.h"
10#include "Misc/ScopeLock.h"
11#include "Templates/Function.h"
14#include "VideoEncoderInput.h"
15
16namespace AVEncoder
17{
18 class FCodecPacket;
19 class FVideoEncoderInput;
20 class FVideoEncoderInputFrame;
21
22 class UE_DEPRECATED(5.4, "AVEncoder has been deprecated. Please use the AVCodecs plugin family instead.") FVideoEncoder
23 {
24 public:
25 enum class RateControlMode { UNKNOWN, CONSTQP, VBR, CBR };
26 enum class MultipassMode { UNKNOWN, DISABLED, QUARTER, FULL };
28
29 struct UE_DEPRECATED(5.4, "AVEncoder has been deprecated. Please use the AVCodecs plugin family instead.") FLayerConfig
30 {
31 uint32 Width = 0;
32 uint32 Height = 0;
34 int32 MaxBitrate = 0;
36 int32 QPMax = -1;
37 int32 QPMin = -1;
38 RateControlMode RateControlMode = RateControlMode::CBR;
39 MultipassMode MultipassMode = MultipassMode::FULL;
40 bool FillData = false;
41 H264Profile H264Profile = H264Profile::BASELINE;
42
43 bool operator==(FLayerConfig const& other) const
44 {
45 return Width == other.Width
46 && Height == other.Height
47 && MaxFramerate == other.MaxFramerate
48 && MaxBitrate == other.MaxBitrate
49 && TargetBitrate == other.TargetBitrate
50 && QPMax == other.QPMax
51 && QPMin == other.QPMin
52 && RateControlMode == other.RateControlMode
53 && MultipassMode == other.MultipassMode
54 && FillData == other.FillData
55 && H264Profile == other.H264Profile;
56 }
57
58 bool operator!=(FLayerConfig const& other) const
59 {
60 return !(*this == other);
61 }
62 };
63
65
67 virtual bool Setup(TSharedRef<FVideoEncoderInput> input, FLayerConfig const& config) { return false; }
69 virtual void Shutdown() {}
70
71 AVENCODER_API virtual bool AddLayer(FLayerConfig const& config);
72 uint32 GetNumLayers() const { return static_cast<uint32>(Layers.Num()); }
73 virtual uint32 GetMaxLayers() const { return 1; }
74
77
79 using OnFrameEncodedCallback = TFunction<void(const TSharedPtr<FVideoEncoderInputFrame> /* InCompletedFrame */)>;
80 using OnEncodedPacketCallback = TFunction<void(uint32 /* LayerIndex */, const TSharedPtr<FVideoEncoderInputFrame> /* Frame */, const FCodecPacket& /* Packet */)>;
82
83 struct UE_DEPRECATED(5.4, "AVEncoder has been deprecated. Please use the AVCodecs plugin family instead.") FEncodeOptions
84 {
85 bool bForceKeyFrame = false;
87 };
88
90 void ClearOnEncodedPacket() { OnEncodedPacket = nullptr; }
91
93 virtual void Encode(const TSharedPtr<FVideoEncoderInputFrame> frame, FEncodeOptions const& options) {}
95
96 protected:
97 FVideoEncoder() = default;
98
99 class UE_DEPRECATED(5.4, "AVEncoder has been deprecated. Please use the AVCodecs plugin family instead.") FLayer
100 {
101 public:
102 explicit FLayer(FLayerConfig const& layerConfig)
105 {}
106 virtual ~FLayer() = default;
107
108 FLayerConfig const& GetConfig() const { return CurrentConfig; }
109 void UpdateConfig(FLayerConfig const& config)
110 {
113 NeedsReconfigure = true;
114 }
115
116 protected:
119 bool NeedsReconfigure;
120 };
121
122 virtual FLayer* CreateLayer(uint32 layerIdx, FLayerConfig const& config) { return nullptr; }
123 virtual void DestroyLayer(FLayer* layer) {};
124
125 TArray<FLayer*> Layers;
127 };
128}
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
UE_FORCEINLINE_HINT bool operator!=(const FIndexedPointer &Other) const
Definition LockFreeList.h:76
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ScopeLock.h:141
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition AudioEncoder.cpp:7
@ UNKNOWN
Definition SoundFileIOEnums.h:235
@ config
Definition ObjectMacros.h:860
bool operator==(const FCachedAssetKey &A, const FCachedAssetKey &B)
Definition AssetDataMap.h:501
float Encode(EEncoding SourceEncoding, float Value)
Definition TransferFunctions.cpp:51
UTickableTransformConstraint * GetConfig(const UClass *InConstraintClass)
Definition TransformConstraintUtil.cpp:878
@ false
Definition radaudio_common.h:23