473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mjpeg stream

So, we have these video cameras at work, that use motion jpegs to send
images. I am able to get the feed into a c# application if I am given
a jpeg page where the image updates when I click refresh. However,
there are also mjpeg pages, that run a lot smoother, and my
understanding is that these are essentially the same thing as doing a
web request for the jpeg really quickly. I can't get these to load up
in my application the same way, however. I will post my code below,
any suggestions on how to either
A)receive the jpegs much faster(changing my timer doesn't help), or
B)just receive the mjpeg feed directly into the app

are greatly appreciated.

namespace StreamTest
{
public partial class Form1 : Form
{
HttpWebRequest wreq;
HttpWebResponse wresp;
Stream mystream;
Bitmap bmp;
Timer time = new Timer();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
time.Interval = 50;
time.Tick += new EventHandler(time_Tick);
pictureBox1.Image = LoadPicture("url");
time.Enabled = true;
}

void time_Tick(object sender, EventArgs e)
{
pictureBox1.Image = LoadPicture("url");
}

private Bitmap LoadPicture(string url)
{
HttpWebRequest wreq;
HttpWebResponse wresp;
Stream mystream;
Bitmap bmp;

bmp = null;
mystream = null;
wresp = null;
try
{
wreq = (HttpWebRequest)WebRequest.Create(url);
wreq.Credentials = new NetworkCredential("guest",
"guest");
wresp = (HttpWebResponse)wreq.GetResponse();

if ((mystream = wresp.GetResponseStream()) != null)
bmp = new Bitmap(mystream);
}
finally
{
if (mystream != null)
mystream.Close();

if (wresp != null)
wresp.Close();
}
return (bmp);

}

private void button1_Click(object sender, EventArgs e)
{
this.Close();
}

private void button1_Click_1(object sender, EventArgs e)
{
this.Close();
}

}
}

Jul 31 '06 #1
0 7195

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
26654
by: andrewcw | last post by:
OK I am half way there - I can manipulate the stream without the byte issue like this - but is this the way to push the new values back into the stream & write out the stream without resorting to...
5
2539
by: andrewcw | last post by:
I have an object to serialize. TextWriter writer = new StreamWriter("test.xml"); serializer.Serialize(writer,obj); writer.Close(); but below does not, why ?? I have a file that I will have...
3
15261
by: MJB | last post by:
I'm getting an IStream back from function xmlHttp.responsestream. I would like to convert this to a System.IO.Stream in order to work with it in my application. Has anyone encountered this and...
0
2098
by: Jay Douglas | last post by:
Hello all. I need to stream a mjpeg (http://localhost/sream.jpg) from a web cam to the browser using an asp.net application. I'm having a hard time finding any examples to help me code the page....
2
5224
by: Jay Douglas | last post by:
Hello all. I have an MJPEG on a remote web cam that I am able using the System.Net facilities in the FCL. However, I am having a hard time streaming the MJPEG to the browser. I'm trying to...
8
10388
by: Marc Gravell | last post by:
I want to write a method that will accept a stream as a parameter, and which will write xml to the stream (based in reality on database results) using the XmlTextWriter class. However, this insists...
3
3016
by: sven.suursoho | last post by:
Hello, In main(), the first output API is what I try to achieve. Unfortunately it fails, printing first string as pointer instead of human readable message. Tried to initialize str(""), set new...
0
1848
by: Jerry Spence1 | last post by:
What is the best way to view MJPEG images from an IP camera? I've tried using a web browser (.COM) and that sort of works OK, but I can't figure out how to resize the image to fit the browser (to...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.