-
Notifications
You must be signed in to change notification settings - Fork 0
add vod split autoselect for cut selection #66 #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
73efef6
refactor: remove unused copy plugin from rollup configuration
saebyn e20bf55
feat: add key press handler to Button and IconButton components
saebyn 34ff0cc
feat: implement findGaps function and corresponding tests to identify…
saebyn 962f51a
feat: add onSeekToTime handler to ClipSelectionDialog and VideoSelect…
saebyn 7d12004
refactor: move the VideoClip interface to types.ts
saebyn a03a08e
feat: add export and clip silences buttons to VideoSelectionPage comp…
saebyn 9718b02
feat: add onSeekToTime action to ClipSelectionDialog stories
saebyn 6279de8
feat: enhance Button component to support space key activation
saebyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import type { Section } from "types"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import findGaps from "./findGaps"; | ||
|
|
||
| describe("findGaps", () => { | ||
| it("should find gaps between sections", async () => { | ||
| const sections: Section[] = [ | ||
| { timestamp: 0, timestamp_end: 10 }, | ||
| { timestamp: 20, timestamp_end: 30 }, | ||
| { timestamp: 40, timestamp_end: 50 }, | ||
| ]; | ||
| const minGapDuration = 5; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([ | ||
| { id: "10-20", start: 10, end: 20 }, | ||
| { id: "30-40", start: 30, end: 40 }, | ||
| ]); | ||
| }); | ||
|
|
||
| it("should return an empty array if no gaps are found", async () => { | ||
| const sections: Section[] = [ | ||
| { timestamp: 0, timestamp_end: 10 }, | ||
| { timestamp: 11, timestamp_end: 20 }, | ||
| ]; | ||
| const minGapDuration = 5; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([]); | ||
| }); | ||
|
|
||
| it("should handle sections with undefined timestamp_end", async () => { | ||
| const sections: Section[] = [ | ||
| { timestamp: 0, timestamp_end: 10 }, | ||
| { timestamp: 20 }, | ||
| { timestamp: 30, timestamp_end: 40 }, | ||
| ]; | ||
| const minGapDuration = 5; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([{ id: "10-30", start: 10, end: 30 }]); | ||
| }); | ||
|
|
||
| it("should ignore gaps that are less than the minimum gap duration", async () => { | ||
| const sections: Section[] = [ | ||
| { timestamp: 0, timestamp_end: 10 }, | ||
| { timestamp: 15, timestamp_end: 25 }, | ||
| ]; | ||
| const minGapDuration = 10; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([]); | ||
| }); | ||
|
|
||
| it("should handle an empty array of sections", async () => { | ||
| const sections: Section[] = []; | ||
| const minGapDuration = 5; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([]); | ||
| }); | ||
|
|
||
| it("should handle a single section", async () => { | ||
| const sections: Section[] = [{ timestamp: 0, timestamp_end: 10 }]; | ||
| const minGapDuration = 5; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([]); | ||
| }); | ||
|
|
||
| it("should find gaps greater than or equal to the minimum gap duration but ignore gaps less than the minimum gap duration", async () => { | ||
| const sections: Section[] = [ | ||
| { timestamp: 0, timestamp_end: 10 }, | ||
| { timestamp: 15, timestamp_end: 25 }, | ||
| { timestamp: 35, timestamp_end: 40 }, | ||
| ]; | ||
| const minGapDuration = 10; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([{ id: "25-35", start: 25, end: 35 }]); | ||
| }); | ||
|
|
||
| it("should handle timestamps that are floats", async () => { | ||
| const sections: Section[] = [ | ||
| { timestamp: 0, timestamp_end: 10.5 }, | ||
| { timestamp: 20.5, timestamp_end: 30.5 }, | ||
| ]; | ||
| const minGapDuration = 5; | ||
|
|
||
| const gaps = await findGaps(sections, minGapDuration); | ||
|
|
||
| expect(gaps).toEqual([{ id: "10.5-20.5", start: 10.5, end: 20.5 }]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import type { Section, VideoClip } from "types"; | ||
|
|
||
| /** | ||
| * Finds gaps between video sections that are greater than or equal to the specified minimum gap duration. | ||
| * | ||
| * @param {Section[]} sections - The list of video sections. | ||
| * @param {number} minGapDuration - The minimum duration of a gap to be considered. | ||
| * @returns {Promise<VideoClip[]>} - A promise that resolves to an array of video clips representing the gaps. | ||
| */ | ||
| export default async function findGaps( | ||
| sections: Section[], | ||
| minGapDuration: number, | ||
| ): Promise<VideoClip[]> { | ||
| const gaps: VideoClip[] = []; | ||
|
|
||
| const validSections = sections.filter( | ||
| (section): section is Section & { timestamp_end: number } => | ||
| section.timestamp_end !== undefined, | ||
| ); | ||
|
|
||
| for (let i = 0; i < validSections.length - 1; i++) { | ||
| const currentSection = validSections[i]; | ||
| const nextSection = validSections[i + 1]; | ||
|
|
||
| const gapDuration = nextSection.timestamp - currentSection.timestamp_end; | ||
|
|
||
| if (gapDuration >= minGapDuration) { | ||
| gaps.push({ | ||
| id: `${currentSection.timestamp_end}-${nextSection.timestamp}`, | ||
| start: currentSection.timestamp_end, | ||
| end: nextSection.timestamp, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| return gaps; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.