OpenShot Library | libopenshot  0.2.5
Public Member Functions | Public Attributes | List of all members
openshot::FFmpegReader Class Reference

This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame objects for any frame in the file. More...

#include <FFmpegReader.h>

Inheritance diagram for openshot::FFmpegReader:
openshot::ReaderBase

Public Member Functions

void Close () override
 Close File. More...
 
 FFmpegReader (const std::string &path, bool inspect_reader=true)
 Constructor for FFmpegReader. More...
 
CacheMemoryGetCache () override
 Get the cache object used by this reader. More...
 
std::shared_ptr< openshot::FrameGetFrame (int64_t requested_frame) override
 
bool IsOpen () override
 Determine if reader is open or closed. More...
 
std::string Json () const override
 Get and Set JSON methods. More...
 
Json::Value JsonValue () const override
 Generate Json::Value for this object. More...
 
std::string Name () override
 Return the type name of the class. More...
 
void Open () override
 Open File - which is called by the constructor automatically. More...
 
void SetJson (const std::string value) override
 Load JSON string into this object. More...
 
void SetJsonValue (const Json::Value root) override
 Load Json::Value into this object. More...
 
virtual ~FFmpegReader ()
 Destructor. More...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo ()
 Display file information in the standard output stream (stdout) More...
 
openshot::ClipBaseParentClip ()
 Parent clip object of this reader (which can be unparented and NULL) More...
 
void ParentClip (openshot::ClipBase *new_clip)
 Set parent clip object of this reader. More...
 
 ReaderBase ()
 Constructor for the base reader, where many things are initialized. More...
 
virtual ~ReaderBase ()=default
 

Public Attributes

bool enable_seek
 
CacheMemory final_cache
 Final cache object used to hold final frames. More...
 
- Public Attributes inherited from openshot::ReaderBase
openshot::ReaderInfo info
 Information about the current media file. More...
 

Additional Inherited Members

- Protected Attributes inherited from openshot::ReaderBase
openshot::ClipBaseclip
 Pointer to the parent clip instance (if any) More...
 
juce::CriticalSection getFrameCriticalSection
 Section lock for multiple threads. More...
 
juce::CriticalSection processingCriticalSection
 

Detailed Description

This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame objects for any frame in the file.

All seeking and caching is handled internally, and the primary public interface is the GetFrame() method. To use this reader, simply create an instance of this class, and call the GetFrame method to start retrieving frames. Use the info struct to obtain information on the file, such as the length (# of frames), height, width, bit rate, frames per second (fps), etc...

// Create a reader for a video
openshot::FFmpegReader r("MyAwesomeVideo.webm");
r.Open(); // Open the reader
// Get frame number 1 from the video
std::shared_ptr<openshot::Frame> f = r.GetFrame(1);
// Now that we have an openshot::Frame object, lets have some fun!
f->Display(); // Display the frame on the screen
f->DisplayWaveform(); // Display the audio waveform as an image
f->Play(); // Play the audio through your speaker
// Close the reader
r.Close();

Definition at line 94 of file FFmpegReader.h.

Constructor & Destructor Documentation

◆ FFmpegReader()

FFmpegReader::FFmpegReader ( const std::string &  path,
bool  inspect_reader = true 
)

Constructor for FFmpegReader.

Sets (and possibly opens) the media file path, or throws an exception.

Parameters
pathThe filesystem location to load
inspect_readerif true (the default), automatically open the media file and loads frame 1.

Definition at line 89 of file FFmpegReader.cpp.

◆ ~FFmpegReader()

FFmpegReader::~FFmpegReader ( )
virtual

Destructor.

Definition at line 119 of file FFmpegReader.cpp.

Member Function Documentation

◆ Close()

void FFmpegReader::Close ( )
overridevirtual

Close File.

Implements openshot::ReaderBase.

Definition at line 564 of file FFmpegReader.cpp.

Referenced by FFmpegReader(), GetFrame(), SetJsonValue(), and ~FFmpegReader().

◆ GetCache()

CacheMemory* openshot::FFmpegReader::GetCache ( )
inlineoverridevirtual

Get the cache object used by this reader.

Implements openshot::ReaderBase.

Definition at line 251 of file FFmpegReader.h.

◆ GetFrame()

std::shared_ptr< Frame > FFmpegReader::GetFrame ( int64_t  requested_frame)
overridevirtual

Get a shared pointer to a openshot::Frame object for a specific frame number of this reader.

Returns
The requested frame of video
Parameters
requested_frameThe frame number that is requested.

Implements openshot::ReaderBase.

Definition at line 804 of file FFmpegReader.cpp.

◆ IsOpen()

bool openshot::FFmpegReader::IsOpen ( )
inlineoverridevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 260 of file FFmpegReader.h.

◆ Json()

std::string FFmpegReader::Json ( ) const
overridevirtual

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 2445 of file FFmpegReader.cpp.

◆ JsonValue()

Json::Value FFmpegReader::JsonValue ( ) const
overridevirtual

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 2452 of file FFmpegReader.cpp.

Referenced by Json().

◆ Name()

std::string openshot::FFmpegReader::Name ( )
inlineoverridevirtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 263 of file FFmpegReader.h.

◆ Open()

void FFmpegReader::Open ( )
overridevirtual

Open File - which is called by the constructor automatically.

Implements openshot::ReaderBase.

Definition at line 226 of file FFmpegReader.cpp.

Referenced by FFmpegReader(), GetFrame(), and SetJsonValue().

◆ SetJson()

void FFmpegReader::SetJson ( const std::string  value)
overridevirtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 2464 of file FFmpegReader.cpp.

◆ SetJsonValue()

void FFmpegReader::SetJsonValue ( const Json::Value  root)
overridevirtual

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 2479 of file FFmpegReader.cpp.

Referenced by SetJson().

Member Data Documentation

◆ enable_seek

bool openshot::FFmpegReader::enable_seek

Enable or disable seeking. Seeking can more quickly locate the requested frame, but some codecs have trouble seeking, and can introduce artifacts or blank images into the video.

Definition at line 234 of file FFmpegReader.h.

Referenced by GetFrame().

◆ final_cache

CacheMemory openshot::FFmpegReader::final_cache

Final cache object used to hold final frames.

Definition at line 230 of file FFmpegReader.h.

Referenced by FFmpegReader(), and GetFrame().


The documentation for this class was generated from the following files: