Skip to content

Commit

Permalink
feat: extract qvbr for csv export
Browse files Browse the repository at this point in the history
  • Loading branch information
oshinongit committed Aug 20, 2024
1 parent 12c8785 commit 52fb9bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ async function exportWmafResultToCsv(argv) {
folder,
filename: resolutionVmaf.vmafFile,
resolution: `${resolutionVmaf.resolution.width}X${resolutionVmaf.resolution.height}`,
qvbr: resolutionVmaf.qvbr,
vmaf: resolutionVmaf.vmaf,
bitrate: result[0],
realTime: resolutionVmaf.cpuTime?.realTime,
Expand Down
10 changes: 9 additions & 1 deletion src/pairVmaf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import ffmpeg from 'fluent-ffmpeg';
import * as fs from 'fs';
import * as path from 'path';

function extractQVBRNumberFromFilename(filename: string): number | null {
const match = filename.match(/_QVBR_(\d+)_/);
return match ? parseInt(match[1], 10) : null;
}

export async function pairVmafWithResolutionAndBitrate(
directoryWithVmafFiles: string,
filterFunction: (
Expand All @@ -24,6 +29,7 @@ export async function pairVmafWithResolutionAndBitrate(
{
resolution: Resolution;
vmaf: number;
qvbr: number | null;
cpuTime?: { realTime: number; cpuTime: number };
vmafFile: string;
}[]
Expand Down Expand Up @@ -66,18 +72,20 @@ export async function pairVmafWithResolutionAndBitrate(
const height = parseInt(heightStr);
const bitrate = bitrates ? bitrates[filename] : parseInt(bitrateStr);
const cpuTime = cpuTimes ? cpuTimes[filename] : undefined;
const qvbr = extractQVBRNumberFromFilename(filename);

if (filterFunction(bitrate, { width, height }, vmaf)) {
if (pairs.has(bitrate)) {
pairs.get(bitrate)?.push({
resolution: { width, height },
qvbr,
vmaf,
cpuTime,
vmafFile: filename
});
} else {
pairs.set(bitrate, [
{ resolution: { width, height }, vmaf, cpuTime, vmafFile: filename }
{ resolution: { width, height }, qvbr, vmaf, cpuTime, vmafFile: filename }
]);
}
}
Expand Down

0 comments on commit 52fb9bf

Please sign in to comment.