diff --git a/src/utils.ts b/src/utils.ts index a50389c..670a8a1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -412,7 +412,9 @@ export async function downloadUrl( : undefined, timeout, onDownloadProgress: event => { - log.debug(`downloadUrl fileUrl=${url} progress=${event}`) + log.debug( + `downloadUrl fileUrl=${url} progress=${event.progress || event.bytes}`, + ) }, httpsAgent: new Agent({ rejectUnauthorized: false, diff --git a/src/vmaf.ts b/src/vmaf.ts index 42c60f5..de43304 100644 --- a/src/vmaf.ts +++ b/src/vmaf.ts @@ -366,8 +366,15 @@ export async function runVmaf( const comparisonPath = degradedPath.replace(/\.[^.]+$/, '') const vmafLogPath = comparisonPath + '.vmaf.json' const cpus = os.cpus().length - const referencePathMp4 = `${referencePath.replace(/\.ivf$/, '.mp4')}` - const degradedPathMp4 = `${degradedPath.replace(/\.ivf$/, '.mp4')}` + + const dir = path.dirname(referencePath) + const sender = path.basename(referencePath).replace('.ivf', '') + const receiver = path + .basename(degradedPath) + .replace('.ivf', '') + .split('_recv-by_')[1] + const referencePathMp4 = `${dir}/${sender}_sent-to_${receiver}.mp4` + const degradedPathMp4 = `${dir}/${sender}_recv-by_${receiver}.mp4` const { width, @@ -386,32 +393,25 @@ export async function runVmaf( }) const textHeight = Math.ceil(height / 18) + 6 - const referencePathMp4Exists = fs.existsSync(referencePathMp4) const filter = `\ [0:v]scale=w=${width}:h=${height}:flags=bicubic:eval=frame,crop=${width}:${ height - textHeight * 2 }:0:${textHeight},fps=fps=${frameRate},split=3[deg1][deg2][deg3];\ [1:v]scale=w=${width}:h=${height}:flags=bicubic:eval=frame,crop=${width}:${ height - textHeight * 2 - }:0:${textHeight},fps=fps=${frameRate},split=3[ref1][ref2]${ - referencePathMp4Exists ? '' : '[ref3]' - };\ + }:0:${textHeight},fps=fps=${frameRate},split=3[ref1][ref2][ref3];\ [deg1][ref1]libvmaf=model='path=/usr/share/model/vmaf_v0.6.1.json':log_fmt=json:log_path=${vmafLogPath}:n_subsample=1:n_threads=${cpus}[vmaf]` const cmd = preview ? `ffmpeg -loglevel warning -y -threads ${cpus} \ --ss ${-ptsDiff / frameRate} -i ${degradedPath} \ --i ${referencePath} \ +-i ${degradedPath} \ +-ss ${ptsDiff / frameRate} -i ${referencePath} \ -filter_complex "${filter};[ref2][deg2]hstack[stacked]" \ -map [vmaf] -f null - \ -map [stacked] -c:v libx264 -crf 15 -f mp4 -movflags +faststart ${ comparisonPath + '_comparison.mp4' } \ -${ - referencePathMp4Exists - ? '' - : `-map [ref3] -c:v libx264 -crf 15 -f mp4 -movflags +faststart ${referencePathMp4}` -} \ +-map [ref3] -c:v libx264 -crf 15 -f mp4 -movflags +faststart ${referencePathMp4} \ -map [deg3] -c:v libx264 -crf 15 -f mp4 -movflags +faststart ${degradedPathMp4} \ ` : `ffmpeg -loglevel warning -y -threads ${cpus} \ @@ -428,11 +428,6 @@ ${ stdout, stderr, }) - const sender = path.basename(referencePath).replace('.ivf', '') - const receiver = path - .basename(degradedPath) - .replace('.ivf', '') - .split('_recv-by_')[1] const metrics = { sender, receiver,