OpenShot Library | libopenshot  0.1.9
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 ()
 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 ()
 Get the cache object used by this reader. More...
 
std::shared_ptr< FrameGetFrame (int64_t requested_frame)
 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 ()
 Determine if reader is open or closed. More...
 
string Json ()
 Get and Set JSON methods. More...
 
Json::Value JsonValue ()
 Generate Json::JsonValue for this object. More...
 
string Name ()
 Return the type name of the class. More...
 
void Open ()
 Open the internal reader. More...
 
void PrintMapping ()
 Print all of the original frames and which new frames they map to. More...
 
ReaderBaseReader ()
 Get 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 (string value)
 Load JSON string into this object. More...
 
void SetJsonValue (Json::Value root)
 Load Json::JsonValue into this object. More...
 
void SetTimelineFrameOffset (int64_t offset)
 
 ~FrameMapper ()
 Destructor. More...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo ()
 Display file information in the standard output stream (stdout) More...
 
 ReaderBase ()
 Constructor for the base reader, where many things are initialized. More...
 
void SetMaxSize (int width, int height)
 Set Max Image Size (used for performance optimization) More...
 

Public Attributes

vector< Fieldfields
 
vector< MappedFrameframes
 
- Public Attributes inherited from openshot::ReaderBase
ReaderInfo info
 Information about the current media file. More...
 

Additional Inherited Members

- Protected Attributes inherited from openshot::ReaderBase
CriticalSection getFrameCriticalSection
 Section lock for multiple threads. More...
 
int max_height
 The maximium image height needed by this clip (used for optimizations) More...
 
int max_width
 The maximum image width needed by this clip (used for optimizations) More...
 
CriticalSection processingCriticalSection
 

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 139 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 33 of file FrameMapper.cpp.

◆ ~FrameMapper()

FrameMapper::~FrameMapper ( )

Destructor.

Definition at line 63 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 717 of file FrameMapper.cpp.

◆ Close()

void FrameMapper::Close ( )
virtual

Close the openshot::FrameMapper and internal reader.

Implements openshot::ReaderBase.

Definition at line 639 of file FrameMapper.cpp.

◆ GetCache()

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

Get the cache object used by this reader.

Implements openshot::ReaderBase.

Definition at line 189 of file FrameMapper.h.

◆ GetFrame()

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

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 383 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 311 of file FrameMapper.cpp.

◆ IsOpen()

bool FrameMapper::IsOpen ( )
virtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 618 of file FrameMapper.cpp.

◆ Json()

string FrameMapper::Json ( )
virtual

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 662 of file FrameMapper.cpp.

◆ JsonValue()

Json::Value FrameMapper::JsonValue ( )
virtual

Generate Json::JsonValue for this object.

Implements openshot::ReaderBase.

Definition at line 669 of file FrameMapper.cpp.

◆ Name()

string openshot::FrameMapper::Name ( )
inlinevirtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 203 of file FrameMapper.h.

◆ Open()

void FrameMapper::Open ( )
virtual

Open the internal reader.

Implements openshot::ReaderBase.

Definition at line 627 of file FrameMapper.cpp.

◆ PrintMapping()

void FrameMapper::PrintMapping ( )

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

Definition at line 584 of file FrameMapper.cpp.

◆ Reader()

ReaderBase * FrameMapper::Reader ( )

Get the current reader.

Definition at line 70 of file FrameMapper.cpp.

◆ ResampleMappedAudio()

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

Resample audio and map channels (if needed)

Definition at line 766 of file FrameMapper.cpp.

◆ SetJson()

void FrameMapper::SetJson ( string  value)
virtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 680 of file FrameMapper.cpp.

◆ SetJsonValue()

void FrameMapper::SetJsonValue ( Json::Value  root)
virtual

Load Json::JsonValue into this object.

Implements openshot::ReaderBase.

Definition at line 703 of file FrameMapper.cpp.

◆ SetTimelineFrameOffset()

void FrameMapper::SetTimelineFrameOffset ( int64_t  offset)

Definition at line 754 of file FrameMapper.cpp.

Member Data Documentation

◆ fields

vector<Field> openshot::FrameMapper::fields

Definition at line 167 of file FrameMapper.h.

◆ frames

vector<MappedFrame> openshot::FrameMapper::frames

Definition at line 168 of file FrameMapper.h.


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