473,785 Members | 2,167 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()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
time.Interval = 50;
time.Tick += new EventHandler(ti me_Tick);
pictureBox1.Ima ge = LoadPicture("ur l");
time.Enabled = true;
}

void time_Tick(objec t sender, EventArgs e)
{
pictureBox1.Ima ge = LoadPicture("ur l");
}

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

bmp = null;
mystream = null;
wresp = null;
try
{
wreq = (HttpWebRequest )WebRequest.Cre ate(url);
wreq.Credential s = new NetworkCredenti al("guest",
"guest");
wresp = (HttpWebRespons e)wreq.GetRespo nse();

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

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

}

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

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

}
}

Jul 31 '06 #1
0 7241

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

Similar topics

1
26805
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 byte conversion ?? FileStream stream = null; stream = File.Open(fiPath, FileMode.Open, FileAccess.ReadWrite,FileShare.None); System.IO.StreamReader Tin = new System.IO.StreamReader (stream);
5
2555
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 exclusively opened & I use the stream for that operation. THANKS { I am tring to push the object back into the stream )
3
15325
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 written a conversion? TIA, Matt
0
2125
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. Any and all suggestions are welcome. Thanks in advance.
2
5237
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 figure out a way to basically keep the byte buffer flowing to the browser. Any resources or suggestions are welcome. Thanks in advance.
8
10466
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 on closing my stream, and I can't convince it not to. A much-simplified example is below; basically, as soon as the writer is disposed (marked **** below) the base stream gets closed - which is a pain if I was still using it ;-p The base...
3
3034
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 buffer etc, but nothing worked. Ideas? Also might use another internal construct, only API is needed and requirement to reuse existing std::ostream inserters.
0
1875
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 get rid of the scroll bars). Then I wondered about using a picturebox, but there are then complications about getting the image from the camera (which looks like a web) into it. Any help would be appreciated. -Jerry
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.