Next video optimization #20323
Replies: 13 comments 3 replies
-
Great idea! |
Beta Was this translation helpful? Give feedback.
-
I am not clearly sure if my idea(s) would be a good one(s), but I hope they could use some cool tech like socket programming(it has been there for ages, and should there be something equivalent that can be implemented using JS stack) to optimize real-time video rendering. If not, they could also try to utilize web assembly in any other new ways, to churn up a technique to optimize videos. It might seem crazy, but it impossible these days to limit the abilities of any tech. Who knows, someday PHP might become a huge deal as like the world of JS and Python. |
Beta Was this translation helpful? Give feedback.
-
Absolutely! Stream + webm would be so sweet candy |
Beta Was this translation helpful? Give feedback.
-
What's missing from Next.js? Video components and video optimizations! For inspiration, check out the following open-source projects. Inspiration 1 Look at @cloudinary open-source work for rendering video components using React.js: You can specify transformations using the For example, <Video cloudName="my_cloud" publicId="watchme">
<Transformation overlay="text:arial_60:watchme" gravity="north" y="20" />
</Video> Will be compiled by React to: <video>
<source src="https://res.cloudinary.com/my_cloud/video/upload/g_north,l_text:arial_60:watchme,y_20/watchme.webm" type="video/webm">
<source src="https://res.cloudinary.com/my_cloud/video/upload/g_north,l_text:arial_60:watchme,y_20/watchme.mp4" type="video/mp4">
<source src="https://res.cloudinary.com/my_cloud/video/upload/g_north,l_text:arial_60:watchme,y_20/watchme.ogv" type="video/ogg">
</video> Inspiration 2 Check out @imagekit-developer work on URL-based transformations (video transformation) and video optimization: Here's an simple URL structure:
|
Beta Was this translation helpful? Give feedback.
-
Videos make up the majority of all consumer internet traffic. It's time to implement a For inspiration, check out:
|
Beta Was this translation helpful? Give feedback.
-
Love this idea ❤️ and would love to help. We have the Mux Player in beta now: React example: https://codesandbox.io/s/mux-player-react-uqz58z |
Beta Was this translation helpful? Give feedback.
-
If your video has /* /src/scripts/video-lazyload.jsx */
import Script from 'next/script';
export default function VideoLazyLoad() {
return (
<Script id="show-banner" strategy="afterInteractive">
{`!function(){var e=[].slice.call(document.querySelectorAll("video.lazy"));if("IntersectionObserver"in window){var r=new IntersectionObserver(function(e,t){e.forEach(function(e){if(e.isIntersecting){for(var t in e.target.children){var a=e.target.children[t];"string"==typeof a.tagName&&"SOURCE"===a.tagName&&(a.src=a.dataset.src)}e.target.load(),e.target.classList.remove("lazy"),r.unobserve(e.target)}})});e.forEach(function(e){r.observe(e)})}}();`}
</Script>
);
} /* src/pages/_app.jsx */
import VideoLazyLoad from 'scripts/video-lazyload';
export default function App({ Component, pageProps }: AppProps) {
return (
<VideoLazyLoad />
<Component {...pageProps} />
)
} Then the videos you want to lazy load, add the <video class="lazy">
<source data-src={src} />
</video> References: |
Beta Was this translation helpful? Give feedback.
-
All the answers are amazing and useful, but they are a little off the original idea. The idea is to add INSIDE the NextJs a solution for video optimization using NextJs/Vercel itself, not using paid tools. I'm not saying the answers given aren't useful or can't be used, but it's not what I had in mind when I opened this discussion. |
Beta Was this translation helpful? Give feedback.
-
I'd love to see something like this directly in Next.js. The first time I used A few of the challenges with this (and why video is not quite as easy as images):
That's not to say that any of these challenges can't be overcome, and especially if we're talking about very short videos that are say, under a minute long. Things you might use for background hero videos or small graphics on the page, then that gets significantly easier to figure out. |
Beta Was this translation helpful? Give feedback.
-
While this might not be directly related to video optimization, I see potential for As far as I can tell, there is currently no way to elegantly load an image from next.js's optimization cache when it isn't used as an element on the page. However, video thumbnails, i.e. the |
Beta Was this translation helpful? Give feedback.
-
+1 next/video should 100% exist |
Beta Was this translation helpful? Give feedback.
-
Folks on this thread might be interested in this RFC for next/video |
Beta Was this translation helpful? Give feedback.
-
Would love to have a NPM package related to it, let me try building one. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I wish there was something like next/image but for videos. I don't know if it would be viable since it would require a lot of processing (I think), but maybe you will find a way to make it viable.
As I said, it would be something like next/image, it would reduce the quality of the video, convert it to webm, maybe even stream the files (like uploading YouTube in parties).
I hope you enjoyed the suggestion and are able to add it. Good luck!
Beta Was this translation helpful? Give feedback.
All reactions