Insufficient system resources, capture video from web camera java -


i'm trying capture video using jxcapture. manage once when i'm trying capture second time video in same program got troubles. code following:

public videocapture videocapture = videocapture.create(videoformat.wmv); public capturevideofromwebcamera(){}  public void start(string filename){       list<videosource> availablevideosources = videosource.getavailable();     system.out.println("availablevideosources = " + availablevideosources);      if (availablevideosources.isempty()) {         throw new illegalstateexception("no external video sources available");     }     videosource webcamera = availablevideosources.get(0);     system.out.println("webcamera = " + webcamera);      videocapture.setvideosource(webcamera);      java.util.list<codec> videocodecs = videocapture.getvideocodecs();     system.out.println("videocodecs = " + videocodecs);     if (videocodecs.isempty()) {         throw new illegalstateexception("no video codecs available");     }      codec videocodec = videocodecs.get(2);     system.out.println("videocodec = " + videocodec);      encodingparameters encodingparameters = new encodingparameters(new file("webcamera.wmv"));     encodingparameters.setbitrate(500000);     encodingparameters.setframerate(10);     encodingparameters.setkeyframeinterval(1);     encodingparameters.setcodec(videocodec);      videocapture.setencodingparameters(encodingparameters);     videocapture.start();     system.out.println("recording started. press 'enter' terminate.");  }  public void stop(string filename) throws ioexception{  system.in.read();  videocapture.stop(); }   public static void main(string[] args) throws throwable {      capturevideofromwebcamera obj = new capturevideofromwebcamera();     obj.start("");     obj.stop("");      capturevideofromwebcamera obj1 = new capturevideofromwebcamera();            obj1.start("");     obj1.stop("");  } 

}

when i'm trying i'm reveiving following error (insufficient system resources exist complete requested service web camera):

exception in thread "main" java.lang.runtimeexception: java.lang.reflect.invocationtargetexception @ com.teamdev.jxcapture.video.win.basedirectshowcapture.dostart(sourcefile:103) @ com.teamdev.jxcapture.videocapture.start(sourcefile:146) @ capturer.capturevideofromwebcamera.start(capturevideofromwebcamera.java:58) @ capturer.capturevideofromwebcamera.main(capturevideofromwebcamera.java:76) caused by: java.lang.reflect.invocationtargetexception @ com.teamdev.jxdesktop.win32.g.doinvokeandwait(unknown source) @ com.teamdev.jxcapture.video.win.basedirectshowcapture.dostart(sourcefile:97) ... 3 more caused by: com.teamdev.jxdesktop.win32.com.comexception: com object method returns error code: 0x800705aa; insufficient system resources exist complete requested service.

edit2: tried add thread sleep code in order wait second capturing process.

capturevideofromwebcamera obj = new capturevideofromwebcamera();     obj.start("1.wmv");     obj.stop("");     thread.sleep(5000);     capturevideofromwebcamera obj1 = new capturevideofromwebcamera();            obj1.start("2.wmv");     obj1.stop(""); 

i got same error.

edit3: when trying use same object capturing got following message:

exception in thread "main" java.lang.runtimeexception: java.lang.reflect.invocationtargetexception @ com.teamdev.jxcapture.video.win.basedirectshowcapture.dostart(sourcefile:103) @ com.teamdev.jxcapture.videocapture.start(sourcefile:146) @ capturevideofromwebcamera.start(capturevideofromwebcamera.java:47) //videocapture.start(); @ capturevideofromwebcamera.main(capturevideofromwebcamera.java:64) /obj.start("2.wmv"); caused by: java.lang.reflect.invocationtargetexception @ com.teamdev.jxdesktop.win32.g.doinvokeandwait(unknown source) @ com.teamdev.jxcapture.video.win.basedirectshowcapture.dostart(sourcefile:97) ... 3 more

actually, getting error message because resource has been locked thread , lock not released while try utilize same resource thread.

here, have 2 main things :

step 1 : in program, have setup thread.sleep(5000); pause thread instead , have not setup statement release resource. so, try resetting camera socket , closing object in finally statement.

step 2 : try synchronizedthread instead using normal 1 1 process can able use resource @ time.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -