Jose,
Did you get sound to work with this widget? I was looking at the Panasonic camera you have and it seems to do some magic using Active X for sound.
Thanks,
Howard
Hi Howard,
I worked on that for quite a while, but hit ta few major road blocks : 1) Flash Lite does not support sound streaming, and 2) g726 Audio is not supported on the Chumby. Duane looked at what it would take to get the audio format supported, but found that the format was poorly documented and decided that the chance of getting it to work work was slim.
I think there is a chance to get it working if we can add the support in BT. Even if bt supported the format, I would still have to figure out how to have something on the side "streaming" the audio. I wrote something in PHP to get "snipets" of audio (on g726), but not sophisticated enough for streaming. Here is the code:
<?php
$response = http_get("http://usr:pass@192.168.1.3/nphAudio?Mode=Mixed", array("timeout"=>20));
$parsed_msg = http_parse_message($response);
//print_r($parsed_msg);
$body_of_msg = $parsed_msg->body;
//echo "$body_of_msg";
$data = "";
// parse the body to remove all the information in between the boundaries
$chunks = explode("\r\n",$body_of_msg);
$i = 0;
foreach($chunks as $body_element) {
//echo "$i: $body_element\n";
$i++;
if( $i == 7 ) {
$i = 0;
$data = $data . $body_element;
}
//if(strlen($body_element) > 2) {
// if( (strrpos($body_element,"boundary" ) == false )&&
// (strrpos($body_element,"Control" ) == false )&&
// (strrpos($body_element,"Permission" ) == false )&&
//(strrpos($body_element,"Content" ) == false ) ) {
// $data_to_store = $data_to_store . $body_element;
//echo "DATA: $data\n";
//}
// }
//$data = '$data' . '$body_element';
}
//file_put_contents("test_audio.g721",$data);
file_put_contents("test_audio.g726",$data);
?>
I found a player on the web that can play g726 and verified that indeed the code does extract audio.
Here something else I wrote to get the video with audio. You can then create an mjpeg file. The file has all the info needed to play it like a movie:
<?php
$response = http_get("http://usr:pswd@192.168.1.10/nphVideo?Mode=0?Resolution=320x240?Quality=Standard", array("timeout"=>1));
$parsed_msg = http_parse_message($response);
//print_r($parsed_msg);
$body_of_msg = $parsed_msg->body;
// echo "BODY:$body_of_msg";
$audio = "";
$video = "";
// parse the body to remove all the information in between the boundaries
$v = 0; // audio is first
$new_string = $body_of_msg;
$pos = strpos($new_string,"myboundary"); // start of new data
//echo "POS: $pos\n";
while($pos) {
//echo "HERE 1\n";
$new_string = substr($new_string, $pos+10); // forward to the data
//echo "NEW STRING: " . substr($new_string, 0, 100);
$pos2 = strpos($new_string, "Content-length:"); // length of data
//echo "POS2: $pos2\n";
if($pos2) {
//echo "HERE 2\n";
$new_string = substr($new_string, $pos2+16); // go to start of bytes
// get number of bytes and extract the data
$i = 1;
$bytes = $new_string{0};
while($new_string{$i} != "\r" ) {
//echo "HERE 3\n";
$bytes = $bytes . $new_string{$i};
$i++;
}
//echo "BYTES: $bytes\n";
//echo "HERE 4\n";
$i = $i + 4; // skip \r\n\r\n
$data = substr($new_string, $i, $bytes); // get the data
//$new_string = substr($new_string, $i+$bytes); // fast forward the data; do we have to?
} else {
$bytes = 0;
}
if( $v == 1 ) { // video; set up for audio
$v = 0;
if( $bytes > 0 ) { // 0 data sometimes
$video = $video . $data;
}
} else { // audio; set up for video
$v = 1;
if( $bytes > 0 ) { // 0 data sometimes
$audio = $audio . $data;
}
}
$pos = strpos($new_string,"myboundary"); // start of new data
//echo "POS: $pos\n";
}
$data = $audio . $video;
file_put_contents("test_video.mjpg",$data);
?>
No streamng, though.
I think what needs to happen for the cam audio to work is this: 1) Flash Lite streaming must be supported (I hear this might happen soon), and 2) a stream must be created for the cam (maybe something that creates a g726 stream from the cam and converts it to a mp3 stream for Flash ?, or somehow support g726 streams directly(with bt?))
I am open to suggestions. Maybe my php code turns on a light bulb.
Regards,
Jose