You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Adding support for detecting video_length (i.e. # of video frames) from the metadata, instead of calculating from duration * fps. This is occasionally different by a small amount, and in my testing, the metadata is more accurate.
This commit is contained in:
@@ -821,6 +821,11 @@ void FFmpegReader::UpdateVideoInfo() {
|
||||
info.duration = float(info.file_size) / info.video_bit_rate;
|
||||
}
|
||||
|
||||
// Get the # of video frames (if found in stream)
|
||||
if (pStream->nb_frames > 0) {
|
||||
info.video_length = pStream->nb_frames;
|
||||
}
|
||||
|
||||
// No duration found in stream of file
|
||||
if (info.duration <= 0.0f) {
|
||||
// No duration is found in the video stream
|
||||
@@ -831,8 +836,10 @@ void FFmpegReader::UpdateVideoInfo() {
|
||||
// Yes, a duration was found
|
||||
is_duration_known = true;
|
||||
|
||||
// Calculate number of frames
|
||||
info.video_length = round(info.duration * info.fps.ToDouble());
|
||||
// Calculate number of frames (if not already found in metadata)
|
||||
if (info.video_length <= 0) {
|
||||
info.video_length = round(info.duration * info.fps.ToDouble());
|
||||
}
|
||||
}
|
||||
|
||||
// Add video metadata (if any)
|
||||
|
||||
Reference in New Issue
Block a user