added: added ass resampler map support
This commit is contained in:
parent
0f086f3be0
commit
ef8fb2cb0a
@ -134,7 +134,7 @@ function resamplePOSSubtitle(subtitle: string, ox: number, oy: number, nx: numbe
|
||||
}
|
||||
|
||||
if (line.includes('\\fs')) {
|
||||
let posMatches = line.matchAll(/\\fs(-?\d+(?:\.\d+)?)/g)
|
||||
let posMatches = line.matchAll(/\\fs(\d+(?:\.\d+)?)/g)
|
||||
for (let posMatch of posMatches) {
|
||||
let font = parseInt(posMatch[1])
|
||||
let newFontSize = Math.round((font / oy) * ny)
|
||||
@ -154,6 +154,22 @@ function resamplePOSSubtitle(subtitle: string, ox: number, oy: number, nx: numbe
|
||||
}
|
||||
lines[i] = line
|
||||
}
|
||||
|
||||
if (line.match(/m\s|l\s/)) {
|
||||
let posMatches = line.matchAll(/([ml])\s*(-?\d+(?:\.\d+)?)\s*(-?\d+(?:\.\d+)?)/g)
|
||||
for (let posMatch of posMatches) {
|
||||
let command = posMatch[1]
|
||||
let oldX = parseFloat(posMatch[2])
|
||||
let oldY = parseFloat(posMatch[3])
|
||||
|
||||
let newX = Math.round((oldX / ox) * nx)
|
||||
let newY = Math.round((oldY / oy) * ny)
|
||||
|
||||
let newCommand = `${command} ${newX} ${newY}`
|
||||
line = line.replace(posMatch[0], newCommand)
|
||||
}
|
||||
lines[i] = line
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n')
|
||||
|
Reference in New Issue
Block a user