Getting duration of video/audio file problem

The place for "I can't figure out how to..." questions.
Post Reply
eawedat
User
Posts: 3
Joined: Tue Oct 23, 2012 8:48 am
Are you a spambot?: no

Getting duration of video/audio file problem

Post by eawedat » Tue Oct 23, 2012 8:56 am

hey all
I have downloaded getID3 version 1.9.3

using this code below does not really give me the duration of file,

Code: Select all

<?php
include("getid3/getid3.php");
$filename="aa.flv";
$getID3 = new getID3;
$file = $getID3->analyze($filename);
echo $file['playtime_string'];
?>

what's the reason for that?

thanks.

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Getting duration of video/audio file problem

Post by James Heinrich » Tue Oct 23, 2012 11:01 am

Does "not really" mean you get a duration, but it's inaccurate? If so, please submit a sample file to info@getid3.org
Is anything returned in $file['warning'] and/or $file['error'] ?

eawedat
User
Posts: 3
Joined: Tue Oct 23, 2012 8:48 am
Are you a spambot?: no

Re: Getting duration of video/audio file problem

Post by eawedat » Tue Oct 23, 2012 11:12 am

I get an empty blank page ->Get nothing-> a clean page-> white page

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Getting duration of video/audio file problem

Post by James Heinrich » Tue Oct 23, 2012 12:17 pm

Try this:

Code: Select all

require_once('getid3/getid3.php');
$filename = 'aa.flv';
$getID3 = new getID3;
$file = $getID3->analyze($filename);
echo '<pre>'.htmlentities(print_r($file, true)).'</pre>';
You can also try opening demo/demo.browse.php in your web browser and browse to the file in question to confirm that getID3 is analyzing the file correctly.

eawedat
User
Posts: 3
Joined: Tue Oct 23, 2012 8:48 am
Are you a spambot?: no

Re: Getting duration of video/audio file problem

Post by eawedat » Tue Oct 23, 2012 12:43 pm

thank you very much,that worked for me now, there were few modules missing.

if i want to get filesize in megabytes not in bytes so I should divide it by 10^6 right ?

Code: Select all

 $file[filesize]/1000000

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Getting duration of video/audio file problem

Post by James Heinrich » Tue Oct 23, 2012 12:55 pm

eawedat wrote:if i want to get filesize in megabytes not in bytes so I should divide it by 10^6 right ?

Code: Select all

 $file[filesize]/1000000
No, you should divide it by 2^20 = 1048576 to get megabytes (as displayed by any operating system; more correctly called "mebibyte": http://en.wikipedia.org/wiki/Mebibyte )
Similarly, use 2^10 = 1024 as the divisor for bytes->kilobytes; 2^20 = 1048576 for bytes->megabytes; 2^30 = 1073741824 for bytes->gigabytes, etc.

On the other hand, if you want to display bitrate in kbps or mbps then you would divide it by 10^3 or 10^6.

Post Reply