16 #ifndef OPENSHOT_FFMPEG_READER_H
17 #define OPENSHOT_FFMPEG_READER_H
105 AVFormatContext *pFormatCtx;
106 int videoStream, audioStream;
107 AVCodecContext *pCodecCtx, *aCodecCtx;
109 AVBufferRef *hw_device_ctx = NULL;
111 AVStream *pStream, *aStream;
115 bool is_duration_known;
116 bool check_interlace;
118 int max_concurrent_frames;
128 std::shared_ptr<openshot::Frame> last_video_frame;
132 int64_t seeking_frame;
135 int64_t seek_audio_frame_found;
136 int64_t seek_video_frame_found;
139 int64_t largest_frame_processed;
140 int64_t current_video_frame;
145 double pts_offset_seconds;
146 double audio_pts_seconds;
147 double video_pts_seconds;
148 int64_t NO_PTS_OFFSET;
151 int hw_de_supported = 0;
153 AVPixelFormat hw_de_av_pix_fmt = AV_PIX_FMT_NONE;
154 AVHWDeviceType hw_de_av_device_type = AV_HWDEVICE_TYPE_NONE;
155 int IsHardwareDecodeSupported(
int codecid);
162 bool CheckSeek(
bool is_video);
165 void CheckWorkingFrames(int64_t requested_frame);
168 int64_t ConvertFrameToAudioPTS(int64_t frame_number);
171 int64_t ConvertFrameToVideoPTS(int64_t frame_number);
174 int64_t ConvertVideoPTStoFrame(int64_t pts);
177 std::shared_ptr<openshot::Frame> CreateFrame(int64_t requested_frame);
189 int64_t GetPacketPTS();
195 bool IsPartialFrame(int64_t requested_frame);
198 void ProcessVideoPacket(int64_t requested_frame);
201 void ProcessAudioPacket(int64_t requested_frame);
204 std::shared_ptr<openshot::Frame> ReadStream(int64_t requested_frame);
207 void RemoveAVFrame(AVFrame *);
210 void RemoveAVPacket(AVPacket *);
213 void Seek(int64_t requested_frame);
218 void UpdatePTSOffset();
221 void UpdateAudioInfo();
224 void UpdateVideoInfo();
240 FFmpegReader(
const std::string& path,
bool inspect_reader=
true);
246 void Close()
override;
255 std::shared_ptr<openshot::Frame>
GetFrame(int64_t requested_frame)
override;
258 bool IsOpen()
override {
return is_open; };
261 std::string
Name()
override {
return "FFmpegReader"; };
264 std::string
Json()
const override;
265 void SetJson(
const std::string value)
override;
270 void Open()
override;