Jump to content

Get Height and Width of Uploaded Video


Recommended Posts

I have a site where users can upload video to their posts. I then display this video using the <embed> tag.

[code]<embed src="video.wmv">[/code]

Any video format is allowed. The problem is that I don't know how to get the height and width of the video with PHP. Without defining height="x" and width="x", the video shows up very small. I don't want to use a static height and width in my embed tag. So how can I get the dimensions of a video with PHP, or what alternative is there to make the video show up in the page with the correct size?

[code]<embed src="video.wmv" height="???" width="???">[/code]
Link to comment
Share on other sites

Uhhh if height and width tags arent passed the actual height and width are used i think... So getting them isnt gonna do you any good unless you plan to double them or something... Lemme search google real quick...

http://chattyfig.figleaf.com/pipermail/flashcoders/2006-May/166365.html has something bout gettin the width and height of a flash file... Ill test it real qucik on a .wmv and see if it works...
Link to comment
Share on other sites

my example that does work from the database.

[code]


<?php

$video_query="SELECT * from members_video_uploads where id='$id'";
$video_result=mysql_query($video_query);

while($vid=mysql_fetch_assoc($video_result)) {
?>
<td  align="center"><b>members video</b><br><br>
<object
width="125" height="125" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="mediaplayer1">
<param name="filename" value="members_video/<?php echo $vid["userfile_name"];?>">
<param name="AutoStart" value="false">
<param name="ShowControls" value="true"><br>
<param name="ShowStatusBar" value="False">
<param name="ShowDisplay" value="false">
<param name="AutoRewind" value="True">

<embed type="application/x-mplayer2"
filename="kids.mpg" autostart="True"
showcontrols="True" showstatusbar="False"
showdisplay="False" autorewind="True">
</embed></object>


<?
}
if(mysql_num_rows($video_result)==0){
echo'
<td  align="center"><b>members video</b><br><br><img width="125" height="125" src="images/novid.png"></img>';
}

?>
[/code]

and this is correct example as well.

[code]

<ENBED src="video.wmv" HEIGHT=100 WIDTH=100>

[/code]
Link to comment
Share on other sites

[quote author=logged_with_bugmenot link=topic=103805.msg413611#msg413611 date=1155269175]
I have a site where users can upload video to their posts. I then display this video using the <embed> tag.

[code]<embed src="video.wmv">[/code]

Any video format is allowed. The problem is that I don't know how to get the height and width of the video with PHP. Without defining height="x" and width="x", the video shows up very small. I don't want to use a static height and width in my embed tag. So how can I get the dimensions of a video with PHP, or what alternative is there to make the video show up in the page with the correct size?

[code]<embed src="video.wmv" height="???" width="???">[/code]
[/quote]

It wasnt me asking the question.  I'm sorry if you misunderstood my 'ansaw'
Link to comment
Share on other sites

I know that you can use getimagesize() to get the dimensions of an image or flash file, but it doesn't work for videos. The reason I need to get the height and width of the video is because I want to allow the video to be up to 500 height and 500 width. If the dimensions are lower than that, I stick with them. If either the height or width goes above 500, then I choose new proportional dimensions to make it fit in the 500x500 space.

I tried removing the height and width properties of the embed tag and the video shows up as the correct size in IE. But in Firefox and Opera, it is very tiny and is not the correct size. How can I make Firefox and Opera use the right size automatically?
Link to comment
Share on other sites

Theyre all porportional so you could just have them all as x by y no matter what... It would look kinda wierd on some of em but youre site would end up lookin better anyways... Someone might think its funny to upload some 2000x2000 file... making the page its on look like crap...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.