<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Capture Video from ip camera using JMF</title>
	<atom:link href="http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/</link>
	<description>News, articles, software, teaching content, programming the development of Internet resources</description>
	<lastBuildDate>Wed, 01 Feb 2012 17:29:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: CAM_IP</title>
		<link>http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/comment-page-1/#comment-9191</link>
		<dc:creator>CAM_IP</dc:creator>
		<pubDate>Wed, 01 Feb 2012 17:29:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.950buy.com/?p=108#comment-9191</guid>
		<description>SVP j&#039;ai travaille avec Dlink DCS-920,j utilise le même code mai sa marche pas malgré que le vidéo est accessible a part via l&#039;@: &quot;http://ip_camera/MJPEG.CGI&quot;

N&#039;hesite pas à m&#039;aider svp c urgent.

Merci d&#039;avance.</description>
		<content:encoded><![CDATA[<p>SVP j&#8217;ai travaille avec Dlink DCS-920,j utilise le même code mai sa marche pas malgré que le vidéo est accessible a part via l&#8217;@: &#8220;http://ip_camera/MJPEG.CGI&#8221;</p>
<p>N&#8217;hesite pas à m&#8217;aider svp c urgent.</p>
<p>Merci d&#8217;avance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JarJar</title>
		<link>http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/comment-page-1/#comment-2273</link>
		<dc:creator>JarJar</dc:creator>
		<pubDate>Tue, 21 Jun 2011 11:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.950buy.com/?p=108#comment-2273</guid>
		<description>Very helping code
Thank you</description>
		<content:encoded><![CDATA[<p>Very helping code<br />
Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamlesh Dhakad</title>
		<link>http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/comment-page-1/#comment-1473</link>
		<dc:creator>Kamlesh Dhakad</dc:creator>
		<pubDate>Thu, 07 Apr 2011 10:09:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.950buy.com/?p=108#comment-1473</guid>
		<description>Very nice and helping code. thanks..</description>
		<content:encoded><![CDATA[<p>Very nice and helping code. thanks..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phong Dinh</title>
		<link>http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/comment-page-1/#comment-1116</link>
		<dc:creator>Phong Dinh</dc:creator>
		<pubDate>Tue, 11 Jan 2011 07:11:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.950buy.com/?p=108#comment-1116</guid>
		<description>Hi Java people,
I rewrite the above code as the following code, It work well on Applet Viewer of Eclipse but doesn&#039;t work on browser. Any body can help me to embed into browser. Thank you so much. Here is my code:

import java.applet.Applet;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;

/**
*
* @author David E. Mireles, Ph.D.
*/
public class LiveDemo extends Applet implements Runnable {
	/**
	* 
	*/
	private static final long serialVersionUID = 1L;
	public boolean useMJPGStream = false;//true;
	public String jpgURL=&quot;http://10.0.0.81/axis-cgi/jpg/image.cgi?resolution=1024x768&quot;;
	public String mjpgURL=&quot;http://10.0.0.81/axis-cgi/jpg/image.cgi?resolution=1024x768&quot;;
	DataInputStream dis;
	private Image image = null;
	public Dimension imageSize = null;
	public boolean connected = false;
	private boolean initCompleted = false;
	HttpURLConnection huc = null;
	Component parent;
	
	/** Creates a new instance of Ax52Camera */
	public void init()
	{
		new Thread(this).start();
	}
	
	public void connect(){
		try{
			URL u = new URL(useMJPGStream?mjpgURL:jpgURL);
			huc = (HttpURLConnection)u.openConnection();			
			
			System.out.println(huc.getContentType());
			InputStream is = huc.getInputStream();
			System.out.println(is.toString());
			connected = true;
			BufferedInputStream bis = new BufferedInputStream(is);
			dis= new DataInputStream(bis);
			if (!initCompleted) initDisplay();
		}catch(IOException e){ //incase no connection exists wait and try again, instead of printing the error
			try{
				huc.disconnect();
				Thread.sleep(33);
			}catch(InterruptedException ie){huc.disconnect();connect();}
			connect();
		}catch(Exception e){;}
	}
	
	public void initDisplay(){ //setup the display
		if (useMJPGStream)readMJPGStream();
		else {readJPG();disconnect();}
		imageSize = new Dimension(image.getWidth(this), image.getHeight(this));
		setPreferredSize(imageSize);
		this.setSize(imageSize);
		this.validate();
		initCompleted = true;
	}
	
	public void disconnect(){
		try{
			if(connected){
				dis.close();
				connected = false;
			}
		}catch(Exception e){;}
	}
	
	public void paint(Graphics g) { //used to set the image on the panel					
		if (image != null)
			g.drawImage(image, 0, 0, this);
	}
	
	public void readStream(){ //the basic method to continuously read the stream
		try{
			if (useMJPGStream){
				while(true){
					readMJPGStream();
					this.repaint();
				}
			}
			else{
				while(true){
					connect();
					readJPG();
					this.repaint();
					disconnect();
				}
			}
	
		}catch(Exception e){;}
	}
	
	
	public void readMJPGStream(){ //preprocess the mjpg stream to remove the mjpg encapsulation
		readLine(3,dis); //discard the first 3 lines
		readJPG();
		readLine(2,dis); //discard the last two lines
	}
	
	public void readJPG(){ //read the embedded jpeg image
		try{
			JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis);
			image = decoder.decodeAsBufferedImage();
		}catch(Exception e){e.printStackTrace();disconnect();}
	}
	
	public void readLine(int n, DataInputStream dis){ //used to strip out the header lines
		for (int i=0; i&lt;n;i++){
		readLine(dis);
		}
	}
	public void readLine(DataInputStream dis){
		try{
			boolean end = false;
			String lineEnd = &quot;\n&quot;; //assumes that the end of the line is marked with this
			byte[] lineEndBytes = lineEnd.getBytes();
			byte[] byteBuf = new byte[lineEndBytes.length];
			
			while(!end){
				dis.read(byteBuf,0,lineEndBytes.length);
				String t = new String(byteBuf);
				//System.out.print(t); //uncomment if you want to see what the lines actually look like
				if(t.equals(lineEnd)) end=true;
			}
		}catch(Exception e){e.printStackTrace();}
	
	}
	public void run() {
		connect();
		readStream();
	}
	
}</description>
		<content:encoded><![CDATA[<p>Hi Java people,<br />
I rewrite the above code as the following code, It work well on Applet Viewer of Eclipse but doesn&#8217;t work on browser. Any body can help me to embed into browser. Thank you so much. Here is my code:</p>
<p>import java.applet.Applet;<br />
import java.awt.Component;<br />
import java.awt.Dimension;<br />
import java.awt.Graphics;<br />
import java.awt.Image;<br />
import java.io.BufferedInputStream;<br />
import java.io.DataInputStream;<br />
import java.io.IOException;<br />
import java.io.InputStream;<br />
import java.net.HttpURLConnection;<br />
import java.net.URL;</p>
<p>import com.sun.image.codec.jpeg.JPEGCodec;<br />
import com.sun.image.codec.jpeg.JPEGImageDecoder;</p>
<p>/**<br />
*<br />
* @author David E. Mireles, Ph.D.<br />
*/<br />
public class LiveDemo extends Applet implements Runnable {<br />
	/**<br />
	*<br />
	*/<br />
	private static final long serialVersionUID = 1L;<br />
	public boolean useMJPGStream = false;//true;<br />
	public String jpgURL=&#8221;http://10.0.0.81/axis-cgi/jpg/image.cgi?resolution=1024&#215;768&#8243;;<br />
	public String mjpgURL=&#8221;http://10.0.0.81/axis-cgi/jpg/image.cgi?resolution=1024&#215;768&#8243;;<br />
	DataInputStream dis;<br />
	private Image image = null;<br />
	public Dimension imageSize = null;<br />
	public boolean connected = false;<br />
	private boolean initCompleted = false;<br />
	HttpURLConnection huc = null;<br />
	Component parent;</p>
<p>	/** Creates a new instance of Ax52Camera */<br />
	public void init()<br />
	{<br />
		new Thread(this).start();<br />
	}</p>
<p>	public void connect(){<br />
		try{<br />
			URL u = new URL(useMJPGStream?mjpgURL:jpgURL);<br />
			huc = (HttpURLConnection)u.openConnection();			</p>
<p>			System.out.println(huc.getContentType());<br />
			InputStream is = huc.getInputStream();<br />
			System.out.println(is.toString());<br />
			connected = true;<br />
			BufferedInputStream bis = new BufferedInputStream(is);<br />
			dis= new DataInputStream(bis);<br />
			if (!initCompleted) initDisplay();<br />
		}catch(IOException e){ //incase no connection exists wait and try again, instead of printing the error<br />
			try{<br />
				huc.disconnect();<br />
				Thread.sleep(33);<br />
			}catch(InterruptedException ie){huc.disconnect();connect();}<br />
			connect();<br />
		}catch(Exception e){;}<br />
	}</p>
<p>	public void initDisplay(){ //setup the display<br />
		if (useMJPGStream)readMJPGStream();<br />
		else {readJPG();disconnect();}<br />
		imageSize = new Dimension(image.getWidth(this), image.getHeight(this));<br />
		setPreferredSize(imageSize);<br />
		this.setSize(imageSize);<br />
		this.validate();<br />
		initCompleted = true;<br />
	}</p>
<p>	public void disconnect(){<br />
		try{<br />
			if(connected){<br />
				dis.close();<br />
				connected = false;<br />
			}<br />
		}catch(Exception e){;}<br />
	}</p>
<p>	public void paint(Graphics g) { //used to set the image on the panel<br />
		if (image != null)<br />
			g.drawImage(image, 0, 0, this);<br />
	}</p>
<p>	public void readStream(){ //the basic method to continuously read the stream<br />
		try{<br />
			if (useMJPGStream){<br />
				while(true){<br />
					readMJPGStream();<br />
					this.repaint();<br />
				}<br />
			}<br />
			else{<br />
				while(true){<br />
					connect();<br />
					readJPG();<br />
					this.repaint();<br />
					disconnect();<br />
				}<br />
			}</p>
<p>		}catch(Exception e){;}<br />
	}</p>
<p>	public void readMJPGStream(){ //preprocess the mjpg stream to remove the mjpg encapsulation<br />
		readLine(3,dis); //discard the first 3 lines<br />
		readJPG();<br />
		readLine(2,dis); //discard the last two lines<br />
	}</p>
<p>	public void readJPG(){ //read the embedded jpeg image<br />
		try{<br />
			JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis);<br />
			image = decoder.decodeAsBufferedImage();<br />
		}catch(Exception e){e.printStackTrace();disconnect();}<br />
	}</p>
<p>	public void readLine(int n, DataInputStream dis){ //used to strip out the header lines<br />
		for (int i=0; i&lt;n;i++){<br />
		readLine(dis);<br />
		}<br />
	}<br />
	public void readLine(DataInputStream dis){<br />
		try{<br />
			boolean end = false;<br />
			String lineEnd = &quot;\n&quot;; //assumes that the end of the line is marked with this<br />
			byte[] lineEndBytes = lineEnd.getBytes();<br />
			byte[] byteBuf = new byte[lineEndBytes.length];</p>
<p>			while(!end){<br />
				dis.read(byteBuf,0,lineEndBytes.length);<br />
				String t = new String(byteBuf);<br />
				//System.out.print(t); //uncomment if you want to see what the lines actually look like<br />
				if(t.equals(lineEnd)) end=true;<br />
			}<br />
		}catch(Exception e){e.printStackTrace();}</p>
<p>	}<br />
	public void run() {<br />
		connect();<br />
		readStream();<br />
	}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phong Dinh</title>
		<link>http://blog.950buy.com/article/capture-video-from-ip-camera-using-jmf/comment-page-1/#comment-1115</link>
		<dc:creator>Phong Dinh</dc:creator>
		<pubDate>Tue, 11 Jan 2011 06:52:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.950buy.com/?p=108#comment-1115</guid>
		<description>load: AxisCamera.class can&#039;t be instantiated.
Please review your code, It doesn&#039;t work and throw the following exception:
java.lang.InstantiationException: AxisCamera
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)</description>
		<content:encoded><![CDATA[<p>load: AxisCamera.class can&#8217;t be instantiated.<br />
Please review your code, It doesn&#8217;t work and throw the following exception:<br />
java.lang.InstantiationException: AxisCamera<br />
	at java.lang.Class.newInstance0(Unknown Source)<br />
	at java.lang.Class.newInstance(Unknown Source)<br />
	at sun.applet.AppletPanel.createApplet(Unknown Source)<br />
	at sun.applet.AppletPanel.runLoader(Unknown Source)<br />
	at sun.applet.AppletPanel.run(Unknown Source)<br />
	at java.lang.Thread.run(Unknown Source)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

