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;
Header file for AudioLocation class.
Header file for CacheMemory class.
Header file for Clip class.
Header file for FFmpegUtilities.
Header file for OpenMPUtilities (set some common macros)
Header file for ReaderBase class.
Header file for global Settings class.
This class is a memory-based cache manager for Frame objects.
This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame...
void Open() override
Open File - which is called by the constructor automatically.
CacheMemory * GetCache() override
Get the cache object used by this reader.
Json::Value JsonValue() const override
Generate Json::Value for this object.
bool GetIsDurationKnown()
Return true if frame can be read with GetFrame()
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
CacheMemory final_cache
Final cache object used to hold final frames.
std::string Name() override
Return the type name of the class.
virtual ~FFmpegReader()
Destructor.
std::string Json() const override
Generate JSON string of this object.
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
void Close() override
Close File.
void SetJson(const std::string value) override
Load JSON string into this object.
bool IsOpen() override
Determine if reader is open or closed.
This abstract class is the base class, used by all readers in libopenshot.
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.
This struct holds the packet counts and end-of-file detection for an openshot::FFmpegReader.
int64_t packets_decoded()