34 #ifndef OPENSHOT_FFMPEG_READER_H
35 #define OPENSHOT_FFMPEG_READER_H
98 AVFormatContext *pFormatCtx;
99 int i, videoStream, audioStream;
100 AVCodecContext *pCodecCtx, *aCodecCtx;
102 AVBufferRef *hw_device_ctx = NULL;
104 AVStream *pStream, *aStream;
108 bool is_duration_known;
109 bool check_interlace;
111 bool has_missing_frames;
115 std::map<int64_t, int64_t> processing_video_frames;
116 std::multimap<int64_t, int64_t> processing_audio_frames;
117 std::map<int64_t, int64_t> processed_video_frames;
118 std::map<int64_t, int64_t> processed_audio_frames;
119 std::multimap<int64_t, int64_t> missing_video_frames;
120 std::multimap<int64_t, int64_t> missing_video_frames_source;
121 std::multimap<int64_t, int64_t> missing_audio_frames;
122 std::multimap<int64_t, int64_t> missing_audio_frames_source;
123 std::map<int64_t, int> checked_frames;
131 int64_t num_packets_since_video_frame;
132 int64_t num_checks_since_final;
133 std::shared_ptr<openshot::Frame> last_video_frame;
137 int64_t seeking_frame;
140 int64_t seek_audio_frame_found;
141 int64_t seek_video_frame_found;
143 int64_t audio_pts_offset;
144 int64_t video_pts_offset;
146 int64_t largest_frame_processed;
147 int64_t current_video_frame;
149 int hw_de_supported = 0;
151 AVPixelFormat hw_de_av_pix_fmt = AV_PIX_FMT_NONE;
152 AVHWDeviceType hw_de_av_device_type = AV_HWDEVICE_TYPE_NONE;
153 int IsHardwareDecodeSupported(
int codecid);
160 bool CheckSeek(
bool is_video);
163 bool CheckMissingFrame(int64_t requested_frame);
166 void CheckWorkingFrames(
bool end_of_stream, int64_t requested_frame);
169 int64_t ConvertFrameToAudioPTS(int64_t frame_number);
172 int64_t ConvertFrameToVideoPTS(int64_t frame_number);
175 int64_t ConvertVideoPTStoFrame(int64_t pts);
178 std::shared_ptr<openshot::Frame> CreateFrame(int64_t requested_frame);
190 int64_t GetSmallestVideoFrame();
193 int64_t GetSmallestAudioFrame();
196 int64_t GetVideoPTS();
199 bool IsPartialFrame(int64_t requested_frame);
202 void ProcessVideoPacket(int64_t requested_frame);
205 void ProcessAudioPacket(int64_t requested_frame, int64_t target_frame,
int starting_sample);
208 std::shared_ptr<openshot::Frame> ReadStream(int64_t requested_frame);
211 void RemoveAVFrame(AVFrame *);
214 void RemoveAVPacket(AVPacket *);
217 void Seek(int64_t requested_frame);
220 void UpdatePTSOffset(
bool is_video);
223 void UpdateAudioInfo();
226 void UpdateVideoInfo();
258 std::shared_ptr<openshot::Frame>
GetFrame(int64_t requested_frame);
264 std::string
Name() {
return "FFmpegReader"; };
267 std::string
Json()
const override;
268 void SetJson(
const std::string value);