How to get width and height of mp4 file in php code before playing them [duplicate]

Asked
Active3 hr before
Viewed126 times

7 Answers

duplicateheightwidth
90%

I need to open file with .mp4 extension in popup. It is playing nicely and all other things are perfectly done. But when that popup is opening. At that time I want it to open with same height and width as of the video. I have that kind of more then 25 videos on my page. So I will store that parameters in code and then use it in javascript when I will open the popup. So I want to know video files width and height before I am playing that file. I want to know these parameters in php. , How can an NPC replace some pages of a book with different pages, without leaving a trace of manipulation? , By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. ,I don't wanna install any php extension (it's a disaster work under Windows, especially Windows 64bit), so I use ffprobe and a php (as follows) to get the dimension:

Try the php-mp4info library.

include("MP4Info.php");
$info = MP4Info::getInfo('directory/to/file.mp4');
if ($info - > hasVideo) {
   echo $info - > video - > width.
   ' x '.$info - > video - > height;
}

The $info object is, for example, as follows:

stdClass Object
   (
      [hasVideo] => 1[hasAudio] => 1[video] => stdClass Object(
         [width] => 480[height] => 272[codec] => 224[codecStr] => H .264
      )[audio] => stdClass Object(
         [codec] => 224[codecStr] => AAC
      )[duration] => 6
   )
load more v
88%

Returns the size of the file in bytes, or false (and generates an error of level E_WARNING) in case of an error. ,Note: Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. ,Example #1 filesize() example, Gets the size for the given file.

load more v
72%

The controls attribute adds video controls, like play, pause, and volume.,It is a good idea to always include width and height attributes. If height and width are not set, the page might flicker while the video loads.,This allows you to load, play, and pause videos, as well as setting duration and volume.,To start a video automatically, use the autoplay attribute:


The HTML <video> element is used to show a video on a web page.

<video>
load more v
65%

Save your audio and video files in a new directory on your computer.,We won't be teaching you how to produce audio and video files — that requires a completely different skillset. We have provided you with sample audio and video files and example code for your own experimentation, in case you are unable to get hold of your own.,If you are unable to source any video or audio, then you can feel free to use our sample audio and video files to carry out this exercise. You can also use our sample code for reference.,Audio and Video manipulation: A LOT of detail about manipulating audio and video using JavaScript (for example adding filters.)

<video src="rabbit320.webm" controls>
   <p>Your browser doesn't support HTML5 video. Here is a <a href="rabbit320.webm">link to the video</a> instead.</p>
</video>
load more v
75%

You can further customize this embed code such as changing the video size by selecting the customization option given just below the embed-code input box.,The newly introduced HTML5 <video> element provides a standard way to embed video in web pages. However, the video element is relatively new, but it works in most of the modern web browsers.,This is the easiest and popular way to embed videos files in the web pages. Just upload the video on YouTube and insert HTML code to display that video in your web page.,A video, using the browser default set of controls, with alternative sources.

<video controls="controls" src="media/shuttle.mp4">
   Your browser does not support the HTML5 Video element.
</video>
load more v
40%

The H.264 codec in particular is ideal for compressing videos into a smaller file size for streaming without a negative impact on quality.,2) Actually, this can be fixed using a special class that Outlook.com applies to all emails. Check it out in the revisions above!,Thanks very much for the article and the list of supported email clients. ,*For the latest about client support for video in email, check out Can I Email.

Using <object> to embed video in email

 <!-- Embed a flash movie -->
 <object data="movie.swf"   type="application/x-shockwave-flash"></object>

 <!-- Embed a flash movie with parameters -->
 <object data="movie.swf" type="application/x-shockwave-flash">
      
    <param name="foo" value="bar">
 </object>
load more v
22%

Safari Technology Preview Release 126 is now available for download for macOS Big Sur and betas of macOS Monterey. If you already have Safari Technology Preview installed, you can update in the Software Update pane of System Preferences on macOS.,Safari Technology Preview Release 109 is now available for download for macOS Catalina. With this release, Safari Technology Preview is now available for betas of macOS Big Sur. If you already have Safari Technology Preview installed, you can update in the Software Update pane of System Preferences on macOS. Safari Technology Preview is currently only available for Intel-based Macs.,After updating to Safari Technology Preview Release 60, the homepage preference and the Develop menu preference will be lost.,Fixed an issue that could lead to large memory use in the Safari Technology Preview and web content processes when certain Safari Extensions are installed

Domain-bound codes. On macOS Big Sur, added support to Security Code AutoFill for domain-bound, one-time codes sent over SMS; in the following 2FA SMS, Safari only offers to fill the code on example.com, and no other domain.

Your Example code is 123446.

@example.com #123446

Other "duplicate-height" queries related to "How to get width and height of mp4 file in php code before playing them [duplicate]"