mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Protection against errors if unable to use MediaInfo or ffprobe
Just changed the videoBR logic to be inside a try block to avoid errors on rare instances where Media info & ffprobe fail
This commit is contained in:
parent
7f87af3c1b
commit
23bef4c778
1 changed files with 11 additions and 13 deletions
|
|
@ -357,21 +357,19 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
// Check if stream is a video.
|
||||
if (videoIdx === -1 && strstreamType === 'video') {
|
||||
videoIdx = i;
|
||||
videoBR = Number(file.mediaInfo.track[i + 1].BitRate) / 1000;
|
||||
|
||||
// If MediaInfo fails somehow fallback to ffprobe - Try two types of tags that might exist
|
||||
if (videoBR <= 0 || Number.isNaN(videoBR)) {
|
||||
if (Number(file.ffProbeData.streams[i].tags.BPS) > 0) {
|
||||
videoBR = file.ffProbeData.streams[i].tags.BPS / 1000;
|
||||
} else {
|
||||
try {
|
||||
if (Number(file.ffProbeData.streams[i].tags.BPS['-eng']) > 0) {
|
||||
videoBR = file.ffProbeData.streams[i].tags.BPS['-eng'] / 1000;
|
||||
}
|
||||
} catch (err) {
|
||||
// Catch error - Ignore & carry on - If check can bomb out if tags don't exist...
|
||||
// Try checking file stats using Mediainfo first, then ffprobe.
|
||||
try {
|
||||
videoBR = Number(file.mediaInfo.track[i + 1].BitRate) / 1000;
|
||||
if (videoBR <= 0 || Number.isNaN(videoBR)) {
|
||||
if (Number(file.ffProbeData.streams[i].tags.BPS) > 0) {
|
||||
videoBR = file.ffProbeData.streams[i].tags.BPS / 1000;
|
||||
} else if (Number(file.ffProbeData.streams[i].tags.BPS['-eng']) > 0) {
|
||||
videoBR = file.ffProbeData.streams[i].tags.BPS['-eng'] / 1000;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// Catch error - Ignore & carry on - If check can bomb out if tags don't exist...
|
||||
videoBR = 0; // Set videoBR to 0 for safety
|
||||
}
|
||||
// Check if duration info is filled, if so convert time format to minutes.
|
||||
if (Number.isNaN(file.meta.Duration) === false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue