34 #ifndef OPENSHOT_FFMPEG_READER_H 35 #define OPENSHOT_FFMPEG_READER_H 97 AVFormatContext *pFormatCtx;
98 int i, videoStream, audioStream;
99 AVCodecContext *pCodecCtx, *aCodecCtx;
101 AVBufferRef *hw_device_ctx = NULL;
103 AVStream *pStream, *aStream;
107 bool is_duration_known;
108 bool check_interlace;
110 bool has_missing_frames;
111 int max_concurrent_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();
202 bool IsPartialFrame(int64_t requested_frame);
205 void ProcessVideoPacket(int64_t requested_frame);
208 void ProcessAudioPacket(int64_t requested_frame, int64_t target_frame,
int starting_sample);
211 std::shared_ptr<openshot::Frame> ReadStream(int64_t requested_frame);
214 void RemoveAVFrame(AVFrame *);
217 void RemoveAVPacket(AVPacket *);
220 void Seek(int64_t requested_frame);
223 void UpdatePTSOffset(
bool is_video);
226 void UpdateAudioInfo();
229 void UpdateVideoInfo();
245 FFmpegReader(
const std::string& path,
bool inspect_reader=
true);
251 void Close()
override;
260 std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame)
override;
263 bool IsOpen()
override {
return is_open; };
266 std::string
Name()
override {
return "FFmpegReader"; };
269 std::string Json()
const override;
270 void SetJson(
const std::string value)
override;
271 Json::Value JsonValue()
const override;
272 void SetJsonValue(
const Json::Value root)
override;
275 void Open()
override;
278 bool GetIsDurationKnown();
std::string Name() override
Return the type name of the class.
Header file for ReaderBase class.
CacheMemory * GetCache() override
Get the cache object used by this reader.
Header file for OpenMPUtilities (set some common macros)
bool is_near(AudioLocation location, int samples_per_frame, int64_t amount)
This abstract class is the base class, used by all readers in libopenshot.
Header file for CacheMemory class.
This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame...
Header file for Clip class.
bool IsOpen() override
Determine if reader is open or closed.
Header file for global Settings class.
This namespace is the default namespace for all code in the openshot library.
This struct holds the associated video frame and starting sample # for an audio packet.
CacheMemory final_cache
Final cache object used to hold final frames.
Header file for FFmpegUtilities.
This class is a memory-based cache manager for Frame objects.