-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: start processing after buffered MP4 recordings finish uploading #1911
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
richiemcilroy
merged 3 commits into
CapSoftware:main
from
ManthanNimodiya:fix/buffered-raw-recording-processing-trigger
Jun 12, 2026
+56
−1
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
a3a812a
fix(web-recorder): start processing after buffered MP4 recordings fin…
ManthanNimodiya 724644f
fix(web-recorder): use authenticated user id for raw file key
ManthanNimodiya 8d6482e
fix(process-video): skip raw upload cleanup when raw key matches outp…
ManthanNimodiya 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
39 changes: 39 additions & 0 deletions
39
apps/web/actions/video/trigger-instant-recording-processing.ts
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,39 @@ | ||
| "use server"; | ||
|
|
||
| import { db } from "@cap/database"; | ||
| import { getCurrentUser } from "@cap/database/auth/session"; | ||
| import { videos } from "@cap/database/schema"; | ||
| import type { Video } from "@cap/web-domain"; | ||
| import { eq } from "drizzle-orm"; | ||
| import { startVideoProcessingWorkflow } from "@/lib/video-processing"; | ||
|
|
||
| export async function triggerInstantRecordingProcessing({ | ||
| videoId, | ||
| }: { | ||
| videoId: Video.VideoId; | ||
| }): Promise<{ success: boolean }> { | ||
| const user = await getCurrentUser(); | ||
| if (!user) throw new Error("Unauthorized"); | ||
|
|
||
| const [video] = await db() | ||
| .select() | ||
| .from(videos) | ||
| .where(eq(videos.id, videoId)); | ||
|
|
||
| if (!video) throw new Error("Video not found"); | ||
| if (video.ownerId !== user.id) throw new Error("Unauthorized"); | ||
|
|
||
| const rawFileKey = `${user.id}/${videoId}/result.mp4`; | ||
|
|
||
| await startVideoProcessingWorkflow({ | ||
| videoId, | ||
| userId: user.id, | ||
| rawFileKey, | ||
| bucketId: video.bucket ?? null, | ||
| processingMessage: "Starting video processing...", | ||
| startFailureMessage: "Video uploaded, but processing could not start.", | ||
| mode: "singlepart", | ||
| }); | ||
|
|
||
| return { success: true }; | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processVideoWorkflowdeletesresult.mp4after processingstartVideoProcessingWorkflowcallsprocessVideoWorkflow, which finishes withcleanupRawUpload(videoId, rawFileKey)— an unconditionalbucket.deleteObject(rawFileKey). For the streaming-webm pathrawFileKeyisraw-upload.webm, a distinct intermediary that should be cleaned up. HererawFileKey = "${user.id}/${videoId}/result.mp4", which is also the hardcodedoutputKeywritten by the media server (${userId}/${videoId}/result.mp4inprocess-video.tsline 255). After the media server successfully writes the transcoded output toresult.mp4,cleanupRawUploadimmediately deletes that same key, leaving the video unplayable.The existing admin reprocess path (
adminReprocessVideoWorkflow) handles exactly this case — it calls the media server in the same way but has no cleanup step. Either route through that workflow, or guard the cleanup inprocessVideoWorkflowso it skips deletion whenrawFileKeyequals the output key.Prompt To Fix With AI