authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-05-08 20:58:01-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-05-08 20:59:45-07:00
logd281939a47bccfd03bc3a45f38a73bb2b4ff7e5f
tree5d9cdf56a101122c952b7586328d4a00f26aeb1e
parent9629835aa90509a2bd77af33f496473131564811
signature Signed by SSH key SHA256:xbd+BjjhyBfwk7GVoURf9Yx0gzDerHbvYv7SddNWmAs

fix: ffmpeg progress tracker didn't consider fractional framerates

honestly such a stupid thing like yeah i want to have 29.97 fps like no go be a normal human being. fixes #35

2 files changed, 21 insertions(+), 1 deletions(-)

lib/subprocess/ffmpeg.test.ts created+20
......@@ -0,0 +1,20 @@
1test("Parse uses fractional input fps for total frame estimates", () => {
2 const parser = new Parse();
3
4 parser.onLine("Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':");
5 parser.onLine(" Duration: 00:01:08.10, start: 0.000000, bitrate: 352 kb/s");
6 parser.onLine(
7 " Stream #0:0[0x1](und): Video: h264, yuv420p(progressive), 160x90, 351 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)",
8 );
9
10 const result = parser.onLine(
11 "frame= 2041 fps=0.0 q=-1.0 Lsize=N/A time=00:01:08.10 bitrate=N/A speed= 900x",
12 );
13
14 assert.equal(result.kind, "progress");
15 assert.equal(result.totalFrames, 2041);
16});
17
18import assert from "node:assert";
19import { test } from "vitest";
20import { Parse } from "./ffmpeg.ts";
lib/subprocess/ffmpeg.ts+1-1
......@@ -161,7 +161,7 @@ export class Parse {
161161 );
162162 }
163163 if (!this.targetFps) {
164 const match = line.match(/^Stream.*, (\d+) fps/);
164 const match = line.match(/^Stream.*, (\d+(?:\.\d+)?) fps/);
165165 if (match) this.targetFps = Number(match[1]);
166166 }
167167 }