Video bandwidth
Answered
KenTay posted this in #help-forum
KenTayOP
Hello everyone, I've reached my vercel 100gb bandwidth limit and noticed that my videos were taking a huge amount (see first screen). When I go to my page I noticed that on my page where all the videos are, they are fetched multiple times (second screen) and I don't know why. See my video card component below :
"use client";
import Image, { StaticImageData } from "next/image";
import React, { useEffect, useRef, useState } from "react";
interface IProps extends React.VideoHTMLAttributes<HTMLVideoElement> {
src: string;
thumbnail: StaticImageData;
isHovering?: boolean;
playOnHover?: boolean;
}
const VideoCard = ({
thumbnail,
isHovering,
playOnHover,
autoPlay,
...props
}: IProps) => {
const ref = useRef<HTMLVideoElement>();
const [isPlaying, setIsPlaying] = useState(false);
useEffect(() => {
if (autoPlay) {
ref.current.play();
setIsPlaying(true);
}
if (playOnHover) {
if (isHovering) {
ref.current.play();
setIsPlaying(ref.current?.networkState === 1);
} else {
ref.current.pause();
ref.current.currentTime = 0;
setIsPlaying(false);
}
}
}, [isHovering, playOnHover, autoPlay]);
return (
<div className="relative w-full h-full">
<video
className="pointer-events-none aspect-square"
ref={ref}
muted
loop
{...props}
></video>
{thumbnail && (
<div
className={`${
isPlaying ? "hidden" : ""
} absolute top-0 left-0 w-full h-full after:absolute after:top-0 after:left-0 after:w-full after:h-full after:bg-black after:opacity-40`}
>
<Image
src={thumbnail}
alt="Miniature"
className="absolute top-0 left-0 w-full h-full object-cover bg-white"
/>
</div>
)}
</div>
);
};
export default VideoCard;Answered by joulev
instead you should maybe host them on youtube or if you want a native large file hoster, try aws s3 or cloudflare r2 or similar
28 Replies
KenTayOP
Oh okay
so all requests to that video are counted towards the 100GB limit which definitely runs out very quickly
KenTayOP
Yes because besides video I don't have any big size datas
instead you should maybe host them on youtube or if you want a native large file hoster, try aws s3 or cloudflare r2 or similar
Answer
where limits on size and bandwidth are much better for large files
KenTayOP
But I can't do the change, it seems I'm not authorized to push something to production now that I exceeded the limit
I should have stick to cloudinary, that was my file hosting service
@KenTay But I can't do the change, it seems I'm not authorized to push something to production now that I exceeded the limit
yeah... you have to wait until the current billing period is over
which i think is the end of this month
until then you cannot make a deployment
bad luck but we can't really do anything here
@KenTay I should have stick to cloudinary, that was my file hosting service
exactly. only host application code on vercel, large files should be stored in places that are built for large files
KenTayOP
At least I learnt something else
So you're saying the billing period isn't like a 30 days span
It's a fix date monthly ?
@KenTay It's a fix date monthly ?
i think so yeah, because at least i get my pro plan invoices on the 30th of every month. not sure about the hobby plan
@joulev i think so yeah, because at least i get my pro plan invoices on the 30th of every month. not sure about the hobby plan
KenTayOP
Alright I think imma pay for this month
Thank you for your help
ðŸ‘ðŸ¾
And do you know anything about why my medias are being called multiple times ?
When I look in the network tab
@KenTay And do you know anything about why my medias are being called multiple times ?
this one i'm not sure. do you have many <video> elements on the page with the same src URL?
@joulev this one i'm not sure. do you have many <video> elements on the page with the same src URL?
KenTayOP
Not at all, I only have one of each. Maybe it's some useEffect behaviour but I can't tell
@KenTay Not at all, I only have one of each. Maybe it's some useEffect behaviour but I can't tell
i guessed that at first, but afaik the useEffect firing twice issue only happens in dev+strict mode
so your prod app shouldn't have that issue
@joulev so your prod app shouldn't have that issue
KenTayOP
Yes just saw this, on prod it's okay so it's alright I guess
Thank you again