16 #ifndef OPENSHOT_FFMPEG_READER_H 17 #define OPENSHOT_FFMPEG_READER_H 59 int64_t video_read = 0;
60 int64_t video_decoded = 0;
61 int64_t audio_read = 0;
62 int64_t audio_decoded = 0;
65 bool video_eof =
true;
66 bool audio_eof =
true;
67 bool packets_eof =
true;
68 bool end_of_file =
true;
72 return video_read + audio_read;
77 return video_decoded + audio_decoded;
82 video_read = 0; video_decoded = 0; audio_read = 0; audio_decoded = 0;
83 video_eof = eof; audio_eof = eof; packets_eof = eof; end_of_file = eof;
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;
278 Json::Value JsonValue()
const override;
279 void SetJsonValue(
const Json::Value root)
override;
282 void Open()
override;
285 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.
This struct holds the packet counts and end-of-file detection for an openshot::FFmpegReader.
CacheMemory final_cache
Final cache object used to hold final frames.
int64_t packets_decoded()
Header file for FFmpegUtilities.
This class is a memory-based cache manager for Frame objects.