Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix: export frame counter exceeding total frames
Theodor Peiferd21dd1cbf1e4
diff --git a/src/lib/exporter/gifExporter.ts b/src/lib/exporter/gifExporter.tsindex 747e34e2b..58ed693d7 100644--- a/src/lib/exporter/gifExporter.ts+++ b/src/lib/exporter/gifExporter.ts@@ -174,11 +174,11 @@ export class GifExporter {});// Calculate effective duration and frame count (excluding trim regions)- const effectiveDuration = this.streamingDecoder.getEffectiveDuration(+ const { effectiveDuration, totalFrames } = this.streamingDecoder.getExportMetrics(+ this.config.frameRate,this.config.trimRegions,this.config.speedRegions,);- const totalFrames = Math.ceil(effectiveDuration * this.config.frameRate);// Calculate frame delay in milliseconds (gif.js uses ms)const frameDelay = Math.round(1000 / this.config.frameRate);diff --git a/src/lib/exporter/streamingDecoder.ts b/src/lib/exporter/streamingDecoder.tsindex ee675763a..c02883217 100644--- a/src/lib/exporter/streamingDecoder.ts+++ b/src/lib/exporter/streamingDecoder.ts@@ -536,11 +536,24 @@ export class StreamingVideoDecoder {return segments;}- getEffectiveDuration(trimRegions?: TrimRegion[], speedRegions?: SpeedRegion[]): number {+ getExportMetrics(+ targetFrameRate: number,+ trimRegions?: TrimRegion[],+ speedRegions?: SpeedRegion[],+ ): { effectiveDuration: number; totalFrames: number } {if (!this.metadata) throw new Error("Must call loadMetadata() first");const trimSegments = this.computeSegments(this.metadata.duration, trimRegions);- const speedSegments = this.splitBySpeed(trimSegments, speedRegions);- return speedSegments.reduce((sum, seg) => sum + (seg.endSec - seg.startSec) / seg.speed, 0);+ const segments = this.splitBySpeed(trimSegments, speedRegions);+ return {+ effectiveDuration: segments.reduce(+ (sum, seg) => sum + (seg.endSec - seg.startSec) / seg.speed,+ 0,+ ),+ totalFrames: segments.reduce(+ (sum, seg) => sum + Math.ceil(((seg.endSec - seg.startSec) / seg.speed) * targetFrameRate),+ 0,+ ),+ };}private splitBySpeed(diff --git a/src/lib/exporter/videoExporter.ts b/src/lib/exporter/videoExporter.tsindex d0affd17c..dcfcc3ecb 100644--- a/src/lib/exporter/videoExporter.ts+++ b/src/lib/exporter/videoExporter.ts@@ -157,11 +157,11 @@ export class VideoExporter {this.muxer = muxer;await muxer.initialize();- const effectiveDuration = streamingDecoder.getEffectiveDuration(+ const { effectiveDuration, totalFrames } = streamingDecoder.getExportMetrics(+ this.config.frameRate,this.config.trimRegions,this.config.speedRegions,);- const totalFrames = Math.ceil(effectiveDuration * this.config.frameRate);const readEndSec = Math.max(videoInfo.duration, videoInfo.streamDuration ?? 0) + 0.5;console.log("[VideoExporter] Original duration:", videoInfo.duration, "s");