I am having live url="http/ip:port/live.mp4?channel=0&type=0" Basically i want to get the live video stream(HTTP GET of live url) and display it in picture box. Program Blocks when i convert Stream to Bitmap.
String url = String.Format("http://{0}/live.mp4?channel={1}&type={2}", ipAddress, channel, type);
Console.WriteLine(url);
int read, total = 0;
// Bitmap bmp = null;
Uri uri = new Uri(url);
var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
var credentialCache = new CredentialCache();
credentialCache.Add(
new Uri(uri.GetLeftPart(UriPartial.Authority)), // request url's host
"Digest", // authentication type
new NetworkCredential(nvtUserName, nvtPassword) // credentials
);
httpWebRequest.Credentials = credentialCache;
// httpWebRequest.ContentType = "video/mp4";
httpWebRequest.Method = "GET";
httpWebRequest.Headers.Add("cookie", cookie);
httpWebRequest.Headers.Add("X-csrftoken", strcsrftoken);
//httpWebRequest.UserAgent = "spider/1.0";
httpWebRequest.Method = "GET";
Console.WriteLine(cookie);
Console.WriteLine(strcsrftoken);
var webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Console.WriteLine("Status code={0}", (int)webResponse.StatusCode);
//var stream = webResponse.GetResponseStream();
// bmp = (Bitmap)Bitmap.FromStream(stream);
Stream output = new MemoryStream();
using (Stream input = webResponse.GetResponseStream())
{
p.Image = Bitmap.FromStream(input);
}