diff --git a/include/Clip.h b/include/Clip.h index bf092746..52260d9e 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -91,7 +91,6 @@ namespace openshot { class Clip : public ClipBase { private: bool waveform; ///< Should a waveform be used instead of the clip's image - float end; ///< The position in seconds to end playing (used to trim the ending of a clip) // Audio resampler (if time mapping) AudioResampler *resampler; diff --git a/include/ClipBase.h b/include/ClipBase.h index 661c26c7..d2a9ad8f 100644 --- a/include/ClipBase.h +++ b/include/ClipBase.h @@ -48,7 +48,7 @@ namespace openshot { * together. There are 2 primary types of clips: Effects and Video/Audio Clips. */ class ClipBase { - private: + protected: string id; ///< ID Property for all derived Clip and Effect classes. 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. @@ -69,7 +69,7 @@ namespace openshot { 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() { return end; } ///< Get end position (in seconds) of clip (trim end of video) - float Duration() { return End() - Start(); } ///< Get the length of this clip (in seconds) + float Duration() { return end - start; } ///< Get the length of this clip (in seconds) /// Set basic properties void Id(string value) { id = value; } ///> Set the Id of this clip object diff --git a/src/ClipBase.cpp b/src/ClipBase.cpp index 206f7819..53b8d12e 100644 --- a/src/ClipBase.cpp +++ b/src/ClipBase.cpp @@ -39,6 +39,7 @@ Json::Value ClipBase::JsonValue() { root["layer"] = Layer(); root["start"] = Start(); root["end"] = End(); + root["duration"] = Duration(); // return JsonValue return root; diff --git a/src/Timeline.cpp b/src/Timeline.cpp index b0a0d3eb..d55701d9 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -54,6 +54,7 @@ Timeline::Timeline(int width, int height, Fraction fps, int sample_rate, int cha info.sample_rate = sample_rate; info.channels = channels; info.video_timebase = fps.Reciprocal(); + info.duration = 60 * 30; // 30 minute default duration } // Add an openshot::Clip to the timeline @@ -556,7 +557,7 @@ Json::Value Timeline::JsonValue() { root["color"] = color.JsonValue(); // Add array of clips - root["Clips"] = Json::Value(Json::arrayValue); + root["clips"] = Json::Value(Json::arrayValue); // Find Clips at this time list::iterator clip_itr; @@ -564,11 +565,11 @@ Json::Value Timeline::JsonValue() { { // Get clip object from the iterator Clip *existing_clip = (*clip_itr); - root["Clips"].append(existing_clip->JsonValue()); + root["clips"].append(existing_clip->JsonValue()); } // Add array of effects - root["Effects"] = Json::Value(Json::arrayValue); + root["effects"] = Json::Value(Json::arrayValue); // loop through effects list::iterator effect_itr; @@ -576,7 +577,7 @@ Json::Value Timeline::JsonValue() { { // Get clip object from the iterator EffectBase *existing_effect = (*effect_itr); - root["Effects"].append(existing_effect->JsonValue()); + root["effects"].append(existing_effect->JsonValue()); } // return JsonValue @@ -618,11 +619,11 @@ void Timeline::SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed) { // Clear existing clips clips.clear(); - if (!root["Clips"].isNull()) + if (!root["clips"].isNull()) // loop through clips - for (int x = 0; x < root["Clips"].size(); x++) { + for (int x = 0; x < root["clips"].size(); x++) { // Get each clip - Json::Value existing_clip = root["Clips"][x]; + Json::Value existing_clip = root["clips"][x]; // Create Clip Clip *c = new Clip(); @@ -637,11 +638,11 @@ void Timeline::SetJsonValue(Json::Value root) throw(InvalidFile, ReaderClosed) { // Clear existing effects effects.clear(); - if (!root["Effects"].isNull()) + if (!root["effects"].isNull()) // loop through effects - for (int x = 0; x < root["Effects"].size(); x++) { + for (int x = 0; x < root["effects"].size(); x++) { // Get each effect - Json::Value existing_effect = root["Effects"][x]; + Json::Value existing_effect = root["effects"][x]; // Create Effect EffectBase *e = NULL;