Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better exception handling in MJPEG, examples
- Loading branch information
Showing
4 changed files
with
137 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...capture-driver-ipcam/src/examples/java/com/github/sarxos/webcam/ds/ipcam/JpegExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.sarxos.webcam.ds.ipcam; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.WebcamPanel; | ||
|
||
|
||
public class JpegExample { | ||
|
||
public static void main(String[] args) throws MalformedURLException { | ||
|
||
// Dasding is a radio in Germany. They have few network cameras | ||
// available to be viewed online. Here in this example we are creating | ||
// IP camera device working in PULL mode to request static JPEG images. | ||
|
||
String address = "http://www.dasding.de/ext/webcam/webcam770.php?cam=1"; | ||
IpCamDevice livecam = new IpCamDevice("dasding", new URL(address), IpCamMode.PULL); | ||
|
||
IpCamDriver driver = new IpCamDriver(); | ||
driver.register(livecam); | ||
|
||
Webcam.setDriver(driver); | ||
|
||
WebcamPanel panel = new WebcamPanel(Webcam.getDefault()); | ||
panel.setFPS(0.2); // 1 frame per 5 seconds | ||
|
||
JFrame f = new JFrame("Dasding Studio Live IP Camera"); | ||
f.add(panel); | ||
f.pack(); | ||
f.setVisible(true); | ||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...apture-driver-ipcam/src/examples/java/com/github/sarxos/webcam/ds/ipcam/MjpegExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.github.sarxos.webcam.ds.ipcam; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.WebcamPanel; | ||
|
||
|
||
/** | ||
* Example of how to stream MJPEG with Webcam Capture. | ||
* | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class MjpegExample { | ||
|
||
public static void main(String[] args) throws MalformedURLException { | ||
|
||
String address = "http://88.37.116.138/mjpg/video.mjpg "; | ||
IpCamDevice livecam = new IpCamDevice("Lignano Beach", new URL(address), IpCamMode.PUSH); | ||
|
||
IpCamDriver driver = new IpCamDriver(); | ||
driver.register(livecam); | ||
|
||
Webcam.setDriver(driver); | ||
|
||
WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0)); | ||
panel.setFPS(1); | ||
|
||
JFrame f = new JFrame("Live Views From Lignano Beach (Italy)"); | ||
f.add(panel); | ||
f.pack(); | ||
f.setVisible(true); | ||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters