16 #ifndef OPENSHOT_FFMPEG_READER_H
17 #define OPENSHOT_FFMPEG_READER_H
117 AVFormatContext *pFormatCtx;
118 int videoStream, audioStream;
119 AVCodecContext *pCodecCtx, *aCodecCtx;
121 AVBufferRef *hw_device_ctx = NULL;
123 AVStream *pStream, *aStream;
127 bool is_duration_known;
128 bool check_interlace;
130 int max_concurrent_frames;
140 std::shared_ptr<openshot::Frame> last_video_frame;
144 int64_t seeking_frame;
147 int64_t seek_audio_frame_found;
148 int64_t seek_video_frame_found;
151 int64_t largest_frame_processed;
152 int64_t current_video_frame;
157 double pts_offset_seconds;
158 double audio_pts_seconds;
159 double video_pts_seconds;
160 int64_t NO_PTS_OFFSET;
163 int hw_de_supported = 0;
165 AVPixelFormat hw_de_av_pix_fmt = AV_PIX_FMT_NONE;
166 AVHWDeviceType hw_de_av_device_type = AV_HWDEVICE_TYPE_NONE;
167 int IsHardwareDecodeSupported(
int codecid);
174 bool CheckSeek(
bool is_video);
177 void CheckWorkingFrames(int64_t requested_frame);
180 int64_t ConvertFrameToAudioPTS(int64_t frame_number);
183 int64_t ConvertFrameToVideoPTS(int64_t frame_number);
186 int64_t ConvertVideoPTStoFrame(int64_t pts);
189 std::shared_ptr<openshot::Frame> CreateFrame(int64_t requested_frame);
201 int64_t GetPacketPTS();
207 bool IsPartialFrame(int64_t requested_frame);
210 void ProcessVideoPacket(int64_t requested_frame);
213 void ProcessAudioPacket(int64_t requested_frame);
216 std::shared_ptr<openshot::Frame> ReadStream(int64_t requested_frame);
219 void RemoveAVFrame(AVFrame *);
222 void RemoveAVPacket(AVPacket *);
225 void Seek(int64_t requested_frame);
230 void UpdatePTSOffset();
233 void UpdateAudioInfo();
236 void UpdateVideoInfo();
252 FFmpegReader(
const std::string& path,
bool inspect_reader=
true);
258 void Close()
override;
267 std::shared_ptr<openshot::Frame>
GetFrame(int64_t requested_frame)
override;
270 bool IsOpen()
override {
return is_open; };
273 std::string
Name()
override {
return "FFmpegReader"; };
276 std::string
Json()
const override;
277 void SetJson(
const std::string value)
override;
282 void Open()
override;
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...
CacheMemory * GetCache() override
Get the cache object used by this reader.
void Open() override
Open File - which is called by the constructor automatically.
FFmpegReader(const std::string &path, bool inspect_reader=true)
Constructor for FFmpegReader.
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.
bool is_near(AudioLocation location, int samples_per_frame, int64_t amount)
This struct holds the packet counts and end-of-file detection for an openshot::FFmpegReader.
int64_t packets_decoded()