Пример 2. Encode an audio file to OGG/Vorbis
<?php dl('oggvorbis.so');
$context = stream_context_create(array('ogg'=>array( 'pcm_mode' => OGGVORBIS_PCM_S8, /* Signed 8bit audio */ 'rate' => 44100, /* 44kHz CD quality */ 'bitrate' => 0.5, /* Midquality VBR */ 'channels' => 1, /* Mono */ 'serialno' => 12345))); /* Unique within our stream */
/* Open file for appending. This will "chain" a second OGG stream at the end of the first. */ $ogg = fopen('ogg://mysong.ogg', 'a', false, $context);
$pcm = fopen('mysample.pcm', 'r');
/* Compress the raw PCM audio from mysample.pcm into mysong.ogg */ stream_copy_to_stream($pcm, $ogg);
fclose($pcm); fclose($ogg); ?>
|
|