|Subject:||Stream extraction and tag rendering|
|Cc:||pastorofmuppets [...] users.sf.net|
From Steve Sloan (pastorofmuppets at users.sf.net), moved to new RT system: In my current project, I want to read the ID3 tag from a file, store the info in a database, then strip-out the tag and store just the MPEG data in a file. To export a song from the database, I just spit-out the MPEG data and attach an ID3 tag (v1.1), rendered on-the-fly. These is difficult to implement without access to MP3::Info's internal data, so I propose adding two functions: (1) map_mp3data( $file, $function, $buffsize = 4096 ) This opens the file (or filehandle) passed and computes the start and end points of the MPEG stream (i.e. after the V2 tag and before the V1 tag). It then reads the data, $buffsize bytes at a time, and calls the function-reference $function, with the current buffer as $_. This would allow for easy processing of MPEG data (e.g. decoding/playing). (2) render_mp3tag( ... ) This function behaves the same as set_mp3tag(), except without the file argument, and instead of modifying the tag in the file, it renders the new tag (V1.1) and returns it in binary form. The grunt work for both of these functions is already present, only requiring some code rearrangement. E.g. set_mp3tag() would call render_mp3tag() to generate the tag, then write it to the file. remove_mp3tag() could call map_mp3data() in cases where a simple file truncate won't do (i.e. V2 tag present). I've attached my version of MP3::Info with these changes. They should probably be implemented a bit more cleanly, but in either case, I strongly urge you to add this functionality.
Message body is not shown because it is too large.