Why prismic is not serving MP4 videos via CDN?

Hello,

I am developing a website that has multiple mp4 videos across different pages.

The video download time is slow and I have noticed that prismic is serving the mp4 files direct from S3 Buckets instead of a CDN like Cloudfront, it's also doesn't use any kind of compression to reduce the data transfer.

I read in the docs that prismic uses CDN by default, so I was wondering why prismic is serving the video files directly from S3 Bucket without compression?

Thank you very much!

Hey Tim, thanks for reaching out!

It is true that Prismic doesn’t currently offer an automatic compression with videos. We do it with images using the Image Optimization feature. So Maybe a solution would be to manually compress videos before uploading them to your Prismic media library.

And as you said, assets stored in the Prismic media library are stored in an Amazon S3 bucket and have a public URL. AWS provides Prismic connectivity to a variety of telecommunications and network service providers. AWS also provides Prismic with environmental control systems including fire suppression systems, cooling systems, uninterruptible power supply (UPS) systems, and generators.

You can read more details about this in our Security page.

Have you tried embedding youtube/vimeo/wistia videos instead?

Yes, as @marcellothearcanesuggested, hosting embedding video URLs that come from YouTube or Vimeo into an Embed field is a great approach. These services offer video compression support and both provide an excellent video player. We talk about that in this article:

Thanks for your reply!

Hey @tim2 even though we advise user to use embed for the reason that @Pau described, the mp4 that you upload should be distributed through CloudFront.

Are you not seeing a CDN endpoint when fetching a document through the API that links to an mp4 file?

I tried to reproduce but didn’t have the issue. Can you please send me an example of a request that I can replay to see the issue?

Thanks a lot,
Renaud

Closed due to inactivity

Hi Renaud,

unfortunately I'll have to bring this issue back up - on the website I'm working on I can see that the images are served via imgx and properly compressed. Unfortunately the videos seem to come from S3, no sign of Cloudfront nor compression - same thing happens to the other non-image assets. On this website there's a fairly heavy use of lottie files (json) and those come through uncompressed.
Is it something you guys are looking into implementing a some point or is it just a bug?

Thank you in advance for your time!
Fabio

Hello @fabio1, could you please send us your repo name and the URL of these assets?

Hi Pau, sure thing - where should I send the info?

Hey there. You can send it here or in a private dm to me

@Pau I am experiencing the same behaviour. I have a custom type (Singleton) with a "Link to media" field. When linking an .mp4 file from the media library and then querying the custom type via graphql and reading the _FileLink type for the field, the url property is a S3 URL (also the headers when fetching the file indicate S3 and not a CDN).

I ended up hosting all of my videos on Cloudflare R2, much better than S3 since they don't charge you on egress bandwidth and additionally the request and storage cost is lower and they offer caching in more regions. Maybe not the answer you're looking for, but it's a good alternative that I recommend. Perhaps Prismic needs to start offering R2 and stop using egress bandwidth in their pricing plans, instead Prismic should focus on number of CDN assets and potentially number of requests.

Why are there Chat GPT comments in here?

1 Like

Sorry about that. We're doing some digital pest control today.