ARudik / php-reader

Automatically exported from code.google.com/p/php-reader
0 stars 0 forks source link

Support for reading and writing Ogg Vorbis format #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Enhancement: Support for reading and writing Ogg Vorbis format.

Original issue reported on code.google.com by Super.Ti...@gmail.com on 1 Aug 2008 at 9:30

GoogleCodeExporter commented 9 years ago

Original comment by svollbehr on 9 Aug 2008 at 4:26

GoogleCodeExporter commented 9 years ago

Original comment by svollbehr on 4 May 2011 at 6:58

GoogleCodeExporter commented 9 years ago
I had a lot of fun creating this set of classes I must say. The first version 
of the implementation is now committed to subversion. This version can only 
read information. The implementation differs significantly from the other 
classes of the series.

First of all this implementation was actually for two formats. There is the Ogg 
format, which is a rather boring format encapsulating other formats. Then there 
is the actual format that we are interested in, or the Vorbis format that 
contains the comment header.

Due to the fact that Ogg is simply encapsulating Vorbis, I have impelemented 
support for Ogg decoding in form of a reader class. One can read data contained 
in Ogg simply by reading from the Ogg reader:

$ogg = new Zend_Media_Ogg_Reader(<filename>)
$ogg->read(<bytes>);

OK, so that was quite simple to use. I've then created another class to decode 
only the Vorbis format from a file, stream, or a Zend_Io_Reader object. One can 
then read Vorbis format from an Ogg encapsulation simply by using them both 
together:

$vorbis = new Zend_Media_Vorbis(new Zend_Media_Ogg_Reader(<filename>));

Cool huh? So quick example on using the classes before I get the chance to do a 
proper wiki page for them:

$vorbisComment = $vorbis->commentHeader;

echo "Artist: $vorbisComment->artist\n";
echo "All comments: " . print_r($vorbisComment->getComments(), true);

Original comment by svollbehr on 14 May 2011 at 4:20

GoogleCodeExporter commented 9 years ago
Vorbis comments can now furthermore be read from FLAC bitstream as well. Quick 
sample code follows.

Display metadata block information:
$flac = new Zend_Media_Flac('sample.flac');
print_r($flac->metadataBlocks);

Display image:
$flac = new Zend_Media_Flac('sample.flac');
header('Content-Type: ' . $flac->picture->mimeType);
echo $flac->picture->data;

Display comments:
$flac = new Zend_Media_Flac('sample.flac');
foreach ($flac->vorbisComment->comments as $name => $value) {
    echo "NAME: $name, VALUES: " . implode($value, ", ") . "\n";
}

Flac class uses the same VorbisComments implementation as does the Vorbis class.

Original comment by svollbehr on 11 Jun 2011 at 4:53

GoogleCodeExporter commented 9 years ago
Oh yeah, the previous example works for Flac class as well.

$flac = new Zend_Media_Flac('sample.flac');
echo "Artist: $flac->vorbisComment->artist\n";
echo "All comments: " . print_r($flac->vorbisComment->getComments(), true);

Original comment by svollbehr on 11 Jun 2011 at 4:55

GoogleCodeExporter commented 9 years ago
Hello Sven,
do you think FLAC writing will be possible soon?
Thanks again for this wonderful library!
Georg

Original comment by dietzlge...@gmail.com on 30 May 2012 at 4:52

GoogleCodeExporter commented 9 years ago
Let me see what I can do.

Original comment by svollbehr on 2 Jun 2012 at 3:41