getid3: download the full mp3 data from remote server

Gregory Schultz

I'm using getid3 to get the file size and the time duration from a remote URL. getid3 does not work with remote URLs so the work-around is to download the mp3 to a temporary location, read the data and then delete it.

Code:

<?php $filename = tempnam('/tmp','getid3');
if (file_put_contents($filename,file_get_contents('http://feeds.soundcloud.com/stream/336401044-scott-johnson-27-tms-1314-pm.mp3', false, null, 0, 32768))) {
if (require_once('id3/getid3.php')) {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
echo '<pre>'.print_r($ThisFileInfo, true).'</pre>';
}
unlink($filename);
};?>

My problem I have is that it only downloads the first 32768kb of the mp3 file and it doesn't show the correct filesize (shows as the max 32768) or the correct time duration of the file. If I increase the max size, the code will crash.

Is there a way to download either the full mp3 or find a way to get the appropriate header size without download the full file?

Brad

ID3v1 tags are at the end of the file, not at the beginning. Therefore, you won't be able to read them until you either download a chunk of the end of the file (with range requests done with cURL), or download the entire file.

If you want ID3v2, those will be at the beginning of the file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get duration of remote MP3 file without full download

From Android

How to download a part of mp3 from server?

From Dev

Download mp3 files from webpage

From Dev

Transferring mp3 files from a remote server via cronjob to the RPi without overwriting

From Dev

Is it possible to get the download file name of an mp3 from server using bash?

From Dev

PHP Curl mp3 download reseting meta data

From Dev

PHP Get metadata of remote .mp3 file (from URL)

From Dev

Downloading Mp3 file from remote. Node js

From Dev

extract cover art from remote mp3

From Dev

Download multiple mp3's from a website

From Dev

Download and play mp3 file from URL

From Dev

ios - download only few seconds from mp3 file

From Dev

Download and play .mp3 file from firebase storage to memory

From Dev

Download mp3 file

From Dev

Swift 3: stream MP3 file from server

From Dev

Laravel getID3 unable to pull file from S3

From Dev

Audio mp3 stream from static server NGINX

From Dev

Downloading .mp3 file from the server and load in MediaPlayer

From Java

How to get audio data from a MP3?

From Dev

Extract Image artwork from MP3 audio data as PNG

From Dev

How to interpret raw pcm data from an MP3 file

From Dev

How do I play the sound of an mp3 file downloaded from the server - I am new to using streamed data

From Dev

Display image in browser with getID3

From Dev

getId3 to get video duration in seconds

From Dev

Stream a local mp3 file to a remote UPnP-client without a UPnP-server

From Dev

Xcode: Download mp3 file

From Dev

Download mp3 dynamically by javascript / jquery

From Dev

django play/download mp3 file

From Dev

How to download mpeg/mp3 with Python?

Related Related

HotTag

Archive