Skip to content

Commit

Permalink
fix vmaf files indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed Apr 26, 2024
1 parent 2d6cb95 commit 85c72a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 13 additions & 18 deletions src/vmaf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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} \
Expand All @@ -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,
Expand Down

0 comments on commit 85c72a0

Please sign in to comment.