diff --git a/interfaces/final-object.interface.ts b/interfaces/final-object.interface.ts index 4f28ca99..bd187718 100644 --- a/interfaces/final-object.interface.ts +++ b/interfaces/final-object.interface.ts @@ -30,6 +30,7 @@ export interface ImageElement { duration: number; // number of seconds - duration of film fileName: string; // full file name with extension - for opening the file fileSize: number; // file size in bytes + bitrate: number; // bitrate of the displayed video file - (fileSize/duration)*1024 fps: number; // base frame rate of the video in fps hash: string; // used for detecting changed files and as a screenshot identifier height: AllowedScreenshotHeight; // height of the video (px) @@ -72,6 +73,7 @@ export function NewImageElement(): ImageElement { durationDisplay: '', fileName: '', fileSize: 0, + bitrate: 0, fileSizeDisplay: '', fps: 0, hash: '', diff --git a/node/main-support.ts b/node/main-support.ts index 304a13b5..b198891a 100644 --- a/node/main-support.ts +++ b/node/main-support.ts @@ -117,6 +117,7 @@ function getFileSizeDisplay(sizeInBytes: number): string { * Generate duration formatted as X:XX:XX * @param numOfSec */ + function getDurationDisplay(numOfSec: number): string { if (numOfSec === undefined || numOfSec === 0) { @@ -302,18 +303,24 @@ function getBestStream(metadata) { */ function getFileDuration(metadata): number { if (metadata?.streams?.[0]?.duration) { - + return metadata.streams[0].duration; } else if (metadata?.format?.duration) { return metadata.format.duration; - } else { return 0; } } +//Calculation of video bitrate in mb/s + +function getBitrate(fileSize,duration){ + var bitrate = ((fileSize/1000)/duration)/1000; + return Math.round(bitrate*100)/100; +} + /** * Return the average frame rate of files * =========================================================================================== @@ -537,6 +544,7 @@ export function insertTemporaryFieldsSingle(element: ImageElement): ImageElement const resolution: ResolutionMeta = labelVideo(element.width, element.height); element.durationDisplay = getDurationDisplay(element.duration); element.fileSizeDisplay = getFileSizeDisplay(element.fileSize); + element.bitrate = getBitrate(element.fileSize, element.duration); element.resBucket = resolution.bucket; element.resolution = resolution.label; return element; diff --git a/package-lock.json b/package-lock.json index 77025fdc..028c81ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,6 +59,9 @@ "wait-on": "6.0.0", "zone.js": "0.11.4" }, + "engines": { + "node": ">=v14" + }, "optionalDependencies": { "dmg-license": "1.0.9" } diff --git a/src/app/components/meta/meta.component.html b/src/app/components/meta/meta.component.html index 3eda52ac..83838740 100644 --- a/src/app/components/meta/meta.component.html +++ b/src/app/components/meta/meta.component.html @@ -33,7 +33,9 @@ | {{ video.width }} x {{ video.height }} | {{ video.fileSizeDisplay }} - + + | {{ video.bitrate + ' mb/s' }} + {{ video.fps ? '| ' + video.fps + ' fps' : '' }} |