Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Enable support for skipping processing

Richie McIlroyb0762c42e5dc
diff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
index 2e683a41a..603569f4c 100644
--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
@@ -263,7 +263,7 @@ export const ShareVideo = ({
{isLoading && (
<div className="absolute top-0 left-0 flex flex-col items-center justify-center w-full h-full z-10">
<LogoSpinner className="w-10 h-auto animate-spin" />
- {data.jobStatus !== "COMPLETE" && (
+ {data.jobStatus !== "COMPLETE" && data.skipProcessing === false && (
<p className="text-white text-lg mt-5">Video is processing...</p>
)}
</div>
@@ -295,7 +295,11 @@ export const ShareVideo = ({
>
<VideoPlayer
ref={videoRef}
- videoSrc={`https://v.cap.so/${data.ownerId}/${data.id}/output/video_recording_000.m3u8`}
+ videoSrc={
+ data.skipProcessing === true
+ ? `${process.env.NEXT_PUBLIC_URL}/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=master`
+ : `https://v.cap.so/${data.ownerId}/${data.id}/output/video_recording_000.m3u8`
+ }
/>
</div>
<div className="absolute bottom-0 z-20 w-full text-white bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-all">
diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsx
index 82e1ccf48..f2f5eb20a 100644
--- a/apps/web/app/s/[videoId]/page.tsx
+++ b/apps/web/app/s/[videoId]/page.tsx
@@ -60,7 +60,7 @@ export default async function ShareVideoPage(props: Props) {
const video = query[0];
- if (video.jobId === null) {
+ if (video.jobId === null && video.skipProcessing === false) {
const res = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/upload/mux/create?videoId=${videoId}&userId=${video.ownerId}`,
{
@@ -73,7 +73,7 @@ export default async function ShareVideoPage(props: Props) {
await res.json();
}
- if (video.jobStatus !== "COMPLETE") {
+ if (video.jobStatus !== "COMPLETE" && video.skipProcessing === false) {
const status = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/upload/mux/status?videoId=${videoId}&userId=${video.ownerId}`,
{
diff --git a/apps/web/utils/video/ffmpeg/helpers.ts b/apps/web/utils/video/ffmpeg/helpers.ts
index 50a043b7a..b1678a09e 100644
--- a/apps/web/utils/video/ffmpeg/helpers.ts
+++ b/apps/web/utils/video/ffmpeg/helpers.ts
@@ -91,7 +91,10 @@ export async function generateM3U8Playlist(
let m3u8Content = baseM3U8Content;
urls.forEach((segment) => {
const { url, duration } = segment;
- m3u8Content += `#EXTINF:${duration},\n${url}\n`;
+ m3u8Content += `#EXTINF:${duration},\n${url.replace(
+ "https://capso.s3.us-east-1.amazonaws.com",
+ "https://v.cap.so"
+ )}\n`;
});
m3u8Content += "#EXT-X-ENDLIST";
@@ -113,7 +116,10 @@ export async function generateMasterPlaylist(
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Audio",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",URI="${audioPlaylistUrl}"
#EXT-X-STREAM-INF:${streamInfo}
-${videoPlaylistUrl}
+${videoPlaylistUrl.replace(
+ "https://capso.s3.us-east-1.amazonaws.com",
+ "https://v.cap.so"
+)}
`;
return masterPlaylist;