Dear all,
I stack to this problem about a week , I cant grab a snapshot from the
stream coming from red5 server.
Please help me to solve the problem , I surf the web but there is nothing
found close to this.
here is my AS3 code
private function playHitachiStream(event:MouseEvent):void{
servStream=new NetStream(red5Conn);
this.incoming.getDisplay().attachNetStream(servStream);
servStream.play("Ultrasound");
}
private function snapshotHandler(event:MouseEvent):void{
var bitmapData:BitmapData=new BitmapData(720,576);
var bitmap:Bitmap=new Bitmap(bitmapData);
bitmapData.draw(incoming.getDisplay());
var jpegEncoder:JPGEncoder=new JPGEncoder(75);
jpegBytes=jpegEncoder.encode(bitmapData);
red5Conn.call("createFile", responder,jpegBytes);
}
here is my java code (REd5)
public String createFile(ByteArray jpegByteArray){
String functionReturn="default return";
byte [] byteArray=new byte[jpegByteArray.length()];
jpegByteArray.readBytes(byteArray);
if(jpegByteArray.length()==0){
functionReturn="jpegByteArray is empty";
return functionReturn;
}if(byteArray.length==0){
functionReturn="byteArray is empty";
return functionReturn;
}else{
try{
ByteArrayInputStream byteArrayInputStream=new
ByteArrayInputStream(byteArray);
BufferedImage
bufferedImage=ImageIO.read(byteArrayInputStream);
String fileName="snapshot.jpg";
if(bufferedImage!=null){
ImageIO.write(bufferedImage,"JPEG",new File(fileName));
}else{
functionReturn="bufferedImage is null";
return functionReturn;
}
}catch (Exception e) {
functionReturn= e.getLocalizedMessage();
}
}
return functionReturn;
}
this code works perfectly with the web cam stream (web cam attached directly
to my video component)
Any help will be appreciated a lot , as I really need it .
Thank you all in advance , I will look forward to get something from you .
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org