From 97d795dd3f2352c53e0a2251704a230f0ffd1702 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 3 Mar 2020 15:51:22 +1100 Subject: [PATCH] sequence: moved code that set parameters based on a list of footage to here from ImportTool --- app/project/item/sequence/sequence.cpp | 44 ++++++++++++++++++++++++++ app/project/item/sequence/sequence.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/app/project/item/sequence/sequence.cpp b/app/project/item/sequence/sequence.cpp index 4a55a74a9..e8edb5601 100644 --- a/app/project/item/sequence/sequence.cpp +++ b/app/project/item/sequence/sequence.cpp @@ -265,6 +265,50 @@ void Sequence::set_default_parameters() Config::Current()["DefaultSequenceAudioLayout"].toULongLong())); } +void Sequence::set_parameters_from_footage(const QList footage) +{ + bool found_video_params = false; + bool found_audio_params = false; + + foreach (Footage* f, footage) { + foreach (StreamPtr s, f->streams()) { + if (!found_video_params) { + + if (s->type() == Stream::kVideo) { + // If this is a video stream, use these parameters + VideoStream* vs = static_cast(s.get()); + + if (vs->frame_rate() != 0) { + set_video_params(VideoParams(vs->width(), vs->height(), vs->frame_rate().flipped())); + found_video_params = true; + } + } else if (s->type() == Stream::kImage) { + // If this is an image stream, we'll use it's resolution but won't set `found_video_params` in case + // something with a frame rate comes along which we'll prioritize + ImageStream* is = static_cast(s.get()); + + set_video_params(VideoParams(is->width(), is->height(), video_params().time_base())); + } + + } else if (!found_audio_params && s->type() == Stream::kAudio) { + + AudioStream* as = static_cast(s.get()); + set_audio_params(AudioParams(as->sample_rate(), as->channel_layout())); + found_audio_params = true; + + } + + if (found_video_params && found_audio_params) { + break; + } + } + + if (found_video_params && found_audio_params) { + break; + } + } +} + ViewerOutput *Sequence::viewer_output() const { return viewer_output_; diff --git a/app/project/item/sequence/sequence.h b/app/project/item/sequence/sequence.h index b87753113..c9311cd40 100644 --- a/app/project/item/sequence/sequence.h +++ b/app/project/item/sequence/sequence.h @@ -71,6 +71,8 @@ public: void set_default_parameters(); + void set_parameters_from_footage(const QList footage); + ViewerOutput* viewer_output() const; protected: