Hi folks,
i have a DCS-5222L camera and am developing software in C# to control it.
I'm using httpwebrequest to catch pan, tilt and zoom.
I also implemented through the recording of the camera and save the file system in avi format.
My problem comes when I have to save the audio: I saw that among the cgi there is a command to save the stream:
var command = "http: //" + ip + "/audio/ACAS.cgi?profileid=1";
The method is the following:
try
{
var total = 0;
_stream = new MemoryStream();
var ip = Resources.IPCAM;
var command = "http://" + ip + "/audio/ACAS.cgi?profileid=1";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(command);
request.Credentials = new NetworkCredential(Resources.CAM_USER, Resources.CAM_PASSWORD);
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
var audioFile = @"C:\picture\" + "WAV" + DateTime.Now.ToString("ddMMyyyy_hhmmss.fff") + ".wav";
using (fs = File.Create(audioFile))
{
byte[] buffer = new byte[4096];
while (s.CanRead)
{
Array.Clear(buffer, 0, buffer.Length);
total += s.Read(buffer, 0, buffer.Length);
fs.Write(buffer, 0, buffer.Length);
_stream.WriteTo(fs);
//fs.Close();
//_stream.Close();
}
}
//response.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
I can't read the new wav file...it is generated but does not open...
have you ever tried to save streaming audio in a file?
kindly let me know.
Thank you and good day.
MM