MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / PickDurationSeconds

Method PickDurationSeconds

src/FFmpegReader.cpp:849–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847}
848
849double FFmpegReader::PickDurationSeconds() const {
850 auto has_value = [](double value) { return value > 0.0; };
851
852 switch (duration_strategy) {
853 case DurationStrategy::VideoPreferred:
854 if (has_value(video_stream_duration_seconds))
855 return video_stream_duration_seconds;
856 if (has_value(audio_stream_duration_seconds))
857 return audio_stream_duration_seconds;
858 if (has_value(format_duration_seconds))
859 return format_duration_seconds;
860 break;
861 case DurationStrategy::AudioPreferred:
862 if (has_value(audio_stream_duration_seconds))
863 return audio_stream_duration_seconds;
864 if (has_value(video_stream_duration_seconds))
865 return video_stream_duration_seconds;
866 if (has_value(format_duration_seconds))
867 return format_duration_seconds;
868 break;
869 case DurationStrategy::LongestStream:
870 default:
871 {
872 double longest = 0.0;
873 if (has_value(video_stream_duration_seconds))
874 longest = std::max(longest, video_stream_duration_seconds);
875 if (has_value(audio_stream_duration_seconds))
876 longest = std::max(longest, audio_stream_duration_seconds);
877 if (has_value(format_duration_seconds))
878 longest = std::max(longest, format_duration_seconds);
879 if (has_value(longest))
880 return longest;
881 }
882 break;
883 }
884
885 if (has_value(format_duration_seconds))
886 return format_duration_seconds;
887 if (has_value(inferred_duration_seconds))
888 return inferred_duration_seconds;
889
890 return 0.0;
891}
892
893void FFmpegReader::ApplyDurationStrategy() {
894 const double fps_value = info.fps.ToDouble();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected