Jump to content


Photo

Get Height and Width of Uploaded Video


  • Please log in to reply
10 replies to this topic

#1 logged_with_bugmenot

logged_with_bugmenot
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 11 August 2006 - 04:06 AM

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

<embed src="video.wmv">

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?

<embed src="video.wmv" height="???" width="???">

Earn money with Google AdSense

#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 11 August 2006 - 06:20 AM

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.fig...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...
Why doesn't anyone ever say hi, hey, or whad up world?

#3 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 11 August 2006 - 06:23 AM

Wow, hmmm so that doesnt even work for flash... lol... google failed me!!!!! no!!!!!!!!!!!!!!!!!!!!!!!!!
Why doesn't anyone ever say hi, hey, or whad up world?

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 August 2006 - 07:13 AM

my example that does work from the database.



<?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>';
}

?>

and this is correct example as well.


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


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 11 August 2006 - 08:33 AM

I dont think hes having an issue with that aspect of it... I think hes having trouble cuz he needs to know the width and height of the file...
Why doesn't anyone ever say hi, hey, or whad up world?

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 August 2006 - 08:38 AM

how can anyone no the width and height of the video file you set the width and height.


i understand if the user wanted filesize but not your ansaw corbin
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 11 August 2006 - 08:45 AM

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

<embed src="video.wmv">

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?

<embed src="video.wmv" height="???" width="???">


It wasnt me asking the question.  I'm sorry if you misunderstood my 'ansaw'
Why doesn't anyone ever say hi, hey, or whad up world?

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 August 2006 - 08:50 AM

Theres no other way else using static height= and width=.

sorry corbin silly quistion sorry mate.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 logged_with_bugmenot

logged_with_bugmenot
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 11 August 2006 - 05:17 PM

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?
Earn money with Google AdSense

#10 logged_with_bugmenot

logged_with_bugmenot
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 11 August 2006 - 05:27 PM

Here is an image explaining the problem with the sizes http://img65.imagesh...deosizespe7.png

[attachment deleted by admin]
Earn money with Google AdSense

#11 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 11 August 2006 - 05:30 PM

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...
Why doesn't anyone ever say hi, hey, or whad up world?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users