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

This class creates a mapping between 2 different frame rates, applying a specific pull-down technique. More...

#include <FrameMapper.h>

Inheritance diagram for openshot::FrameMapper:
openshot::ReaderBase

Public Member Functions

void ChangeMapping (Fraction target_fps, PulldownType pulldown, int target_sample_rate, int target_channels, ChannelLayout target_channel_layout)
 Change frame rate or audio mapping details. More...
 
void Close () override
 Close the openshot::FrameMapper and internal reader. More...
 
 FrameMapper (ReaderBase *reader, Fraction target_fps, PulldownType target_pulldown, int target_sample_rate, int target_channels, ChannelLayout target_channel_layout)
 Default constructor for openshot::FrameMapper class. More...
 
CacheMemoryGetCache () override
 Get the cache object used by this reader. More...
 
std::shared_ptr< FrameGetFrame (int64_t requested_frame) override
 This method is required for all derived classes of ReaderBase, and return the openshot::Frame object, which contains the image and audio information for that frame of video. More...
 
MappedFrame GetMappedFrame (int64_t TargetFrameNumber)
 Get a frame based on the target frame rate and the new frame number of a frame. More...
 
bool IsOpen () override
 Determine if reader is open or closed. More...
 
std::string Json () const override
 Generate JSON string of this object. 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 the internal reader. More...
 
void PrintMapping (std::ostream *out=&std::cout)
 Print all of the original frames and which new frames they map to. More...
 
ReaderBaseReader ()
 Get the current reader. More...
 
void Reader (ReaderBase *new_reader)
 Set the current reader. More...
 
void ResampleMappedAudio (std::shared_ptr< Frame > frame, int64_t original_frame_number)
 Resample audio and map channels (if needed) 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 ~FrameMapper ()
 Destructor. More...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo (std::ostream *out=&std::cout)
 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

std::vector< Fieldfields
 
std::vector< MappedFrameframes
 
- 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...
 
std::recursive_mutex getFrameMutex
 Mutex for multiple threads. More...
 
std::recursive_mutex processingMutex
 

Detailed Description

This class creates a mapping between 2 different frame rates, applying a specific pull-down technique.

This class creates a mapping between 2 different video files, and supports many pull-down techniques, such as 2:3:2:3 or 2:3:3:2, and also supports inverse telecine. Pull-down techniques are only needed to remove artificial fields added when converting between 24 fps (film) and television fps (29.97 fps NTSC or 25 fps PAL).

The following graphic displays a how frame rates are mapped, and how time remapping affects the order of frames returned from the FrameMapper.

FrameMapper.png

Please see the following Example Code:

// Create a frame mapper for a reader, and convert the frame rate (from 24 fps to 29.97 fps)
FrameMapper mapping(reader, Fraction(30000, 1001), PULLDOWN_CLASSIC, 44100, 2, LAYOUT_STEREO);
std::shared_ptr<Frame> frame2 = mapping.GetFrame(2);
// If you need to change the mapping...
mapping.ChangeMapping(Fraction(24, 1), PULLDOWN_CLASSIC, 48000, 2, LAYOUT_MONO)

Definition at line 120 of file FrameMapper.h.

Constructor & Destructor Documentation

◆ FrameMapper()

FrameMapper::FrameMapper ( ReaderBase reader,
Fraction  target_fps,
PulldownType  target_pulldown,
int  target_sample_rate,
int  target_channels,
ChannelLayout  target_channel_layout 
)

Default constructor for openshot::FrameMapper class.

Definition at line 25 of file FrameMapper.cpp.

◆ ~FrameMapper()

FrameMapper::~FrameMapper ( )
virtual

Destructor.

Definition at line 52 of file FrameMapper.cpp.

Member Function Documentation

◆ ChangeMapping()

void FrameMapper::ChangeMapping ( Fraction  target_fps,
PulldownType  pulldown,
int  target_sample_rate,
int  target_channels,
ChannelLayout  target_channel_layout 
)

Change frame rate or audio mapping details.

Definition at line 755 of file FrameMapper.cpp.

Referenced by openshot::Timeline::GetMaxFrame().

◆ Close()

void FrameMapper::Close ( )
overridevirtual

Close the openshot::FrameMapper and internal reader.

Implements openshot::ReaderBase.

Definition at line 674 of file FrameMapper.cpp.

Referenced by SetJsonValue(), ~FrameMapper(), and openshot::Timeline::~Timeline().

◆ GetCache()

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

Get the cache object used by this reader.

Implements openshot::ReaderBase.

Definition at line 173 of file FrameMapper.h.

◆ GetFrame()

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

This method is required for all derived classes of ReaderBase, and return the openshot::Frame object, which contains the image and audio information for that frame of video.

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

Implements openshot::ReaderBase.

Definition at line 407 of file FrameMapper.cpp.

◆ GetMappedFrame()

MappedFrame FrameMapper::GetMappedFrame ( int64_t  TargetFrameNumber)

Get a frame based on the target frame rate and the new frame number of a frame.

Definition at line 323 of file FrameMapper.cpp.

Referenced by GetFrame().

◆ IsOpen()

bool FrameMapper::IsOpen ( )
overridevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 654 of file FrameMapper.cpp.

◆ Json()

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

Generate JSON string of this object.

Implements openshot::ReaderBase.

Definition at line 706 of file FrameMapper.cpp.

◆ JsonValue()

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

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 713 of file FrameMapper.cpp.

Referenced by Json().

◆ Name()

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

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 187 of file FrameMapper.h.

◆ Open()

void FrameMapper::Open ( )
overridevirtual

Open the internal reader.

Implements openshot::ReaderBase.

Definition at line 662 of file FrameMapper.cpp.

Referenced by SetJsonValue().

◆ PrintMapping()

void FrameMapper::PrintMapping ( std::ostream *  out = &std::cout)

Print all of the original frames and which new frames they map to.

Definition at line 628 of file FrameMapper.cpp.

◆ Reader() [1/2]

ReaderBase * FrameMapper::Reader ( )

Get the current reader.

Definition at line 61 of file FrameMapper.cpp.

Referenced by openshot::Timeline::ClearAllCache(), and openshot::Timeline::~Timeline().

◆ Reader() [2/2]

void openshot::FrameMapper::Reader ( ReaderBase new_reader)
inline

Set the current reader.

Definition at line 205 of file FrameMapper.h.

◆ ResampleMappedAudio()

void FrameMapper::ResampleMappedAudio ( std::shared_ptr< Frame frame,
int64_t  original_frame_number 
)

Resample audio and map channels (if needed)

Definition at line 796 of file FrameMapper.cpp.

Referenced by GetFrame().

◆ SetJson()

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

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 724 of file FrameMapper.cpp.

◆ SetJsonValue()

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

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 741 of file FrameMapper.cpp.

Referenced by SetJson().

Member Data Documentation

◆ fields

std::vector<Field> openshot::FrameMapper::fields

Definition at line 154 of file FrameMapper.h.

Referenced by Reader().

◆ frames

std::vector<MappedFrame> openshot::FrameMapper::frames

Definition at line 155 of file FrameMapper.h.

Referenced by GetMappedFrame(), PrintMapping(), and Reader().


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