You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Add GetMaxTime
This commit is contained in:
@@ -265,6 +265,8 @@ namespace openshot {
|
||||
/// Look up a timeline effect by ID
|
||||
openshot::EffectBase* GetEffect(const std::string& id);
|
||||
|
||||
/// Look up the end time of the latest timeline element
|
||||
double GetMaxTime();
|
||||
/// Look up the end frame number of the latest element on the timeline
|
||||
int64_t GetMaxFrame();
|
||||
|
||||
|
||||
@@ -299,9 +299,10 @@ openshot::EffectBase* Timeline::GetClipEffect(const std::string& id)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int64_t Timeline::GetMaxFrame() {
|
||||
int64_t last_clip = 1;
|
||||
int64_t last_effect = 1;
|
||||
// Compute the end time of the latest timeline element
|
||||
double Timeline::GetMaxTime() {
|
||||
double last_clip = 0.0;
|
||||
double last_effect = 0.0;
|
||||
|
||||
if (!clips.empty()) {
|
||||
const auto max_clip = std::max_element(
|
||||
@@ -316,6 +317,13 @@ int64_t Timeline::GetMaxFrame() {
|
||||
return std::max(last_clip, last_effect);
|
||||
}
|
||||
|
||||
// Compute the highest frame# based on the latest time and FPS
|
||||
int64_t Timeline::GetMaxFrame() {
|
||||
double fps = info.fps.ToDouble();
|
||||
auto max_time = GetMaxTime();
|
||||
return std::round(max_time * fps) + 1;
|
||||
}
|
||||
|
||||
// Apply a FrameMapper to a clip which matches the settings of this timeline
|
||||
void Timeline::apply_mapper_to_clip(Clip* clip)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user