You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Improved Clip class, and worked on constructors, file readers (image and ffmpeg), and more curves (shear, perspective, and crop)
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
* \author Copyright (c) 2011 Jonathan Thomas
|
||||
*/
|
||||
|
||||
#include "FFmpegReader.h"
|
||||
#include "FrameMapper.h"
|
||||
#include "ImageReader.h"
|
||||
#include "KeyFrame.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -64,15 +67,44 @@ namespace openshot {
|
||||
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)
|
||||
|
||||
/// Init default settings for a clip
|
||||
void init_settings();
|
||||
|
||||
public:
|
||||
|
||||
/// Default Constructor
|
||||
Clip();
|
||||
|
||||
/// Constructor with filepath
|
||||
Clip(string path);
|
||||
|
||||
// File Reader object
|
||||
FileReaderBase* file_reader;
|
||||
|
||||
// Frame mapping object
|
||||
FrameMapper* frame_map;
|
||||
|
||||
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
|
||||
|
||||
/// Get basic properties
|
||||
float get_position() { return position; } ///<Get position on timeline
|
||||
int get_layer() { return layer; } ///<Get layer of clip on timeline (lower number is covered by higher numbers)
|
||||
float get_start() { return start; } ///<Get start position of clip (trim start of video)
|
||||
float get_end() { return end; } ///<Get end position of clip (trim end of video)
|
||||
|
||||
/// Set basic properties
|
||||
void set_position(float value) { position = value; } ///<Get position on timeline
|
||||
void set_layer(int value) { layer = value; } ///<Get layer of clip on timeline (lower number is covered by higher numbers)
|
||||
void set_start(float value) { start = value; } ///<Get start position of clip (trim start of video)
|
||||
void set_end(float value) { end = value; } ///<Get end position of clip (trim end of video)
|
||||
|
||||
// Scale and Location curves
|
||||
Keyframe scale_x; ///<Curve representing the horizontal scaling (0 to 100)
|
||||
Keyframe scale_y; ///<Curve representing the vertical scaling (0 to 100)
|
||||
Keyframe location_x; ///<Curve representing the relative X position based on the gravity (-100 to 100)
|
||||
Keyframe location_y; ///<Curve representing the relative Y position 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)
|
||||
@@ -82,10 +114,24 @@ namespace openshot {
|
||||
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 100)
|
||||
|
||||
public:
|
||||
// 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%)
|
||||
|
||||
/// Default Constructor
|
||||
Clip();
|
||||
// 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
|
||||
|
||||
};
|
||||
|
||||
|
||||
64
src/Clip.cpp
64
src/Clip.cpp
@@ -2,14 +2,14 @@
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
// Default Constructor for a clip
|
||||
Clip::Clip()
|
||||
// Init default settings for a clip
|
||||
void Clip::init_settings()
|
||||
{
|
||||
// Init clip settings
|
||||
position = 0.0;
|
||||
layer = 0;
|
||||
start = 0.0;
|
||||
end = 0.0;
|
||||
set_position(0.0);
|
||||
set_layer(0);
|
||||
set_start(0.0);
|
||||
set_end(0.0);
|
||||
gravity = CENTER;
|
||||
scale = FIT;
|
||||
anchor = CANVAS;
|
||||
@@ -30,4 +30,56 @@ Clip::Clip()
|
||||
time = Keyframe(0.0);
|
||||
volume = Keyframe(100.0);
|
||||
|
||||
// Init crop settings
|
||||
crop_gravity = CENTER;
|
||||
crop_width = Keyframe(-1.0);
|
||||
crop_height = Keyframe(-1.0);
|
||||
crop_x = Keyframe(0.0);
|
||||
crop_y = Keyframe(0.0);
|
||||
|
||||
// Init shear and perspective curves
|
||||
shear_x = Keyframe(0.0);
|
||||
shear_y = Keyframe(0.0);
|
||||
perspective_c1_x = Keyframe(-1.0);
|
||||
perspective_c1_y = Keyframe(-1.0);
|
||||
perspective_c2_x = Keyframe(-1.0);
|
||||
perspective_c2_y = Keyframe(-1.0);
|
||||
perspective_c3_x = Keyframe(-1.0);
|
||||
perspective_c3_y = Keyframe(-1.0);
|
||||
perspective_c4_x = Keyframe(-1.0);
|
||||
perspective_c4_y = Keyframe(-1.0);
|
||||
}
|
||||
|
||||
// Default Constructor for a clip
|
||||
Clip::Clip()
|
||||
{
|
||||
// Init all default settings
|
||||
init_settings();
|
||||
}
|
||||
|
||||
// Constructor with filepath
|
||||
Clip::Clip(string path)
|
||||
{
|
||||
// Init all default settings
|
||||
init_settings();
|
||||
|
||||
// Try each type of reader (until one works)
|
||||
try
|
||||
{
|
||||
file_reader = new ImageReader(path);
|
||||
cout << "READER FOUND: ImageReader" << endl;
|
||||
|
||||
} catch(...) {
|
||||
try
|
||||
{
|
||||
file_reader = new FFmpegReader(path);
|
||||
cout << "READER FOUND: FFmpegReader" << endl;
|
||||
|
||||
} catch(BaseException ex) {
|
||||
// let exception bubble up
|
||||
cout << "READER NOT FOUND" << endl;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user