Remote (HTTP) MP3 data (duration etc)

The place for "I can't figure out how to..." questions.
Post Reply
djdeant
User
Posts: 2
Joined: Sun Aug 02, 2015 9:26 pm
Are you a spambot?: no

Remote (HTTP) MP3 data (duration etc)

Post by djdeant » Sun Aug 02, 2015 9:36 pm

Hi there :)

I really like getID3, its fantastic! However, while it works great for files local to you, it does not work too well for remote files.
What I tried to do to get this to work is to remove the "file_exists" part (as it won't know for URL files), and now I get this error:

Warning: fseek(): stream does not support seeking in /getID3-1.9.9/getid3/getid3.php on line 1703

So, I already know that fseek isn't supported for streams, but from what I can tell, this function is only reading the first few bytes of a file? I might be wrong in that assumption, as there is many many lines of code...

All I'm trying to do is get the duration of a few MP3 files. I'm wondering if there is a way to do it with getID3, or perhaps this isn't possible?

Thanks for any help!

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

Re: Remote (HTTP) MP3 data (duration etc)

Post by James Heinrich » Sun Aug 02, 2015 9:56 pm

Full remote processing isn't possible with getID3. It's left to the user to copy the target file (in entirety or perhaps only partially) locally for analysis. Some file formats will analyse perfectly well with only the first few kB, others may need more data to analyse correctly. With MP3 specifically the required data is mostly at the beginning (except for ID3v3, APE, and Lyrics3 which are all at the end of the file), but if the file does not have a very specific header (which only some encoders use) then the playtime is calculated from the average bitrate and the overall filesize, so if you only have a small part of the total file then the playtime will be off. However, there is the optional second parameter to getID3->analyze() where you can pass the original filesize to fix that particular miscalculation.

There is some more remote-copy sample code here:
viewtopic.php?t=1605

djdeant
User
Posts: 2
Joined: Sun Aug 02, 2015 9:26 pm
Are you a spambot?: no

Re: Remote (HTTP) MP3 data (duration etc)

Post by djdeant » Mon Aug 03, 2015 5:52 pm

Thanks, that quite helpful - although it won't fix my problem.
I'll contact our CDN and point them in the direction of this post and see if they can do anything on their server - perhaps they could use getID3 locally, and we could call it through an API of some description.
We'll see...

Post Reply