I'm trying to extract MP3 ID3 Tag information from any remotely hosted mp3 file via PHP.
I've tried several times with fread and fseek to grab the last 128bytes of the file and extract the tag information...but had no success.
Here's and example of what I want to do:
http://www.digitalcoding.com/tools/read-remote-mp3-avi-file-id3-information.html
Any tips or code snippets would be appreciated :)
With HTTP you'd download a range of data from the resource. You can pick an arbitrary range and it can even consist of multiple parts like "X-Y" or "X-Y,A-B" etc.
Servers however don't always support that and then you'll be served the full file instead.
When using something like curl, you can use its CURLOPT_RANGE option (or the command line tool's -r).
Related
This is going to sound like an odd request.
I have a PHP script pulling a mp3 stream from SoundCloud and repeating the stream with the correct headers to allow WinAmp to play the file. But it only shows the local url I have the script running from. Before anyone asks, I am injecting ID3v1 into the file before echoing it.
Is there any way to provide WinAmp with the meta data from php?
Just to clarify, you are effectively proxying an MP3 file from SoundCloud, and you want to embed metadata into it?
Winamp will pick up ID3 tags in an HTTP-served MP3 file. However, if you are using ID3v1, those tags don't exist until the very end of the file. If you want the file to be identified without having to download the whole file, you must use ID3v2 which are typically located at the beginning of the file. (I actually recommend using both ID3v1 and ID3v2 for broader player compatibility, but almost everything supports ID3v2, so it is your choice.)
Now, there is another method but if you use this method the metadata won't be saved in the file when downloaded. You can use SHOUTcast-style metadata. Basically, Winamp and other clients (like VLC) send a request header, Icy-MetaData: 1. This tells the server that it supports SHOUTcast-style metadata. In your server response, you would insert metadata every 8KB or so. Basically, you want the reverse of what I have detailed here: https://stackoverflow.com/a/4914538/362536
In the end, simply adding ID3v2 tags will solve your problem in the best way, but I wanted to mention the alternative option in case you needed it for something else.
I have uploaded the doc files in my server and now i have to show the content of doc files in web page. Now i am not getting any way to show that content as doc may contain images, tables, and other type of texts.
I tried to work with file_get_contents and then using headers but not possible in all ways.
Firstly, .doc/.docx file is not a text file. I don't think with file_get_contents you shall get any normal text character as output.
You can do two things:
Convert the doc/docx to pdf and show in your web page [Try: OfficeToPdf]
Convert the doc/docx to html compatible format using library [Try: PhpWord]
Links
PhpWord: http://phpword.codeplex.com/
OfficeToPdf: http://officetopdf.codeplex.com/
The libraries I mentioned are for example, there are a plenty of libraries available for free. Just Google to get them. Good luck :)
Docx is a zipped file format, so you can't get any information with file_get_contents.
Doc is not zipped, so you will directly get all information in XML format when opening with file_get_contents.
If you want to convert the files for a webviewing, you could use one of the libraries mentioned by #programmer
PhpWord: http://phpword.codeplex.com/
OfficeToPdf: http://officetopdf.codeplex.com/
I'm using the Google Text-to-Speech to make a game, but the TTS have a limit of 100 characteres per request. So, I split the text, and I do more than one request to synthesize the complete text.
Now, I have the binary of sound of my text split in two files.
Just doing a simple
$audio1 .= $audio2
doesn't work.
The file type is MPEG, so it's not the same as MP3.
I think I need to clear the headers of the second file, but I dont know how to.
I made a test using your URL, it generates MP3 files, after a lookup on Google it could be done:
https://www.dropbox.com/sh/iwbzqdvsxymytgu/c2SaOVjcHY (Hosted on Dropbox for Audio files)
There is a FFmpeg tool to process media files, example concat two files
I want to give users a preview of certain files on my site and will be using scribd API. Does anyone know how I can access the full file from my server and save the file under a different name , which I will then show to users..Can't think of a way to do this with PHP for .docx and image files...Help is much appreciated.
For "splitting" images, use an image processing library like gd to crop the image (lots of examples to be found on how to do that all over the place). For Word documents, use a library like PHPWord (or one of the other myriad such libraries) to open the document, remove/extract as much text as you need, then save that into a new Word file.
For other file types, find the appropriate method that allows you to manipulate that format, then do whatever you need to do with it.
I need to merge two flv files, using PHP. I can't use exec method. I am wondering if is possible to cut some part of one flv file (audio tag) and paste to another and overwrite duration for output file.
I have found interesting solution here: calculate flv video file length ? using pure php but I do not know how can I get an audio tag from a flv file? How many audio tags a flv file has? Which tags should I overwrite in output file to be able to play audio from two merged files?
I will be very gratefull for advices.
Many thanks,
Piotr
I strongly recommend you to go to http://www.adobe.com/devnet/f4v.html and download the FLV/F4V specification made freely available by Adobe.
Using the techniques I described in my answer you linked at, you should be able to achieve your goal.
Be careful however when trying to join files with different codecs, since the resulting file has good chances to confuse the flash player, or even not playing at all past the junction point.
Otherwise, I don't really understand your goal.
If you plan to put a file's audio track into another file, I would really discourage you from doing it in PHP, but instead using video tools such as ffmpeg.
If you're stuck with PHP, you should probably read both files concurrently, synchronizing via each tag's timestamp, reading the first file's video, and the second file's audio, combining tags by temporal order into a third new file.