mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 23:04:04 +09:00
bitrate indicator
This commit is contained in:
@@ -10,6 +10,7 @@ const pcm = require("pcm")
|
|||||||
const MP2_FRAME_SIZE = [144,216,252,288,360,432,504,576,720,864,1008,1152,1440,1728]
|
const MP2_FRAME_SIZE = [144,216,252,288,360,432,504,576,720,864,1008,1152,1440,1728]
|
||||||
const fullFilePath = _G.shell.resolvePathInput(exec_args[1])
|
const fullFilePath = _G.shell.resolvePathInput(exec_args[1])
|
||||||
const FILE_LENGTH = files.open(fullFilePath.full).size
|
const FILE_LENGTH = files.open(fullFilePath.full).size
|
||||||
|
let videoRateBin = []
|
||||||
|
|
||||||
con.clear();con.curs_set(0)
|
con.clear();con.curs_set(0)
|
||||||
graphics.clearPixels(255)
|
graphics.clearPixels(255)
|
||||||
@@ -43,6 +44,20 @@ let width = seqread.readShort()
|
|||||||
let height = seqread.readShort()
|
let height = seqread.readShort()
|
||||||
let fps = seqread.readShort(); if (fps == 0) fps = 9999
|
let fps = seqread.readShort(); if (fps == 0) fps = 9999
|
||||||
|
|
||||||
|
function updateDataRateBin(rate) {
|
||||||
|
videoRateBin.push(rate)
|
||||||
|
|
||||||
|
if (videoRateBin.length > fps) {
|
||||||
|
videoRateBin.shift()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVideoRate(rate) {
|
||||||
|
let baseRate = videoRateBin.reduce((a, c) => a + c, 0)
|
||||||
|
let mult = fps / videoRateBin.length
|
||||||
|
return baseRate * mult
|
||||||
|
}
|
||||||
|
|
||||||
//fps = 9999
|
//fps = 9999
|
||||||
|
|
||||||
const FRAME_TIME = 1.0 / fps
|
const FRAME_TIME = 1.0 / fps
|
||||||
@@ -161,6 +176,7 @@ while (!stopPlay && seqread.getReadCount() < FILE_LENGTH) {
|
|||||||
if (packetType == 4 || packetType == 5 || packetType == 260 || packetType == 261) {
|
if (packetType == 4 || packetType == 5 || packetType == 260 || packetType == 261) {
|
||||||
let decodefun = (packetType > 255) ? graphics.decodeIpf2 : graphics.decodeIpf1
|
let decodefun = (packetType > 255) ? graphics.decodeIpf2 : graphics.decodeIpf1
|
||||||
let payloadLen = seqread.readInt()
|
let payloadLen = seqread.readInt()
|
||||||
|
updateDataRateBin(payloadLen)
|
||||||
|
|
||||||
if (framesRead >= FRAME_COUNT) {
|
if (framesRead >= FRAME_COUNT) {
|
||||||
break renderLoop
|
break renderLoop
|
||||||
@@ -219,6 +235,7 @@ while (!stopPlay && seqread.getReadCount() < FILE_LENGTH) {
|
|||||||
doFrameskip = false // disable frameskip for delta-coding
|
doFrameskip = false // disable frameskip for delta-coding
|
||||||
|
|
||||||
let payloadLen = seqread.readInt()
|
let payloadLen = seqread.readInt()
|
||||||
|
updateDataRateBin(payloadLen)
|
||||||
|
|
||||||
if (framesRead >= FRAME_COUNT) {
|
if (framesRead >= FRAME_COUNT) {
|
||||||
break renderLoop
|
break renderLoop
|
||||||
@@ -332,6 +349,11 @@ while (!stopPlay && seqread.getReadCount() < FILE_LENGTH) {
|
|||||||
if (notifHideTimer > (NOTIF_SHOWUPTIME + FRAME_TIME)) {
|
if (notifHideTimer > (NOTIF_SHOWUPTIME + FRAME_TIME)) {
|
||||||
con.clear()
|
con.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
con.move(32, 1)
|
||||||
|
graphics.setTextFore(161)
|
||||||
|
print(`VRate: ${(getVideoRate() / 1024 * 8)|0} kbps `)
|
||||||
|
con.move(1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
t1 = t2
|
t1 = t2
|
||||||
|
|||||||
Reference in New Issue
Block a user