how to get audio info by remote files
-
- User
- Posts:5
- Joined:Thu Feb 21, 2008 6:26 pm
i want get audio info by remote files method,
however don't need to download audio file to my PC?
i'm using one simple class, to get mp3 bitrate , don't need download audio file, by remote files
however don't need to download audio file to my PC?
i'm using one simple class, to get mp3 bitrate , don't need download audio file, by remote files
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Depending on the file format you may need anywhere from a few bytes to the entire file to get accurate results. If you download (at least) the first 32kB of the file you should be OK for most MP3 files (although you will be missing all tags data from the end, like ID3v1, Lyrics3, APE) but if you only need bitrate for MP3s then that should be enough.
If you need code examples, search these forums for "remote" and you'll find plenty of threads with example code.
If you need code examples, search these forums for "remote" and you'll find plenty of threads with example code.
-
- getID3() v2 developer
- Posts:445
- Joined:Sun May 04, 2003 2:22 pm
- Location:Holmegaard, Denmark
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Sorry Allan, but that would give 32MiB ;)Allan Hansen wrote:$fp = fopen('http://myserver/myfile.flac');
$first32kb = fread($fp, 32*1024*1024);
fclose($fp);
Code: Select all
$fp = fopen('http://myserver/myfile.flac');
$first32kb = fread($fp, 32*1024);
fclose($fp);
-
- User
- Posts:5
- Joined:Thu Feb 21, 2008 6:26 pm
sorry, here's my code
and it's create one 6kb file :|
Code: Select all
$remotefilename = 'mylink,example';
$fp = fopen($remotefilename,'rb');
if ($fp2 = fopen('boo', 'wb')) {
$first32kb = fread($fp, 32*1024);
fwrite($fp2,$first32kb);
}
fclose($fp);
$ThisFileInfo = $getID3->analyze('boo');
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Filesize, obviously not. You can get the remote filesize with a function like this:rassen wrote:one more question, that's i can't get right playtime and filesize util download full file to my desktop :| ??!
Code: Select all
function filesize_remote($remotefile, $timeout=10) {
$size = false;
$url = parse_url($remotefile);
if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
while (!feof($fp)) {
$headerline = fgets($fp, 4096);
if (eregi('^Content-Length: (.*)', $headerline, $matches)) {
$size = intval($matches[1]);
break;
}
}
fclose ($fp);
}
return $size;
}
-
- User
- Posts:2
- Joined:Mon Jul 13, 2009 11:46 pm
- Are you a spambot?:no
Re: how to get audio info by remote files
Can I use this method for analyzing .flv/.swf files??
How much Kb should "read" from remote file?
How much Kb should "read" from remote file?
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: how to get audio info by remote files
Yes, this method should work for pretty much any file format (with the caution that the file may be flagged as corrupt and/or incorrect playtime/bitrate type values may be returned for those format that don't store this information in a header). For FLV/SWF you probably don't need much data, anywhere from 1kB to 32kB is probably fine, depending on the file. More is always better (in terms of returning accurate results) but you can probably be pretty safe with ~4kB most of the time.
-
- User
- Posts:1
- Joined:Thu Sep 17, 2009 6:53 pm
- Are you a spambot?:no
Re: how to get audio info by remote files
Can anyone tell me how to get the width and height of a remote flv file using an array instead of creating a file on the web server?
-
- User
- Posts:1
- Joined:Wed Jul 07, 2010 1:37 am
- Are you a spambot?:no
Re: how to get audio info by remote files
I have some vedio file on remote box in format: mp4/H.264/FFAC.
In order to get the following info :
Note that I have to obtain "GETID3_FREAD_BUFFER_SIZE * 300" of the file.
Is there any better way to fetch less bytes from remote url for MP4 VEDIO?
In order to get the following info :
resolution: 1280 x 720
time: 9701.695 sec time_string: 161:42
1310784729+4351741=1315136470 total bytes
bitrates: 1084Kbps
File parsed in 9.986 seconds.
Code: Select all
$tmpfname = tempnam("./", "mp4");
$buf = file_get_contents( $_REQUEST['filename'], false, null, 0, GETID3_FREAD_BUFFER_SIZE * 300);
file_put_contents( $tmpfname, $buf);
$info = $getID3->analyze( $tmpfname);
getid3_lib::CopyTagsToComments($info);
//echo table_var_dump($info);
//print_r( $info['quicktime']['vedio']);
echo $info['video']['resolution_x']." x ";
echo $info['video']['resolution_y']."<br>";
echo $info['playtime_seconds']." ";
echo $info['playtime_string']."<br>";
$filesize = $info['quicktime']['mdat']['size'] + $info['quicktime']['mdat']['offset'];
echo $info['quicktime']['mdat']['size']."+";
echo $info['quicktime']['mdat']['offset']."={$filesize}<br>";
echo round( $filesize * 8 / $info['playtime_seconds'] / 1000)."Kbps<br>";
Is there any better way to fetch less bytes from remote url for MP4 VEDIO?