Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/components/TrimControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export default function TrimControl({ recipe, onChange, duration, file }: Props)

const n = parseFloat(val);

onChange({ trimEnd: n });

if (isNaN(n)) {
setEnd(true);
setEndErrorMsg("Enter a valid number.");
Expand Down Expand Up @@ -112,6 +110,7 @@ export default function TrimControl({ recipe, onChange, duration, file }: Props)

setEnd(false);
setEndErrorMsg("");
onChange({ trimEnd: n });
};

const inputClass =
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useVideoEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ function validateRecipe(recipe: EditRecipe, duration: number ): string | null {
"Trim start time cannot be less than 0 seconds.",
],
[
recipe.trimEnd !== null && recipe.trimEnd > duration,
recipe.trimEnd !== null && duration > 0 && recipe.trimEnd > duration,
`Trim end time cannot exceed the video duration (${Math.floor(duration)}s).`,
],
[
recipe.trimStart >= (recipe.trimEnd ?? duration),
recipe.trimEnd !== null
? recipe.trimStart >= recipe.trimEnd
: (duration > 0 && recipe.trimStart >= duration),
"Trim start time must be earlier than the end time.",
],
[
Expand Down
Loading