Skip to content

Commit

Permalink
fix: account for how fractional frame rates are expressed in the time…
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
Alex Van Camp committed Mar 17, 2023
1 parent 90858ff commit e6f77be
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/commands/diskList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,20 @@ export class DiskListCommand extends AbstractCommand {
if (match?.groups && frameRateMatch?.groups && timecodeMatch?.groups) {
// according to the manual, timecodes are expressed as non-drop-frame
const interlaced = frameRateMatch.groups.scan.toLowerCase() === 'i'
const rawFrameRate = parseInt(frameRateMatch.groups.frameRate, 10)
const frameRate = Math.round(interlaced ? rawFrameRate / 2 : rawFrameRate)
/** Frames, not fields! 25, 50, 60, 5994, 2997, 23976, etc. */
const rawFrameRate = interlaced
? parseInt(frameRateMatch.groups.frameRate, 10) / 2
: parseInt(frameRateMatch.groups.frameRate, 10)
let frameRate: number
const isFractionalFrameRate = rawFrameRate >= 1000
if (isFractionalFrameRate) {
const whole = String(rawFrameRate).substring(0, 2)
const fraction = String(rawFrameRate).substring(2)
const combined = parseFloat(`${whole}.${fraction}`)
frameRate = Math.round(combined)
} else {
frameRate = Math.round(rawFrameRate)
}
const msPerFrame = 1000 / (interlaced ? frameRate / 2 : frameRate)
const hoursMs = parseInt(timecodeMatch.groups.hours, 10) * 60 * 60 * 1000
const minutesMs = parseInt(timecodeMatch.groups.minutes, 10) * 60 * 1000
Expand Down

0 comments on commit e6f77be

Please sign in to comment.