I am afraid that this is not entirely possible. In order for the browser to determine the size of the video, it must first download it.
One solution could be, assuming this would even work, first load the video without specifying the height and width, but using CSS to hide the video, calculate the dimensions, destroy the video and load it again when you right-click the size. That would be incredibly inefficient.
Alternatively, you can make a server-side script (PHP / ASP / ...) that reads the video file, determines the height and width when you first save the content, and save the height and width in the database, Then you can read the height and width from Databases on every pageview. Although you could make such a script to view the video file with each request, it would be inefficient and increase the time required to create the page.
If you use PHP, I highly recommend you look at ffmpeg-php , a free open source library that you can use to parse several types of video files.
Another thought: Another solution might be to not specify the height and width in the embed code and let the browser modify the video on its own. You can then resize the lightbox to fix the video container. Many Lightbox plugins have events that you can plug in.
source share