Click here to Skip to main content
15,890,399 members
Home / Discussions / Java
   

Java

 
QuestionSplit and Replace methods Pin
f2616-Dec-13 18:28
f2616-Dec-13 18:28 
AnswerRe: Split and Replace methods Pin
Richard MacCutchan16-Dec-13 23:11
mveRichard MacCutchan16-Dec-13 23:11 
GeneralRe: Split and Replace methods Pin
f2616-Dec-13 23:47
f2616-Dec-13 23:47 
GeneralRe: Split and Replace methods Pin
Member 1041746021-Dec-13 9:30
Member 1041746021-Dec-13 9:30 
GeneralRe: Split and Replace methods Pin
Richard MacCutchan21-Dec-13 21:16
mveRichard MacCutchan21-Dec-13 21:16 
AnswerRe: Split and Replace methods Pin
BobJanova17-Dec-13 1:58
BobJanova17-Dec-13 1:58 
GeneralRe: Split and Replace methods Pin
Richard MacCutchan17-Dec-13 2:47
mveRichard MacCutchan17-Dec-13 2:47 
Questionwebcam for java android eclipse Pin
NooobieCoder16-Dec-13 16:25
NooobieCoder16-Dec-13 16:25 
Hi, what I want to do is to capture live video from a webcam in this java application, but had an error when I run this set of code:
VB
java.io.IOException: Could not connect to capture device
javax.media.NoDataSourceException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.io.IOException: Could not connect to capture device


I had already put the jmf.jar into the lib folder.


Java
<pre lang="java">
public class CamRecorder {

static VideoFormat videoFormat;
static AudioFormat audioFormat;
static CaptureDeviceInfo videoDevice;
static CaptureDeviceInfo audioDevice;

public static void main(String[] args) {
try {
Vector deviceList = CaptureDeviceManager.getDeviceList(new YUVFormat()); //get all media devices

CaptureDeviceInfo device = (CaptureDeviceInfo) deviceList.firstElement(); //in this computer the only capture device is in=built webcam stays at 0th position
Format[] formats = device.getFormats(); //get all formats

for (int x = 0; x < formats.length; x++) {
if (formats[x] != null && formats[x] instanceof VideoFormat) {
videoFormat = (VideoFormat) formats[x]; //take the video format
videoDevice = device;
}
/*if (formats[x] != null && formats[x] instanceof AudioFormat) {
audioFormat = (AudioFormat) formats[x]; //take the audio format
//audioDevice = device;
}*/
}
//create data sources
DataSource videoDataSource = Manager.createDataSource(device.getLocator());

deviceList = CaptureDeviceManager.getDeviceList(new VideoFormat(null)); //get all media devices
device = (CaptureDeviceInfo) deviceList.firstElement();

DataSource audioDataSource=Manager.createDataSource(device.getLocator());

DataSource[] dArray=new DataSource[1];
dArray[0]=videoDataSource;
//dArray[1]=audioDataSource;

DataSource mixedDataSource = Manager.createMergingDataSource(dArray);

//format for output

Format[] outputFormats=new Format[2];
outputFormats[0]=new VideoFormat(VideoFormat.YUV);
//outputFormats[1]=new AudioFormat(AudioFormat.LINEAR);
//output type
FileTypeDescriptor outputType=new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);

//settingup Processor
ProcessorModel processorModel=new ProcessorModel(mixedDataSource, outputFormats, outputType);
Processor processor=Manager.createRealizedProcessor(processorModel);

//settingup sink
DataSource outputDataSource=processor.getDataOutput();
MediaLocator destination=new MediaLocator("file:.\\testcam.avi");
DataSink dataSink=Manager.createDataSink(outputDataSource, destination);
dataSink.open();

//start sink + processor
Thread.sleep(4000);
dataSink.start();
processor.start();

Thread.sleep(4000);

dataSink.close();
processor.stop();
processor.close();


} catch (Exception ex) {
System.out.println(ex);
}
}
}
QuestionIntelliJ IDEA, Think like a computer scientist. import a java file Pin
David C# Hobbyist.15-Dec-13 4:18
professionalDavid C# Hobbyist.15-Dec-13 4:18 
AnswerRe: IntelliJ IDEA, Think like a computer scientist. import a java file Pin
Richard MacCutchan15-Dec-13 4:43
mveRichard MacCutchan15-Dec-13 4:43 
GeneralRe: IntelliJ IDEA, Think like a computer scientist. import a java file Pin
David C# Hobbyist.15-Dec-13 10:56
professionalDavid C# Hobbyist.15-Dec-13 10:56 
GeneralRe: IntelliJ IDEA, Think like a computer scientist. import a java file Pin
Richard MacCutchan15-Dec-13 21:11
mveRichard MacCutchan15-Dec-13 21:11 
Questionproject code Pin
Member 1045083712-Dec-13 19:45
Member 1045083712-Dec-13 19:45 
AnswerRe: project code Pin
Richard MacCutchan12-Dec-13 21:25
mveRichard MacCutchan12-Dec-13 21:25 
Questionjava .. while Pin
Ehab Obiad12-Dec-13 7:55
Ehab Obiad12-Dec-13 7:55 
AnswerRe: java .. while Pin
R.K.krishna12-Dec-13 15:48
R.K.krishna12-Dec-13 15:48 
QuestionHow to draw Shapes from MySQL Database Pin
f2611-Dec-13 23:33
f2611-Dec-13 23:33 
QuestionRe: How to draw Shapes from MySQL Database Pin
Richard MacCutchan12-Dec-13 0:13
mveRichard MacCutchan12-Dec-13 0:13 
AnswerRe: How to draw Shapes from MySQL Database Pin
f2612-Dec-13 7:48
f2612-Dec-13 7:48 
AnswerRe: How to draw Shapes from MySQL Database Pin
BobJanova12-Dec-13 5:33
BobJanova12-Dec-13 5:33 
QuestionGood books on JDBC and Java Swing? Pin
Member 1033880511-Dec-13 15:05
Member 1033880511-Dec-13 15:05 
AnswerRe: Good books on JDBC and Java Swing? Pin
Richard MacCutchan11-Dec-13 21:22
mveRichard MacCutchan11-Dec-13 21:22 
AnswerRe: Good books on JDBC and Java Swing? Pin
TorstenH.12-Dec-13 3:08
TorstenH.12-Dec-13 3:08 
AnswerRe: Good books on JDBC and Java Swing? Pin
M Riaz Bashir15-Dec-13 1:38
M Riaz Bashir15-Dec-13 1:38 
QuestionJava Code to Print JFrame or JPannel Form Contents Pin
Cyber129-Dec-13 21:41
Cyber129-Dec-13 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.