Skip to content

Commit 9dd35d9

Browse files
Mhmd-Hishamgradio-pr-botfreddyaboulton
authored
Faster Video Trimming Without Re-encoding (#13325)
* input-side seeking and stream copy to avoid video re-encoding on trim * add changeset * Format --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Freddy Boulton <41651716+freddyaboulton@users.noreply.github.com>
1 parent 953efe0 commit 9dd35d9

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

.changeset/twelve-sloths-create.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/video": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Faster Video Trimming Without Re-encoding

js/video/shared/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ export async function trimVideo(
8686
);
8787

8888
let command = [
89+
"-ss",
90+
startTime.toString(),
8991
"-i",
9092
inputName,
91-
...(startTime !== 0 ? ["-ss", startTime.toString()] : []),
92-
...(endTime !== 0 ? ["-to", endTime.toString()] : []),
93-
"-c:a",
93+
...(endTime !== 0 ? ["-to", (endTime - startTime).toString()] : []),
94+
"-c",
9495
"copy",
9596
outputName
9697
];

0 commit comments

Comments
 (0)