#Videos are not playing in build
1 messages · Page 1 of 1 (latest)
It seems like you're having trouble with video playback in the production build of your Next.js application. Here are a few things you might want to check:
- Video File Path: Ensure that the path to your video files is correct. In Next.js, the public directory is the root of your server, so you should reference your video files relative to this directory. For example, if you have a video file at
public/videos/myVideo.mp4, you should reference it in your<video>tag like this:
<video width="320" height="240" controls preload="none">
<source src="/videos/myVideo.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
(Source: Next.js Docs (https://nextjs.org/docs/app/building-your-application/optimizing/videos))
-
Video File Format: Ensure that the video format is supported by the browsers you're targeting. MP4 is widely supported and is a good choice for web video.
-
Server Configuration: If you're self-hosting your Next.js application, ensure that your server is configured to serve video files. This might involve setting the correct MIME types for video files.
-
Video Optimization: Large video files can lead to excessive bandwidth usage and performance issues. It's important to ensure your videos are compressed and optimized. You can also consider using a video hosting solution like Vercel Blob, Vimeo, S3 + BunnyCDN / Cloudfront, Mux, or Cloudinary. These platforms may offer additional options to customize, compress, and transform your video files.
(Source: Vercel Guides (https://vercel.com/guides/best-practices-for-hosting-videos-on-vercel-nextjs-mp4-gif))