Hey, in this video, we're going to be building our own self-hosted, completely free alternative to Loom. The reason why I'm even building this is because I'm planning to improve my cold outreach campaigns, right? Just some business stuff. And one of the things I'm doing now is recording custom Loom videos for my clients, right? The only problem is that Loom is a paid product. And look, I have no problems paying for this service. The only thing is that I can actually build this myself in like two days, just vibe coding a solution that works for me and not have to pay a single cent for it. And so that's what I'm going to try to do in this video.
This might become a really long video, or I might actually divide it into a couple of parts. But the idea is I'm going to be building this project live in front of you and just show you my process of building and how I am building new software in the age of AI agents and everything. I've made project series before. As you know, if you follow my channel for a very long time, you know, I've built things like the Redis database clone in Go and a bunch of other projects. And those have like 20, 30 different parts of like a whole video series.
I stopped doing those kinds of videos because, like, AI writes all my code now anyways. And I mean, if you can prompt it, if you can prompt the agent, you can pretty much build whatever you want nowadays. So, like, is this really valuable, is what I was thinking. But turns out if you're a junior developer, or you just haven't been developing for a very long time, if you're just a pure vibe coder, you probably still suck at writing good prompts and understanding the architecture, right? No offense.
So in this little video, not little video, this is probably going to be an hour long. But in this video, we're going to build an actual project, and you're going to see how I work and how I use these agents to write code faster, but also make sure that that code is maintainable, reliable, and all those other things, right?
So those are little Excalibur presentation over here. We're just going to go through this real quick. Some potential solutions for some potential alternatives and free solutions to Loom, and why I'm not going with them.
Instead of hosting a client's outreach video on Loom, which is a paid service and I'm avoiding that, you could use Google Drive to host the video file and just send a link to that video to the client. You could do that. The only problem is that this is just going to have the Google Drive-owned video player. It's going to have Google-owned branding, and it's not really very scalable, right?
And when you're recording like 20 different videos every single day, sending out 20 different proposals to 20 different clients, uploading all of these to Google Drive and managing all of that, that becomes kind of a headache, right? So this is obviously not going to be my solution.
The second one, and then even more horrible solution, is to use YouTube unlisted videos. Now, this is just a very, very bad idea, and this was actually my first instinct. But turns out this is a horrible idea because, yeah, you could upload a video on YouTube, set it to unlisted, and then share a link to that video with your client.
The only problem is this is extremely unprofessional. You're gonna have the YouTube sidebar with suggested videos popping up, and if your client doesn't have an ad blocker installed, which, let's be honest, a lot of non-technical people, you know, the kind of people that I'm targeting with my content and my products and services, they probably don't have an ad blocker installed, which means they're going to have to go through like 10 different ads, like 15-second unskippable ads in my outreach video where I'm trying to explain to them why they should hire me. And then there's some fucking ad playing, right?
So this is a horrible approach. And obviously you have the YouTube video player with its own custom controls and branding and everything. And that's the least of the problems in this whole list. So obviously we can't go with YouTube unlisted either.
So we're going to have to build our own self-hosted alternative to this. Now, the way we're going to build this is we're going to have a Next.js web app to actually host the video player. This is going to be a very minimal app. It's just going to have like one or two pages, right? Each video that you put on this app is going to have its own little page, and the client can just view that page and watch the entire video. You can just share that link with the client. Super simple.
We're going to have an—we're going to have a Cloudflare R2 bucket. This is basically like Amazon's S3, but it's free, at least for the first 10 GB of storage, which is more than enough for our needs. And finally, we're going to have a bunch of shell scripts to manage the R2 bucket automatically.
These are just going to be a bunch of simple Bash scripts that I'm going to have on my local machine over here. And I can run these anytime to upload a new video, to delete some older videos to make more storage, so we stay under a 10 GB limit, and so on and so forth.
And here is a step-by-step building plan for building this entire project. So without further ado, let's head into my code editor and let's start building this whole thing.
Okay, so instead of going to my code editor, let's first go to—let's first go to Cloudflare and actually configure all of this stuff. So I've already done this, but what you basically need to do is go over to Cloudflare, sign up for their cloud service, head over to R2 Object Storage over here in the Storage and Databases section, create a new bucket over here. I've already created one called Loom. This is where I'm going to store all of my videos. This resume is just a test example file I put over here just to make sure things were working. Ignore that, and you're just gonna set up a bucket over here, and then you can proceed.
Now, before Cloudflare allows you to create an R2 bucket, it's also going to ask you to verify your payment account, your payment method, and basically ask you to add a credit card. You can use a card for this. It's completely safe. Nobody's going to charge you any money as long as, as long as you stay under the free tier limit, which is 10 GB of storage.
But just to be safe, you can go over here to Billing Usage, and you can set up a budget alert. I've already set one up for literally just 10 cents, as in if I so much as—if this thing, if this thing starts to cost me any money at all, I'm going to get a budget alert, and I can go and turn it off if I want to.
So you can set that up as well, just to make sure that you spend zero money on this, and this is completely free. Set up the budget alert, add your payment method, create your R2 bucket, and then go over here in Manage API Tokens and create an account API token for you to use. This is going to give you a bunch of credentials you'll need. I've already created one, as you can see. I just realized I'm gonna have to blur so much information in my Cloudflare account just to make sure nobody hacks me.
But once you create an account API token, it's going to give you some things like the access key ID and the secret access key.
And these are basically a bunch of credentials that you're going to use to access the Cloudflare R2 bucket programmatically from your web app, basically.
Okay, so go over here, create an account API token. Once you've done all of this, then let's proceed to the next step.
The next thing we're going to do is configure our Rclone. So our Rclone over here is basically a CLI tool that allows us to use pretty much any cloud storage without having to necessarily write all the code for it.
So what you do, or how you use this is, let me zoom in as well so you guys can see this more clearly. You just say `rclone config`. And then, as you can see, I've already got a bunch of remotes over here. This is the one we're going to use on Cloudflare.
What you do is you just press N. This is going to help you create a new remote, and it's going to ask you a big bunch of questions: the name of the remote, the access key ID, and the secret access key, and all the other stuff you're going to need.
You can get all of those things, all those credentials, from Cloudflare. Fill all of them in, fill all of them in, and then you're going to have your Rclone remote, which you can use to upload files and download files from this S3 bucket.
And just to show you an example, I can say something like `r2-loom`. That's the name of the remote over here, as you can see. And then I can say `/loom`. That's the name of the bucket in Cloudflare over here, as you can see. And it has a resume.pdf file, right? I can just send this command, and as you can see, it does see that resume.pdf file. So we know this is working properly, so we can start to use this.
Okay, and once you've set all of those things up, I'm gonna just mark this completed. We can move on to the next step, which is to create a shell script to upload a lossless-compressed video to R2.
So every word I just wrote there is important. We want to obviously upload a video to R2. That's kind of the point of this project, but we want to make sure that it is compressed, but we also want to make sure that the compression method we use is lossless, so we don't lose any video quality.
The reason we want to compress this is because, like, look, this is going to be a bunch of screen recordings, right? And screen recordings are notoriously bloated in most software, especially in most software, including OBS, which is the one I'm using to record this video over here.
We want to compress it so that we can save more on storage and store more videos, because remember, Cloudflare R2 buckets for free are just going to give you 10 GB, so you want to make sure you're getting the most out of it. So we're gonna have to compress it as well.
Now, this is, again, really simple. In fact, in fact, I have the command for this right here. I just asked Gemini to give me a command to compress an OBS screen recording without losing any quality.
The reason I asked Gemini is because I'm no expert at FFmpeg and video compression and all these other things, so I'm just going to ask these bots to give me the right command, and I'll just paste that in, right?
So now we need a script, a shell script, basically, that can compress our video file and just upload it all the way over to our R2 bucket.
So what I'm going to do is I'm going to copy this whole command and head over to my video editor again and open up my agent. And let me open up my file explorer over here as well.
So I have a script. I'm going to copy this whole command and head over to my video editor again and open up my folder. I'm just going to create a script over here called `upload-to-R2.sh`. I'm going to pass that in over here in my context.
And then let me just write a prompt for this. I want you to write a Bash script that's going to use Rclone to upload a file to my Cloudflare R2 bucket. Before you upload the file, make sure that you compress it using the FFmpeg command that I'm going to give you below.
This is going to be a video file. You're just going to take the path to the video file from the user, and you're going to compress it using the command I give you below, and you're going to upload it to Cloudflare R2.
Okay, there we go. Now, the FFmpeg command I'm going to give it is right here, and let me just mention: use the Rclone remote `r2-loom` and the bucket name `loom`. And now let's just let it do its thing.
By the way, I hope I can just zoom out a little bit because I hate working in such a zoomed-in environment, but it is necessary for the video so you guys can see this too.
But here we go. Here's the script. So we have this script over here. I'm not going to read the entire code, by the way. More on that later, but let's just read the agent output over here.
Okay, it validates all of our requirements, checks that both FFmpeg and Rclone exist, compresses the video using the command we gave it, and then just uploads it to R2.
And I didn't ask for this, but this is a very useful feature to have. Thank you, Gemini. It's going to automatically delete the temporary compressed file on exit, even on failure or cancellation.
Now let's actually test this out, right? I'm going to go to scripts, upload to R2. And as you can see, it asks me for a video file.
So let me see if I have one over here. Videos. If I go over to my YouTube projects, freelancer intro. Maybe I shot, I recorded a new intro for my freelance profile, so let's try using that. Where? Final.mp4, I think that should be fine. And I'll give it a custom name as well. Why not? Freelancer intro.mp4. There we go.
So now this is running an FFmpeg command to compress the entire video file before it uploads it to R2, basically, right? This video file is 39.92 MB, as you can see over here. So let's see how much this script can actually compress it.
Now, while it does this, I'm going to just minimize this a bit and start building the actual user interface, the actual web app over here, right? So I already know what color I want to use. It right here. This is like a light blue kind of a color. We're going to use this as the primary color for this app, just because I like it. Obviously, you can use whatever you want.
So let me think about what prompt I'm going to give to this agent right now. Actually, instead of having a homepage, we should probably, like, what we really need over here is a video player, right? Actually, instead of building the homepage first, what we should build is probably a page to view the videos, right? So I'm just going to say something like we, and then I'm gonna create a ID folder over here and then a page inside it. This is just how navigation in Next.js works, right? Let's maximize that.
I'm gonna pass that in over here, and I'm just gonna say, use the HSL color that I just gave you to create a bunch of shades. I want you to create at least 12 shades. To create these shades, just increase or decrease the lightness of the color. After every three or four shades, increase or decrease the saturation by just one or two points to make the color seem less dull as you're increasing or decreasing the lightness. Once you have all 12 shades, use them as the primary brand color for this entire website.
What I want you to do is create this page over here that's going to take a video ID, and it going to display that video in a custom video player. Let just give it that prompt.
By the way, the reason I giving it such specific instructions to create these 12 shades and how to create them is because I learned this from a design book called Refactoring UI. It's built, it's written by the same people who built Tailwind. It's a very, very good book. You should probably check it out.
But we also need to, but anyway, back to the project. We also need to think about what kind of video player we want to use. So let's say, suggest me some options for what video player to use. Again, I'm no expert in these things. I do know how to write good apps, but I'm no expert in video player or which one's the best or which FFmpeg command I'm supposed to use or all these other things, right?
So I'm going to ask the agent to give me a bunch of suggestions that I can then review. And the agent is probably smart enough to figure this one out, but I should say it anyway. Add all 12 shades to my Tailwind theme in globals.css. Let's make sure my agent sees that as well.
And while I was doing all that, it turns out my upload command finished as well, successfully uploaded to R2Loon. So let's go see if that worked right here. Let's open up. Okay, it's already open. Let me refresh this, and there we go.
So the original file was 40 MB. All, most, this is 25 MB. So the compression works, and the upload also works. So yeah, step one is complete. Now let's review these options over here. It looks like the base HSL color value wasn't included in your message. That's my fault. Put that over here as well. Let's just say, use this color. There we go.
And then ask for the video player options. With Stack Player, modern, built specifically for React and Next.js, fully headless, production-grade video playback. Okay, custom handcrafted player, probably not a good idea. It's probably best to use a video player that someone else has already built and is being used in many websites instead of creating your own over here.
Media Chrome, composable web components around the standard video HTML element. I don't know what this is. Player React, clean, minimalist default aesthetic. Okay, so let me actually go and Google Vidstack real quick and just see what it looks like.
Okay, so I'm definitely loving the design that these guys have over here. This looks like a very well-made website. Okay, so they have a player demo over here. Let's just see what that looks like. Okay, okay, so I actually like this a lot. It has all the controls I need. The icons look very nice. It has chapters as well. That going to be very useful for us because I plan to include those things as well. Timestamps and chapters, right? Okay. Yeah, I think we just going to use this. Use Vidstack as our video player. There we go.
Okay, and one thing I just realized is we missed a step over here. Let's also... Okay, and while it's doing that, let me go back to my little whiteboard over here and add another step. We're going to also add timestamped chapters to each video. And yeah, that's going to be the final thing that we add. And then we're going to add the testing and final changes.
Let's go through the implementation plan it wrote for us. Brand palette, video player, video URL source. Okay, let's see. Okay, so I guess before we approve this plan, we want to figure out how to actually, you know, display our videos, or at least fetch our videos from Cloudflare R2.
Because I did some research on this, and you can't actually use the public endpoint of the bucket because that, that is heavily rate limited, throttled, and it is not meant for production use. What you need to do is create, is configure your own subdomain to use Cloudflare CDN. So let's figure out how to do that.
So Cloudflare has their own AI agent over here. It is extremely useful. I been talking to it a lot, and it is very good at helping you achieve things on the Cloudflare cloud platform, right? So I want you to help me set up Cloudflare CDN to serve the files, the video files in my R2 bucket called Loom. Got a custom domain hosted on Namecheap. I'm just going to keep it over there, but I want you to help me connect it to Cloudflare CDN over here.
So yeah, for those of you who don't know, I, my domain is hosted on Namecheap, and yeah, just letting you know. And as you guys can see, I'm building this right alongside you. I haven't built this project before. This is my first, this is my first time building it. I'm just gonna put this whole video out there so you guys can actually see how I build the problems and challenges I have to go through and how I actually overcome them. I think this is going to be very valuable for especially junior developers.
Okay, so this is kind of a problem. I can't actually keep my domain on Namecheap. The domain is registered on Namecheap, but the name servers are, uh, are hosted on Vercel, and I'd rather keep them over there. Okay, so this is gonna be a bit of a problem because apparently I can't host my domain on Vercel and still use Cloudflare CDN. So we're gonna have to to figure that one out.
But for now, I guess while I figuring this out, I can use the R2 public bucket URL. This is not meant for production. As you can see, it rate limited and does not use CDN caching. But just for now, just to get this working, right?
Let's just use that. So I'm going to go over to the bucket settings. I'm going to enable the public development URL, type in "allow" to allow this. There we go. And okay, so that's the URL for this bucket. Let me just test this. What if I said resume.pdf over here? Would I get the file? Okay, so I would get the file. Perfect. Yeah, this is my resume, guys. If anyone wants to hire me, you can read through this. But yeah, this thing works.
We're gonna configure Cloudflare CDN later on. But for now, let's just get this app working, right? I'm gonna mention over here in the agent chat, gonna give it this URL and say use. Okay, that's not gonna work. It just asked me to approve a command. This is one thing that's very annoying about EnterGravity. As you're typing a prompt, if it asks you for a command, it just loses all input of that prompt. So that really sucks.
So let me just say, "Use this URL to get the videos from Cloudflare. We will switch to Cloudflare CDN later on." Now the next thing is how exactly do you figure out which ID belongs to which video, right? Well, that is going to have to be done via some sort of a database. But I actually don't want to use a database. I think that's way too overkill for such a simple app. So I'm trying to figure out what a better way or a simpler way to do that would be. And as I'm thinking out loud, I just figured it out. Let me show you.
So here's what we could do. What we can do is we can have the ID of the file be the file name, basically. So instead of having custom file names over there, what we can do is we could set each file name to be, first of all, the actual name of the file, like Freelancer Intro, right? And then we could add a UUID over here and then the final video extension. And what we can do then is we can search for the file that has this particular UUID, just get it and play it, right?
So let's implement that. And the reason we're doing it this way is because we eliminate the need for a database. I don't need to have a database anymore, right? Let me draw a quick database over here. Just drawing a table over here, right? Let's say we have an ID column, we have a file name column. We don't need to have a database to store each ID and each file name separately, right? We can put all of that information inside the actual file name. That eliminates the need for us to manage a Postgres or SQLite database, and you can get all that information from the file name.
So yeah, let me bring that back. Let's go with an approach like that. Skip the build. I'm gonna wait for the agent to finish over here before I give it the next prompt. Just accept all the changes. This is the first stage of the app, so we don't really need to worry about the code right now.
Modify the upload to R2 shell script to add a UUID to every single file before uploading it. Use the format I give you below. And then I'll pass in the upload script over here so it knows which file to edit. The file name format is going to be a file name dash UUID dot MP4. This way, each file name will have a unique UUID at the end, just before the file extension. You can use this to figure out which file to play on the actual video player page.
So when I go to my website over here and I go to a video page, you can grab the UUID that I'm using from the URL, and you can use that to search which file we're gonna have to view in R2.
Actually, now that I think about it, this approach might not actually work because, like, how would you know the name of the file? Oh my God, wait a second. Yeah, this might be a bit of a problem. Or actually, no, no, I'm overthinking this because we do know the file name and the URL because we're, yeah, because we're sharing the links, right? I'm retarded. Okay, this is going to work. I'm just overthinking this a lot.
Anyway, just let the script do its whole thing, and I just realized they gave it a bit of a confusing prompt over here. You don't need to find the video using the UUID alone. You're going to be given the entire file name as well. Here's how we can structure this. We can have a URL segment that matches the file name entirely instead of using the UUID, but we can also add the UUID to the file name. Let's do both.
So as you can see, I'm going back and forth over here because I didn't actually plan this project beforehand. So, like, so, like, you can see me going through all of these different things, different approaches, and trying to select the best approach by actually iterating over here. So you can say something like website slash v slash file name. Let's use that approach instead of using a UUID. And let's keep the shell script adding a UUID to the file name so that each file name has the original file name plus a unique UUID so that people can't exactly guess the file name on their own. And that's basically the reason why I wanted to use UUIDs in the first place.
Okay, so that should be good enough. Let's let the agent do its own thing. In the meantime, let's run this website as well in development mode and see what the agent cooked for us. Okay, so we're just using the default Next.js page over here. No big deal. I have no problems with that. There we go. All the changes have been done.
So now what we should do is we should re-upload the, what is it, the freelancer intro that we just uploaded. Let me get the command for that. There it is. And I wonder if I can still send a custom file name and it'll still add a UUID. I hope it does because if not, we're going to have to tell the agent to go fix that.
But yeah, this is the kind of URLs we're going to generate from now on. Like, I'm gonna put this on some subdomain that I own, and it's gonna be so easy for a client to just go to this URL, watch the entire video I made for them.
And, you know, by the way, this video is getting extremely long. I've been recording for like 40 minutes now. It's probably best if I cut this project into a bunch of parts. Because as you can see, we literally only did like the first two steps, or the first three steps, depending on how you want to count it. And we're already out of time. This video is getting way too long.
So I'm going to let this script finish. We're going to test that we can actually view the video file. Hopefully we can, because I want to end the video now and film the next part later. But yeah, this is what I'm going to be building for the next couple of videos at the next couple of days, at least.
By the way, I know that I was very, like, all over the place, didn't have my thoughts organized, and just didn't know what the fuck I was doing in this video. But that's mostly because this is how I build a new project, right? I have an idea for something that I want to build, and then I just start implementing some things, start figuring things out, start iterating a lot, especially now that AI is writing all of my code.
It's just so easy to iterate, right? I can ask the agent to produce like 500 lines of code and then not like the approach that I'm taking and just discard those 500 lines because code is so cheap now.
And so this is how I build, just having some ideas, trying to implement them, seeing how that looks and how that works, iterating on every single idea, and just trying to figure out the best approach.
Anyway, the upload finished. So let's clear my screen now. Let's run the development server again. Hopefully this works. Maybe I need to configure CORS as well. CORS, origins, and all those other policies. Hopefully not.
If I refresh my bucket over here, you can see I have this URL. Let me just grab the entire file name for this and just paste it over there in my app. There we go. Let's copy that. Slash V slash. There's the video file. Let's see what happens.
Okay, so the design isn't too bad, but it looks horrible. It looks very vibe coded. We're going to have to fix that later on. This intro text is completely hidden because it's, I don't know, I guess it's trying to mix some light or dark themes over here. What happens if I turn on dark mode? Okay, now that actually looks a lot better.
So the design needs a lot of work. I guess they added a bunch of information down here as well. This is kind of cool, but we're going to have to remove most of it. The design needs a lot of work.
And the video is not loading. So let's try to figure out why that is. Yeah, so as I thought, we're going to have to configure the CORS policy as well.
Let's go back to our settings over here. There's the CORS policy. Configure CORS headers that R2 will set when accessing this bucket content from a browser.
Okay, so I already have my CORS policy over here. So why isn't this working, right? Okay, so they already gave me this as a default. Let's try adding that and see what happens. Your bucket is now configured with the specified CORS rules.
Let's refresh this and see what happens. Sometimes it does take like a couple minutes to refresh the Cloudflare cache. Okay, there we go. You can see my funny clown face over there, and now we're playing this video.
Now, just look at how much, how much more professional this is, right? Isn't this just so much better than using some YouTube unlisted video that's going to have ads and sidebars and suggested videos, or using some Google Drive link that just looks so cheap and unprofessional?
This is so much better, right? If I send a link like this to the client, like, look, I could just copy this link and just send it over to some client, and you can view the same video as this. That looks so much more professional, right?
And so this is what I'm going to be building over the next couple of days, and I'm going to film the entire process, and hopefully someone can get some value out of this.
Anyway, this video is getting way too long, so let's stop right there. I hope this new series that I starting is a bit useful for you guys because, like, let be honest, I haven't made these kinds of videos in a very long time. I don't film any project build series where I build a project like this and show you how I'm building it. I haven't done that in a very long time.
And the reason is, I just didn't think those videos were valuable anymore or that anyone would watch them because AI writes all of our code. You can give your agent any prompt, and it can go and build the app that you want to build.
But I also think that these videos are more valuable, or these videos are valuable for a different reason, for a better reason, and that is you get to see a software engineer actually building the app, actually going through so many different problems. As you saw in this video, my mind was just in like 20 different places at once. I had no idea what I was doing because I was just so new to building this app, right? Like, I hadn't planned this script. I hadn't planned this. I didn't plan this video out very, like, in a very, I didn't plan this video a lot.
I just, you know, had the idea for a project and just started building it right in front of you, live alongside you. This is the kinds of problems you're going to be facing as you're developing your apps as well. And I just hope that, you know, these kinds of videos can help you out as you can see me going through the same challenges and just see how I overcome them. And hopefully that helps you as well.
Anyway, again, this video is getting way too long. I'm not going to take any more of your time. 47 minutes. We've been recording for a very long time. Let's stop now and, you know, we'll do the rest in part two. See ya.