Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/renderer/src/dialogs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,20 @@ export async function createFixedByteSixedSegments({ fileDuration, fileSize }: {
const parsed = parseBytesHuman(value);
invariant(parsed != null);

return fileDuration * (parsed / fileSize);
// Use a conservative estimate based on average bytes per second and a safety margin
// so that the estimated segment size (including margin) stays within the user limit.
const safetyFactor = 1.1; // 10% overhead margin for container / bitrate variations

const avgBytesPerSecond = fileSize / fileDuration;
if (!Number.isFinite(avgBytesPerSecond) || avgBytesPerSecond <= 0) {
// Fallback: keep previous behaviour if we for some reason cannot estimate
return fileDuration * (parsed / fileSize);
}

const maxBytesPerSegment = parsed / safetyFactor;
const segmentDuration = maxBytesPerSegment / avgBytesPerSecond;

return segmentDuration;
}


Expand Down