Skip to content

Commit

Permalink
feat: Enable support for skipping processing
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Jun 4, 2024
1 parent c00bc0c commit b0762c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions apps/web/app/s/[videoId]/_components/ShareVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/s/[videoId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
{
Expand All @@ -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}`,
{
Expand Down
10 changes: 8 additions & 2 deletions apps/web/utils/video/ffmpeg/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down

1 comment on commit b0762c4

@vercel
Copy link

@vercel vercel bot commented on b0762c4 Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.