Warning, file /include/opencascade/Image_VideoRecorder.hxx was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef Image_VideoRecorder_HeaderFile_
0017 #define Image_VideoRecorder_HeaderFile_
0018
0019 #include <Image_PixMap.hxx>
0020 #include <TCollection_AsciiString.hxx>
0021 #include <NCollection_DataMap.hxx>
0022 #include <Standard_Transient.hxx>
0023
0024
0025 struct AVFormatContext;
0026 struct AVCodecContext;
0027 struct AVStream;
0028 struct AVCodec;
0029 struct AVFrame;
0030 struct SwsContext;
0031
0032
0033
0034
0035 #ifdef PixelFormat
0036 #undef PixelFormat
0037 #endif
0038
0039
0040
0041 struct Image_VideoParams
0042 {
0043
0044 TCollection_AsciiString Format;
0045 TCollection_AsciiString VideoCodec;
0046 TCollection_AsciiString PixelFormat;
0047
0048 int Width;
0049 int Height;
0050 int FpsNum;
0051 int FpsDen;
0052 NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>
0053 VideoCodecParams;
0054
0055
0056 Image_VideoParams()
0057 : Width(0),
0058 Height(0),
0059 FpsNum(0),
0060 FpsDen(1)
0061 {
0062 }
0063
0064
0065 void SetFramerate(const int theNumerator, const int theDenominator)
0066 {
0067 FpsNum = theNumerator;
0068 FpsDen = theDenominator;
0069 }
0070
0071
0072
0073
0074 void SetFramerate(const int theValue)
0075 {
0076 FpsNum = theValue;
0077 FpsDen = 1;
0078 }
0079 };
0080
0081
0082 class Image_VideoRecorder : public Standard_Transient
0083 {
0084 DEFINE_STANDARD_RTTIEXT(Image_VideoRecorder, Standard_Transient)
0085 public:
0086
0087 Standard_EXPORT Image_VideoRecorder();
0088
0089
0090 Standard_EXPORT ~Image_VideoRecorder() override;
0091
0092
0093 Standard_EXPORT void Close();
0094
0095
0096
0097
0098 Standard_EXPORT bool Open(const char* theFileName, const Image_VideoParams& theParams);
0099
0100
0101
0102 Image_PixMap& ChangeFrame() { return myImgSrcRgba; }
0103
0104
0105 int64_t FrameCount() const { return myFrameCount; }
0106
0107
0108 bool PushFrame() { return writeVideoFrame(false); }
0109
0110 protected:
0111
0112 Standard_EXPORT TCollection_AsciiString formatAvError(const int theError) const;
0113
0114
0115 Standard_EXPORT AVCodecContext* getCodecContext() const;
0116
0117
0118
0119
0120 Standard_EXPORT bool addVideoStream(const Image_VideoParams& theParams, const int theDefCodecId);
0121
0122
0123 Standard_EXPORT bool openVideoCodec(const Image_VideoParams& theParams);
0124
0125
0126 Standard_EXPORT bool writeVideoFrame(const bool theToFlush);
0127
0128 protected:
0129
0130 struct VideoRational
0131 {
0132 int num;
0133 int den;
0134 };
0135
0136 protected:
0137 AVFormatContext* myAVContext;
0138 AVStream* myVideoStream;
0139 AVCodec* myVideoCodec;
0140 AVCodecContext* myCodecCtx;
0141 AVFrame* myFrame;
0142 SwsContext* myScaleCtx;
0143
0144 Image_PixMap myImgSrcRgba;
0145 VideoRational myFrameRate;
0146 int64_t myFrameCount;
0147 };
0148
0149 #endif