MCPcopy
hub / github.com/cpaczek/skylight / ffprobe

Function ffprobe

tracker/src/video/stabilize.ts:42–69  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

40}
41
42function ffprobe(path: string): Promise<Probe> {
43 return new Promise((resolve, reject) => {
44 const p = spawn("ffprobe", [
45 "-v", "error", "-select_streams", "v:0",
46 "-show_entries", "stream=width,height,r_frame_rate,nb_read_frames:format=duration",
47 "-count_frames", "-of", "json", path,
48 ]);
49 let out = "";
50 p.stdout.on("data", (c) => (out += c));
51 p.on("error", reject);
52 p.on("close", () => {
53 try {
54 const j = JSON.parse(out);
55 const s = j.streams[0];
56 const [n, d] = String(s.r_frame_rate).split("/").map(Number);
57 resolve({
58 width: s.width,
59 height: s.height,
60 fps: d ? n / d : 30,
61 frames: Number(s.nb_read_frames) || 0,
62 duration: Number(j.format?.duration) || 0,
63 });
64 } catch (e) {
65 reject(e);
66 }
67 });
68 });
69}
70
71/** Track the plane (frame fractions) across the clip via motion compensation. */
72function detectTrack(path: string): Promise<({ cx: number; cy: number } | null)[]> {

Callers 1

stabilizeClipFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected