You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
1) Added EffectBase (base class of all effects)
2) Improved SWIG bindings to include std::list and std::vector 3) Added Effects list Timeline
This commit is contained in:
+47
-47
@@ -113,11 +113,11 @@ namespace openshot {
|
||||
*/
|
||||
class Clip {
|
||||
private:
|
||||
float position; ///<The position of the timeline where this clip should start playing
|
||||
int layer; ///<The layer this clip is on. Lower clips are covered up by higher clips.
|
||||
float start; ///<The position in seconds to start playing (used to trim the beginning of a clip)
|
||||
float end; ///<The position in seconds to end playing (used to trim the ending of a clip)
|
||||
bool waveform; ///<Should a waveform be used instead of the clip's image
|
||||
float position; ///< The position on the timeline where this clip should start playing
|
||||
int layer; ///< The layer this clip is on. Lower clips are covered up by higher clips.
|
||||
float start; ///< The position in seconds to start playing (used to trim the beginning of a clip)
|
||||
float end; ///< The position in seconds to end playing (used to trim the ending of a clip)
|
||||
bool waveform; ///< Should a waveform be used instead of the clip's image
|
||||
|
||||
// Audio resampler (if time mapping)
|
||||
AudioResampler *resampler;
|
||||
@@ -133,10 +133,10 @@ namespace openshot {
|
||||
string get_file_extension(string path);
|
||||
|
||||
/// Adjust the audio and image of a time mapped frame
|
||||
tr1::shared_ptr<Frame> get_time_mapped_frame(tr1::shared_ptr<Frame> frame, int frame_number);
|
||||
tr1::shared_ptr<Frame> get_time_mapped_frame(tr1::shared_ptr<Frame> frame, int frame_number) throw(ReaderClosed);
|
||||
|
||||
/// Calculate the # of samples per video frame (for a specific frame number)
|
||||
int GetSamplesPerFrame(int frame_number, Fraction rate);
|
||||
int GetSamplesPerFrame(int frame_number, Fraction rate) throw(ReaderClosed);
|
||||
|
||||
/// Init default settings for a clip
|
||||
void init_settings();
|
||||
@@ -145,9 +145,9 @@ namespace openshot {
|
||||
void reverse_buffer(juce::AudioSampleBuffer* buffer);
|
||||
|
||||
public:
|
||||
GravityType gravity; ///<The gravity of a clip determines where it snaps to it's parent
|
||||
ScaleType scale; ///<The scale determines how a clip should be resized to fit it's parent
|
||||
AnchorType anchor; ///<The anchor determines what parent a clip should snap to
|
||||
GravityType gravity; ///< The gravity of a clip determines where it snaps to it's parent
|
||||
ScaleType scale; ///< The scale determines how a clip should be resized to fit it's parent
|
||||
AnchorType anchor; ///< The anchor determines what parent a clip should snap to
|
||||
|
||||
// Compare a clip using the Position() property
|
||||
bool operator< ( Clip& a) { return (Position() < a.Position()); }
|
||||
@@ -167,7 +167,7 @@ namespace openshot {
|
||||
Clip(ReaderBase* reader);
|
||||
|
||||
/// Close the internal reader
|
||||
void Close();
|
||||
void Close() throw(ReaderClosed);
|
||||
|
||||
/// @brief Get an openshot::Frame object for a specific frame number of this timeline.
|
||||
///
|
||||
@@ -176,65 +176,65 @@ namespace openshot {
|
||||
tr1::shared_ptr<Frame> GetFrame(int requested_frame) throw(ReaderClosed);
|
||||
|
||||
/// Open the internal reader
|
||||
void Open() throw(InvalidFile);
|
||||
void Open() throw(InvalidFile, ReaderClosed);
|
||||
|
||||
/// @brief Set the current reader
|
||||
/// @param reader The reader to be used by this clip
|
||||
void Reader(ReaderBase* reader);
|
||||
|
||||
/// Get the current reader
|
||||
ReaderBase* Reader();
|
||||
ReaderBase* Reader() throw(ReaderClosed);
|
||||
|
||||
/// Get basic properties
|
||||
float Position() { return position; } ///<Get position on timeline
|
||||
int Layer() { return layer; } ///<Get layer of clip on timeline (lower number is covered by higher numbers)
|
||||
float Start() { return start; } ///<Get start position of clip (trim start of video)
|
||||
float End(); ///<Get end position of clip (trim end of video), which can be affected by the time curve.
|
||||
float Duration() { return End() - Start(); } ///<Get the length of this clip (in seconds)
|
||||
bool Waveform() { return waveform; } ///<Get the waveform property of this clip
|
||||
float Position() { return position; } ///< Get position on timeline (in seconds)
|
||||
int Layer() { return layer; } ///< Get layer of clip on timeline (lower number is covered by higher numbers)
|
||||
float Start() { return start; } ///< Get start position (in seconds) of clip (trim start of video)
|
||||
float End() throw(ReaderClosed); ///< Get end position (in seconds) of clip (trim end of video), which can be affected by the time curve.
|
||||
float Duration() { return End() - Start(); } ///< Get the length of this clip (in seconds)
|
||||
bool Waveform() { return waveform; } ///< Get the waveform property of this clip
|
||||
|
||||
/// Set basic properties
|
||||
void Position(float value) { position = value; } ///<Get position on timeline
|
||||
void Layer(int value) { layer = value; } ///<Get layer of clip on timeline (lower number is covered by higher numbers)
|
||||
void Start(float value) { start = value; } ///<Get start position of clip (trim start of video)
|
||||
void End(float value) { end = value; } ///<Get end position of clip (trim end of video)
|
||||
void Waveform(bool value) { waveform = value; } ///<Set the waveform property of this clip
|
||||
void Position(float value) { position = value; } ///< Set position on timeline (in seconds)
|
||||
void Layer(int value) { layer = value; } ///< Set layer of clip on timeline (lower number is covered by higher numbers)
|
||||
void Start(float value) { start = value; } ///< Set start position (in seconds) of clip (trim start of video)
|
||||
void End(float value) { end = value; } ///< Set end position (in seconds) of clip (trim end of video)
|
||||
void Waveform(bool value) { waveform = value; } ///< Set the waveform property of this clip
|
||||
|
||||
// Scale and Location curves
|
||||
Keyframe scale_x; ///<Curve representing the horizontal scaling in percent (0 to 100)
|
||||
Keyframe scale_y; ///<Curve representing the vertical scaling in percent (0 to 100)
|
||||
Keyframe location_x; ///<Curve representing the relative X position in percent based on the gravity (-100 to 100)
|
||||
Keyframe location_y; ///<Curve representing the relative Y position in percent based on the gravity (-100 to 100)
|
||||
Keyframe scale_x; ///< Curve representing the horizontal scaling in percent (0 to 100)
|
||||
Keyframe scale_y; ///< Curve representing the vertical scaling in percent (0 to 100)
|
||||
Keyframe location_x; ///< Curve representing the relative X position in percent based on the gravity (-100 to 100)
|
||||
Keyframe location_y; ///< Curve representing the relative Y position in percent based on the gravity (-100 to 100)
|
||||
|
||||
// Alpha and Rotation curves
|
||||
Keyframe alpha; ///<Curve representing the alpha or transparency (0 to 100)
|
||||
Keyframe rotation; ///<Curve representing the rotation (0 to 360)
|
||||
Keyframe alpha; ///< Curve representing the alpha or transparency (0 to 100)
|
||||
Keyframe rotation; ///< Curve representing the rotation (0 to 360)
|
||||
|
||||
// Time and Volume curves
|
||||
Keyframe time; ///<Curve representing the frames over time to play (used for speed and direction of video)
|
||||
Keyframe volume; ///<Curve representing the volume (0 to 1)
|
||||
Keyframe time; ///< Curve representing the frames over time to play (used for speed and direction of video)
|
||||
Keyframe volume; ///< Curve representing the volume (0 to 1)
|
||||
|
||||
/// Curve representing the color of the audio wave form
|
||||
Color wave_color;
|
||||
|
||||
// Crop settings and curves
|
||||
GravityType crop_gravity; ///<Cropping needs to have a gravity to determine what side we are cropping
|
||||
Keyframe crop_width; ///<Curve representing width in percent (0.0=0%, 1.0=100%)
|
||||
Keyframe crop_height; ///<Curve representing height in percent (0.0=0%, 1.0=100%)
|
||||
Keyframe crop_x; ///<Curve representing X offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%)
|
||||
Keyframe crop_y; ///<Curve representing Y offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%)
|
||||
GravityType crop_gravity; ///< Cropping needs to have a gravity to determine what side we are cropping
|
||||
Keyframe crop_width; ///< Curve representing width in percent (0.0=0%, 1.0=100%)
|
||||
Keyframe crop_height; ///< Curve representing height in percent (0.0=0%, 1.0=100%)
|
||||
Keyframe crop_x; ///< Curve representing X offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%)
|
||||
Keyframe crop_y; ///< Curve representing Y offset in percent (-1.0=-100%, 0.0=0%, 1.0=100%)
|
||||
|
||||
// Shear and perspective curves
|
||||
Keyframe shear_x; ///<Curve representing X shear angle in degrees (-45.0=left, 45.0=right)
|
||||
Keyframe shear_y; ///<Curve representing Y shear angle in degrees (-45.0=down, 45.0=up)
|
||||
Keyframe perspective_c1_x; ///<Curves representing X for coordinate 1
|
||||
Keyframe perspective_c1_y; ///<Curves representing Y for coordinate 1
|
||||
Keyframe perspective_c2_x; ///<Curves representing X for coordinate 2
|
||||
Keyframe perspective_c2_y; ///<Curves representing Y for coordinate 2
|
||||
Keyframe perspective_c3_x; ///<Curves representing X for coordinate 3
|
||||
Keyframe perspective_c3_y; ///<Curves representing Y for coordinate 3
|
||||
Keyframe perspective_c4_x; ///<Curves representing X for coordinate 4
|
||||
Keyframe perspective_c4_y; ///<Curves representing Y for coordinate 4
|
||||
Keyframe shear_x; ///< Curve representing X shear angle in degrees (-45.0=left, 45.0=right)
|
||||
Keyframe shear_y; ///< Curve representing Y shear angle in degrees (-45.0=down, 45.0=up)
|
||||
Keyframe perspective_c1_x; ///< Curves representing X for coordinate 1
|
||||
Keyframe perspective_c1_y; ///< Curves representing Y for coordinate 1
|
||||
Keyframe perspective_c2_x; ///< Curves representing X for coordinate 2
|
||||
Keyframe perspective_c2_y; ///< Curves representing Y for coordinate 2
|
||||
Keyframe perspective_c3_x; ///< Curves representing X for coordinate 3
|
||||
Keyframe perspective_c3_y; ///< Curves representing Y for coordinate 3
|
||||
Keyframe perspective_c4_x; ///< Curves representing X for coordinate 4
|
||||
Keyframe perspective_c4_y; ///< Curves representing Y for coordinate 4
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Header file for EffectBase class
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2013 OpenShot Studios, LLC
|
||||
* (http://www.openshotstudios.com). This file is part of
|
||||
* OpenShot Library (http://www.openshot.org), an open-source project
|
||||
* dedicated to delivering high quality video editing and animation solutions
|
||||
* to the world.
|
||||
*
|
||||
* OpenShot Library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPENSHOT_EFFECT_BASE_H
|
||||
#define OPENSHOT_EFFECT_BASE_H
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <tr1/memory>
|
||||
#include "Frame.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace openshot
|
||||
{
|
||||
/**
|
||||
* @brief This struct contains info about an effect, such as the name, video or audio effect, etc...
|
||||
*
|
||||
* Each derived class of EffectBase is responsible for updating this struct to reflect accurate information
|
||||
* about the underlying effect. Derived classes of EffectBase should call the InitEffectInfo() method to initialize the
|
||||
* default values of this struct.
|
||||
*/
|
||||
struct EffectInfo
|
||||
{
|
||||
string name; ///< The name of the effect
|
||||
string description; ///< The description of this effect and what it does
|
||||
bool has_video; ///< Determines if this effect manipulates the image of a frame
|
||||
bool has_audio; ///< Determines if this effect manipulates the audio of a frame
|
||||
float position; ///< The position on the clip (in seconds) where this effect should start being applied
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This abstract class is the base class, used by all effects in libopenshot.
|
||||
*
|
||||
* Effects are types of classes that manipulate the image or audio data of an openshot::Frame object.
|
||||
* The only requirements for an 'effect', is to derive from this base class, implement the Apply()
|
||||
* method, and call the InitEffectInfo() method.
|
||||
*/
|
||||
class EffectBase
|
||||
{
|
||||
public:
|
||||
/// Information about the current effect
|
||||
EffectInfo info;
|
||||
|
||||
/// Display effect information in the standard output stream (stdout)
|
||||
void DisplayInfo();
|
||||
|
||||
/// This method is required for all derived classes of EffectBase, and returns a
|
||||
/// new openshot::Frame object, which is made by copying the image and audio
|
||||
/// of the original frame, and modifying the image or audio data.
|
||||
///
|
||||
/// @returns The requested frame of a clip (a new openshot::Frame object with copied data)
|
||||
/// @param number The frame number of the clip that is requested (and needs the effect applied).
|
||||
virtual tr1::shared_ptr<Frame> GetFrame(int number) = 0;
|
||||
|
||||
/// This method is required for all derived classes of EffectBase, and returns the
|
||||
/// original openshot::Frame object, but first modifies the original frame's image or
|
||||
/// audio data.
|
||||
///
|
||||
/// @returns The requested frame of a clip (the original openshot::Frame object with modified data)
|
||||
/// @param number The frame number of the clip that is requested (and needs the effect applied).
|
||||
virtual tr1::shared_ptr<Frame> Apply(int number) = 0;
|
||||
|
||||
/// Initialize the values of the EffectInfo struct. It is important for derived classes to call
|
||||
/// this method, or the EffectInfo struct values will not be initialized.
|
||||
void InitEffectInfo();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -129,8 +129,6 @@ namespace openshot
|
||||
*/
|
||||
class FrameMapper : public ReaderBase {
|
||||
private:
|
||||
vector<Field> fields; // List of all fields
|
||||
vector<MappedFrame> frames; // List of all frames
|
||||
bool field_toggle; // Internal odd / even toggle (used when building the mapping)
|
||||
Framerate original; // The original frame rate
|
||||
Framerate target; // The target frame rate
|
||||
@@ -152,6 +150,10 @@ namespace openshot
|
||||
int GetSamplesPerFrame(int frame_number, Fraction rate);
|
||||
|
||||
public:
|
||||
// Init some containers
|
||||
vector<Field> fields; // List of all fields
|
||||
vector<MappedFrame> frames; // List of all frames
|
||||
|
||||
/// Default constructor for FrameMapper class
|
||||
FrameMapper(ReaderBase *reader, Framerate target, PulldownType pulldown);
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@
|
||||
#include "DecklinkWriter.h"
|
||||
#endif
|
||||
#include "DummyReader.h"
|
||||
#include "EffectBase.h"
|
||||
#include "Exceptions.h"
|
||||
#include "ReaderBase.h"
|
||||
#include "WriterBase.h"
|
||||
|
||||
@@ -82,6 +82,9 @@ namespace openshot
|
||||
InterpolationType interpolation; ///< This is the interpolation mode
|
||||
HandleType handle_type; ///< This is the handle mode
|
||||
|
||||
/// Default constructor (defaults to 0,0)
|
||||
Point();
|
||||
|
||||
/// Constructor which creates a single coordinate at X=0
|
||||
Point(float y);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace openshot
|
||||
/// Display file information in the standard output stream (stdout)
|
||||
void DisplayInfo();
|
||||
|
||||
/// This method is required for all derived classes of ReaderBase, and return the
|
||||
/// This method is required for all derived classes of ReaderBase, and returns the
|
||||
/// openshot::Frame object, which contains the image and audio information for that
|
||||
/// frame of video.
|
||||
///
|
||||
|
||||
+20
-4
@@ -43,6 +43,7 @@
|
||||
#include "Cache.h"
|
||||
#include "Color.h"
|
||||
#include "Clip.h"
|
||||
#include "EffectBase.h"
|
||||
#include "ReaderBase.h"
|
||||
#include "Fraction.h"
|
||||
#include "Frame.h"
|
||||
@@ -137,6 +138,7 @@ namespace openshot {
|
||||
list<Clip*> clips; ///<List of clips on this timeline
|
||||
list<Clip*> closing_clips; ///<List of clips that need to be closed
|
||||
map<Clip*, Clip*> open_clips; ///<List of 'opened' clips on this timeline
|
||||
list<EffectBase*> effects; ///<List of clips on this timeline
|
||||
Cache final_cache; ///<Final cache of timeline frames
|
||||
|
||||
/// Process a new layer of video or audio
|
||||
@@ -171,13 +173,19 @@ namespace openshot {
|
||||
/// @param clip Add an openshot::Clip to the timeline. A clip can contain any type of Reader.
|
||||
void AddClip(Clip* clip);
|
||||
|
||||
/// @brief Remove an openshot::Clip to the timeline
|
||||
/// @param clip Remove an openshot::Clip from the timeline.
|
||||
void RemoveClip(Clip* clip);
|
||||
/// @brief Add an effect to the timeline
|
||||
/// @param effect Add an effect to the timeline. An effect can modify the audio or video of an openshot::Frame.
|
||||
void AddEffect(EffectBase* effect);
|
||||
|
||||
/// Close the reader (and any resources it was consuming)
|
||||
/// Return a list of clips on the timeline
|
||||
list<Clip*> Clips() { return clips; };
|
||||
|
||||
/// Close the timeline reader (and any resources it was consuming)
|
||||
void Close();
|
||||
|
||||
/// Return the list of effects on the timeline
|
||||
list<EffectBase*> Effects() { return effects; };
|
||||
|
||||
/// Get the framerate of this timeline
|
||||
Framerate FrameRate() { return fps; };
|
||||
|
||||
@@ -209,6 +217,14 @@ namespace openshot {
|
||||
/// Open the reader (and start consuming resources)
|
||||
void Open();
|
||||
|
||||
/// @brief Remove an openshot::Clip from the timeline
|
||||
/// @param clip Remove an openshot::Clip from the timeline.
|
||||
void RemoveClip(Clip* clip);
|
||||
|
||||
/// @brief Remove an effect from the timeline
|
||||
/// @param effect Remove an effect from the timeline.
|
||||
void RemoveEffect(EffectBase* effect);
|
||||
|
||||
/// Sort clips by position on the timeline
|
||||
void SortClips();
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ SET ( OPENSHOT_SOURCE_FILES
|
||||
DummyReader.cpp
|
||||
ReaderBase.cpp
|
||||
WriterBase.cpp
|
||||
EffectBase.cpp
|
||||
FFmpegReader.cpp
|
||||
FFmpegWriter.cpp
|
||||
Fraction.cpp
|
||||
|
||||
+49
-19
@@ -83,6 +83,7 @@ void Clip::init_settings()
|
||||
// Default pointers
|
||||
file_reader = NULL;
|
||||
resampler = NULL;
|
||||
audio_cache = NULL;
|
||||
}
|
||||
|
||||
// Default Constructor for a clip
|
||||
@@ -162,13 +163,17 @@ void Clip::Reader(ReaderBase* reader)
|
||||
}
|
||||
|
||||
/// Get the current reader
|
||||
ReaderBase* Clip::Reader()
|
||||
ReaderBase* Clip::Reader() throw(ReaderClosed)
|
||||
{
|
||||
return file_reader;
|
||||
if (file_reader)
|
||||
return file_reader;
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
}
|
||||
|
||||
// Open the internal reader
|
||||
void Clip::Open() throw(InvalidFile)
|
||||
void Clip::Open() throw(InvalidFile, ReaderClosed)
|
||||
{
|
||||
if (file_reader)
|
||||
{
|
||||
@@ -179,17 +184,23 @@ void Clip::Open() throw(InvalidFile)
|
||||
if (end == 0.0)
|
||||
End(file_reader->info.duration);
|
||||
}
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
}
|
||||
|
||||
// Close the internal reader
|
||||
void Clip::Close()
|
||||
void Clip::Close() throw(ReaderClosed)
|
||||
{
|
||||
if (file_reader)
|
||||
file_reader->Close();
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
}
|
||||
|
||||
// Get end position of clip (trim end of video), which can be affected by the time curve.
|
||||
float Clip::End()
|
||||
float Clip::End() throw(ReaderClosed)
|
||||
{
|
||||
// if a time curve is present, use it's length
|
||||
if (time.Points.size() > 1)
|
||||
@@ -199,6 +210,9 @@ float Clip::End()
|
||||
if (file_reader)
|
||||
// file reader
|
||||
fps = file_reader->info.fps.ToFloat();
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
|
||||
return float(time.GetLength()) / fps;
|
||||
}
|
||||
@@ -210,22 +224,28 @@ float Clip::End()
|
||||
// Get an openshot::Frame object for a specific frame number of this reader.
|
||||
tr1::shared_ptr<Frame> Clip::GetFrame(int requested_frame) throw(ReaderClosed)
|
||||
{
|
||||
// Adjust out of bounds frame number
|
||||
requested_frame = adjust_frame_number_minimum(requested_frame);
|
||||
if (file_reader)
|
||||
{
|
||||
// Adjust out of bounds frame number
|
||||
requested_frame = adjust_frame_number_minimum(requested_frame);
|
||||
|
||||
// Is a time map detected
|
||||
int new_frame_number = requested_frame;
|
||||
if (time.Values.size() > 1)
|
||||
new_frame_number = time.GetInt(requested_frame);
|
||||
// Is a time map detected
|
||||
int new_frame_number = requested_frame;
|
||||
if (time.Values.size() > 1)
|
||||
new_frame_number = time.GetInt(requested_frame);
|
||||
|
||||
// Now that we have re-mapped what frame number is needed, go and get the frame pointer
|
||||
tr1::shared_ptr<Frame> frame = file_reader->GetFrame(new_frame_number);
|
||||
// Now that we have re-mapped what frame number is needed, go and get the frame pointer
|
||||
tr1::shared_ptr<Frame> frame = file_reader->GetFrame(new_frame_number);
|
||||
|
||||
// Get time mapped frame number (used to increase speed, change direction, etc...)
|
||||
tr1::shared_ptr<Frame> new_frame = get_time_mapped_frame(frame, requested_frame);
|
||||
// Get time mapped frame number (used to increase speed, change direction, etc...)
|
||||
tr1::shared_ptr<Frame> new_frame = get_time_mapped_frame(frame, requested_frame);
|
||||
|
||||
// Return processed 'frame'
|
||||
return new_frame;
|
||||
// Return processed 'frame'
|
||||
return new_frame;
|
||||
}
|
||||
else
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
}
|
||||
|
||||
// Get file extension
|
||||
@@ -264,8 +284,13 @@ void Clip::reverse_buffer(juce::AudioSampleBuffer* buffer)
|
||||
}
|
||||
|
||||
// Adjust the audio and image of a time mapped frame
|
||||
tr1::shared_ptr<Frame> Clip::get_time_mapped_frame(tr1::shared_ptr<Frame> frame, int frame_number)
|
||||
tr1::shared_ptr<Frame> Clip::get_time_mapped_frame(tr1::shared_ptr<Frame> frame, int frame_number) throw(ReaderClosed)
|
||||
{
|
||||
// Check for valid reader
|
||||
if (!file_reader)
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
|
||||
tr1::shared_ptr<Frame> new_frame;
|
||||
|
||||
// Check for a valid time map curve
|
||||
@@ -493,8 +518,13 @@ int Clip::adjust_frame_number_minimum(int frame_number)
|
||||
}
|
||||
|
||||
// Calculate the # of samples per video frame (for a specific frame number)
|
||||
int Clip::GetSamplesPerFrame(int frame_number, Fraction rate)
|
||||
int Clip::GetSamplesPerFrame(int frame_number, Fraction rate) throw(ReaderClosed)
|
||||
{
|
||||
// Check for valid reader
|
||||
if (!file_reader)
|
||||
// Throw error if reader not initialized
|
||||
throw ReaderClosed("No Reader has been initialized for this Clip. Call Reader(*reader) before calling this method.", "");
|
||||
|
||||
// Get the total # of samples for the previous frame, and the current frame (rounded)
|
||||
double fps = rate.Reciprocal().ToDouble();
|
||||
double previous_samples = round((file_reader->info.sample_rate * fps) * (frame_number - 1));
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Source file for EffectBase class
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2013 OpenShot Studios, LLC
|
||||
* (http://www.openshotstudios.com). This file is part of
|
||||
* OpenShot Library (http://www.openshot.org), an open-source project
|
||||
* dedicated to delivering high quality video editing and animation solutions
|
||||
* to the world.
|
||||
*
|
||||
* OpenShot Library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../include/EffectBase.h"
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
// Initialize the values of the FileInfo struct
|
||||
void EffectBase::InitEffectInfo()
|
||||
{
|
||||
info.has_video = false;
|
||||
info.has_audio = false;
|
||||
info.position = 0.0;
|
||||
info.name = "";
|
||||
info.description = "";
|
||||
}
|
||||
|
||||
// Display file information
|
||||
void EffectBase::DisplayInfo() {
|
||||
cout << fixed << setprecision(2) << boolalpha;
|
||||
cout << "----------------------------" << endl;
|
||||
cout << "----- Effect Information -----" << endl;
|
||||
cout << "----------------------------" << endl;
|
||||
cout << "--> Name: " << info.name << endl;
|
||||
cout << "--> Description: " << info.description << endl;
|
||||
cout << "--> Has Video: " << info.has_video << endl;
|
||||
cout << "--> Has Audio: " << info.has_audio << endl;
|
||||
cout << "--> Position: " << info.position << " Seconds" << endl;
|
||||
cout << "----------------------------" << endl;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,16 @@
|
||||
using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
// Default constructor (defaults to 0,0)
|
||||
Point::Point() : interpolation(BEZIER), handle_type(AUTO)
|
||||
{
|
||||
// set new coorinate
|
||||
co = Coordinate(0, 0);
|
||||
|
||||
// set handles
|
||||
Initialize_Handles();
|
||||
}
|
||||
|
||||
// Constructor which creates a single coordinate at X=0
|
||||
Point::Point(float y) :
|
||||
interpolation(BEZIER), handle_type(AUTO) {
|
||||
|
||||
@@ -71,6 +71,19 @@ void Timeline::AddClip(Clip* clip)
|
||||
SortClips();
|
||||
}
|
||||
|
||||
// Add an effect to the timeline
|
||||
void Timeline::AddEffect(EffectBase* effect)
|
||||
{
|
||||
// Add effect to list
|
||||
effects.push_back(effect);
|
||||
}
|
||||
|
||||
// Remove an effect from the timeline
|
||||
void Timeline::RemoveEffect(EffectBase* effect)
|
||||
{
|
||||
effects.remove(effect);
|
||||
}
|
||||
|
||||
// Remove an openshot::Clip to the timeline
|
||||
void Timeline::RemoveClip(Clip* clip)
|
||||
{
|
||||
|
||||
+17
-1
@@ -29,6 +29,8 @@
|
||||
|
||||
%include "typemaps.i"
|
||||
%include "std_string.i"
|
||||
%include "std_list.i"
|
||||
%include "std_vector.i"
|
||||
|
||||
/* Unhandled STL Exception Handling */
|
||||
%include <std_except.i>
|
||||
@@ -37,6 +39,7 @@
|
||||
#define SWIG_SHARED_PTR_SUBNAMESPACE tr1
|
||||
%include <std_shared_ptr.i>
|
||||
|
||||
|
||||
/* Mark these classes as shared_ptr classes */
|
||||
%shared_ptr(Magick::Image)
|
||||
%shared_ptr(juce::AudioSampleBuffer)
|
||||
@@ -52,6 +55,7 @@
|
||||
#include "../include/ChunkWriter.h"
|
||||
#include "../include/Coordinate.h"
|
||||
#include "../include/DummyReader.h"
|
||||
#include "../include/EffectBase.h"
|
||||
#include "../include/Exceptions.h"
|
||||
#include "../include/FFmpegReader.h"
|
||||
#include "../include/FFmpegWriter.h"
|
||||
@@ -86,6 +90,7 @@
|
||||
%include "../include/DecklinkWriter.h"
|
||||
#endif
|
||||
%include "../include/DummyReader.h"
|
||||
%include "../include/EffectBase.h"
|
||||
%include "../include/Exceptions.h"
|
||||
%include "../include/FFmpegReader.h"
|
||||
%include "../include/FFmpegWriter.h"
|
||||
@@ -98,4 +103,15 @@
|
||||
%include "../include/Point.h"
|
||||
%include "../include/KeyFrame.h"
|
||||
%include "../include/TextReader.h"
|
||||
%include "../include/Timeline.h"
|
||||
%include "../include/Timeline.h"
|
||||
|
||||
/* Wrap std templates (list, vector, etc...) */
|
||||
namespace std {
|
||||
%template(ClipList) list<Clip *>;
|
||||
%template(EffectBaseList) list<EffectBase *>;
|
||||
%template(CoordinateVector) vector<Coordinate>;
|
||||
%template(PointsVector) vector<Point>;
|
||||
%template(FieldVector) vector<Field>;
|
||||
%template(MappedFrameVector) vector<MappedFrame>;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user