Use file.ffProbeData?.format?.duration if available

This commit is contained in:
HaveAGitGat 2023-02-12 23:03:18 +00:00
parent db3fecab6a
commit fbed3a0a84
9 changed files with 54 additions and 11 deletions

View file

@ -139,7 +139,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
// Check if duration info is filled, if so times it by 0.0166667 to get time in minutes.
// If not filled then get duration of stream 0 and do the same.
if (typeof file.meta.Duration !== 'undefined') {
if (parseFloat(file.ffProbeData?.format?.duration) > 0) {
duration = parseFloat(file.ffProbeData?.format?.duration) * 0.0166667;
} else if (typeof file.meta.Duration !== 'undefined') {
duration = file.meta.Duration * 0.0166667;
} else {
duration = file.ffProbeData.streams[0].duration * 0.0166667;