$from = 'mymusic.mp3';
$samplefile = 'sample.mp3';
$size = 0.3;
$samplecontent = file_get_contents ($from);
$filesize = (int) (filesize ($from) * $size);
$handler = fopen ($samplefile,'w');
fwrite ($handler,$samplecontent,$filesize);
fclose ($handler);
If I did not make any mistakes, this should take the "mymusic.mp3" and create a copy called "sample.mp3" containing only the initial 30% (specified by $size).
If you also need to trim the beginning, then you can use a substr() on the $samplecontent var
If you need a fixed and not relative amount, like having 30 secounds for every song, then there's no choice other than to parse the MP3 file.