|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-04-26 06:13 UTC] gerlach-rainer at gmx dot de
I write a little application that converts u-law
sound files on the fly to wave and sends the out-
put to the browser (IE6 on Windows XP). I use
mod_php4 on Apache/1.3.12 (Unix).
example script (lines splitted at _ for better readability):
<?PHP
if (isset($_GET['call'])) {
header("Content-type: audio/x-wav");
passthru( _
"cat /var/isdn/" . $_GET['call'] . " | _
/usr/sbin/g711conv -a | _
/usr/local/bin/sox -t ul - -t wav -");
}
?>
The file is played, but at the end the voice output is choppy
and the media player reports an "unsupported format" error.
I have tested the command line on the remote machine and get a
file that is correctly played by media player.
I downloaded the file with IE 6 and compared it with the original
file, created on the remote machine. They have exact the length and
almost the same content, but have little differences at the beginning.
Here is the beginning of each file:
orig:
00000000 5249 4646 2478 0100 5741 5645 666d 7420 RIFF$x..WAVEfmt
00000010 1000 0000 0700 0100 401f 0000 401f 0000 ........@...@...
00000020 0100 0800 6461 7461 0078 0100 f1fd 79f7 ....data.x..q}yw
after passthru:
00000000 5249 4646 ffff ff7f 5741 5645 666d 7420 RIFF....WAVEfmt
00000010 1000 0000 0700 0100 401f 0000 401f 0000 ........@...@...
00000020 0100 0800 6461 7461 dbff ff7f f1fd 79f7 ....data[...q}yw
I also tested to download the file with
- wget from cygwin -> wrong
- wget from the same machine as the webserver -> wrong
this works:
<?PHP
if (isset($_GET['call'])) {
header("Content-type: audio/x-wav");
exec(_
"cat /var/isdn/" . $_GET['call'] . " | _
/usr/sbin/g711conv -a | _
/usr/local/bin/sox -t ul - -t wav /tmp/call.wav");
$fd=fopen ("/tmp/call.wav", "r");
fpassthru($fd);
}
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 21 16:00:01 2025 UTC |
I write a little application that converts u-law sound files on the fly to wave and sends the out- put to the browser (IE6 on Windows XP). I use mod_php4 on Apache/1.3.12 (Unix). example script (lines splitted at _ for better readability): <?PHP if (isset($_GET['call'])) { header("Content-type: audio/x-wav"); passthru( _ "cat /var/isdn/" . $_GET['call'] . " | _ /usr/sbin/g711conv -a | _ /usr/local/bin/sox -t ul - -t wav -"); } ?> The file is played, but at the end the voice output is choppy and the media player reports an "unsupported format" error. I have tested the command line on the remote machine and get a file that is correctly played by media player. I saved the link target and compared the result with the original file, created on the remote machine. They have exact the same length and almost the same content, but have little differences at the beginning. Here is the beginning of each file: orig: 00000000 5249 4646 2478 0100 5741 5645 666d 7420 RIFF$x..WAVEfmt 00000010 1000 0000 0700 0100 401f 0000 401f 0000 ........@...@... 00000020 0100 0800 6461 7461 0078 0100 f1fd 79f7 ....data.x..q}yw after passthru: 00000000 5249 4646 ffff ff7f 5741 5645 666d 7420 RIFF....WAVEfmt 00000010 1000 0000 0700 0100 401f 0000 401f 0000 ........@...@... 00000020 0100 0800 6461 7461 dbff ff7f f1fd 79f7 ....data[...q}yw I also tested to download the file with - wget from cygwin -> wrong - wget from the same machine as the webserver -> wrong this works: <?PHP if (isset($_GET['call'])) { header("Content-type: audio/x-wav"); exec(_ "cat /var/isdn/" . $_GET['call'] . " | _ /usr/sbin/g711conv -a | _ /usr/local/bin/sox -t ul - -t wav /tmp/call.wav"); $fd=fopen ("/tmp/call.wav", "r"); fpassthru($fd); } ?>It may be the webserver doing the data manipulation, try explicitly setting the content encoding: header('Content-encoding: 8bit'); header('Content-transfer-encoding: 8bit');