{"action":"created","issue":{"url":"https://api.github.com/repos/sarxos/webcam-capture/issues/406","labels_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/406/labels{/name}","comments_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/406/comments","events_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/406/events","html_url":"https://github.com/sarxos/webcam-capture/issues/406","id":114781169,"number":406,"title":"Recording Video From Multiple Cams using Multi Threading","user":{"login":"MuhammadAmmad","id":9246451,"avatar_url":"https://avatars.githubusercontent.com/u/9246451?v=3","gravatar_id":"","url":"https://api.github.com/users/MuhammadAmmad","html_url":"https://github.com/MuhammadAmmad","followers_url":"https://api.github.com/users/MuhammadAmmad/followers","following_url":"https://api.github.com/users/MuhammadAmmad/following{/other_user}","gists_url":"https://api.github.com/users/MuhammadAmmad/gists{/gist_id}","starred_url":"https://api.github.com/users/MuhammadAmmad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MuhammadAmmad/subscriptions","organizations_url":"https://api.github.com/users/MuhammadAmmad/orgs","repos_url":"https://api.github.com/users/MuhammadAmmad/repos","events_url":"https://api.github.com/users/MuhammadAmmad/events{/privacy}","received_events_url":"https://api.github.com/users/MuhammadAmmad/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sarxos/webcam-capture/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-11-03T10:06:26Z","updated_at":"2015-11-16T10:04:28Z","closed_at":null,"body":"Hi @sarxos Thanks for such an amazing library. I m using video recording example with xuggler. It is running fine with one cam but when I add more cams (almost 13) then the recorded video is very slow. I m using threads. One thread for each cam but still it is slow. Plz help! Thanks again"},"comment":{"url":"https://api.github.com/repos/sarxos/webcam-capture/issues/comments/156976642","html_url":"https://github.com/sarxos/webcam-capture/issues/406#issuecomment-156976642","issue_url":"https://api.github.com/repos/sarxos/webcam-capture/issues/406","id":156976642,"user":{"login":"sarxos","id":472658,"avatar_url":"https://avatars.githubusercontent.com/u/472658?v=3","gravatar_id":"","url":"https://api.github.com/users/sarxos","html_url":"https://github.com/sarxos","followers_url":"https://api.github.com/users/sarxos/followers","following_url":"https://api.github.com/users/sarxos/following{/other_user}","gists_url":"https://api.github.com/users/sarxos/gists{/gist_id}","starred_url":"https://api.github.com/users/sarxos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarxos/subscriptions","organizations_url":"https://api.github.com/users/sarxos/orgs","repos_url":"https://api.github.com/users/sarxos/repos","events_url":"https://api.github.com/users/sarxos/events{/privacy}","received_events_url":"https://api.github.com/users/sarxos/received_events","type":"User","site_admin":false},"created_at":"2015-11-16T10:04:28Z","updated_at":"2015-11-16T10:04:28Z","body":"Hi @MuhammadAmmad ,\r\n\r\nI tested your code pulling precaptured static images from Dasding web page (I have no access to so many IP cameras). The XML cameras descriptor I used can be found [here](https://github.com/sarxos/webcam-capture/blob/master/webcam-capture-drivers/driver-ipcam/src/examples/resources/cameras.xml). Please note these images are updated once every 20 seconds, so this is not even close to 10 FPS, but I put some logs into the code and can clearly see that parallel fetching rate did not drop.\r\n\r\nWhat I modified:\r\n\r\n```java\r\nSystem.out.println(System.currentTimeMillis() + \" \" + Thread.currentThread().getName() + \" \" + camName + \" \" + \"Capture frame \" + i);\r\nbufferedImgs.add(new VideoPic(webcam.getImage(), System.currentTimeMillis()));\r\nSystem.out.println(System.currentTimeMillis() + \" \" + Thread.currentThread().getName() + \" \" + camName + \" \" + \"Capture frame \" + i + \" done\");\r\n```\r\n\r\nAnd the output:\r\n\r\n```\r\ntimestamp     thread   camera     msg\r\n1447666351817 Thread-4 Dasding 06 Capture frame 0\r\n1447666351818 Thread-4 Dasding 06 Capture frame 0 done\r\n1447666351844 Thread-5 Dasding 07 Capture frame 0\r\n1447666351844 Thread-5 Dasding 07 Capture frame 0 done\r\n1447666351852 Thread-6 Dasding 10 Capture frame 0\r\n1447666351852 Thread-6 Dasding 10 Capture frame 0 done\r\n1447666351918 Thread-4 Dasding 06 Capture frame 1\r\n1447666351918 Thread-4 Dasding 06 Capture frame 1 done\r\n1447666351920 Thread-3 Dasding 04 Capture frame 0\r\n1447666351920 Thread-3 Dasding 04 Capture frame 0 done\r\n1447666351939 Thread-2 Dasding 02 Capture frame 0\r\n1447666351939 Thread-2 Dasding 02 Capture frame 0 done\r\n1447666351944 Thread-5 Dasding 07 Capture frame 1\r\n1447666351945 Thread-5 Dasding 07 Capture frame 1 done\r\n1447666351952 Thread-6 Dasding 10 Capture frame 1\r\n1447666351952 Thread-6 Dasding 10 Capture frame 1 done\r\n1447666352018 Thread-4 Dasding 06 Capture frame 2\r\n1447666352018 Thread-4 Dasding 06 Capture frame 2 done\r\n1447666352020 Thread-3 Dasding 04 Capture frame 1\r\n1447666352020 Thread-3 Dasding 04 Capture frame 1 done\r\n1447666352045 Thread-2 Dasding 02 Capture frame 1\r\n1447666352045 Thread-5 Dasding 07 Capture frame 2\r\n1447666352045 Thread-2 Dasding 02 Capture frame 1 done\r\n1447666352045 Thread-5 Dasding 07 Capture frame 2 done\r\n1447666352052 Thread-6 Dasding 10 Capture frame 2\r\n1447666352052 Thread-6 Dasding 10 Capture frame 2 done\r\n1447666352054 Thread-1 Dasding 01 Capture frame 0\r\n1447666352054 Thread-1 Dasding 01 Capture frame 0 done\r\n1447666352118 Thread-4 Dasding 06 Capture frame 3\r\n1447666352118 Thread-4 Dasding 06 Capture frame 3 done\r\n1447666352121 Thread-3 Dasding 04 Capture frame 2\r\n1447666352121 Thread-3 Dasding 04 Capture frame 2 done\r\n1447666352145 Thread-2 Dasding 02 Capture frame 2\r\n1447666352145 Thread-5 Dasding 07 Capture frame 3\r\n1447666352145 Thread-5 Dasding 07 Capture frame 3 done\r\n1447666352145 Thread-2 Dasding 02 Capture frame 2 done\r\n1447666352152 Thread-6 Dasding 10 Capture frame 3\r\n1447666352152 Thread-6 Dasding 10 Capture frame 3 done\r\n1447666352154 Thread-1 Dasding 01 Capture frame 1\r\n1447666352154 Thread-1 Dasding 01 Capture frame 1 done\r\n... etc\r\n```\r\n\r\nTherefore, if there is a lag in fetching images through the network, it's may be caused by either lag on networking side or in IP camera, but there is no issue in the Webcam Capture API.\r\n\r\nFor example, camera Dasding 01 was executed every 100 ms, with quite good precision:\r\n\r\n```\r\n$  cat times.txt | grep \"Dasding 01\" | grep done\r\n```\r\n\r\nGives:\r\n\r\n```\r\n1447666352054 Thread-1 Dasding 01 Capture frame 0 done\r\n1447666352154 Thread-1 Dasding 01 Capture frame 1 done\r\n1447666352254 Thread-1 Dasding 01 Capture frame 2 done\r\n1447666352354 Thread-1 Dasding 01 Capture frame 3 done\r\n1447666352454 Thread-1 Dasding 01 Capture frame 4 done\r\n1447666352554 Thread-1 Dasding 01 Capture frame 5 done\r\n1447666352654 Thread-1 Dasding 01 Capture frame 6 done\r\n1447666352755 Thread-1 Dasding 01 Capture frame 7 done\r\n1447666352855 Thread-1 Dasding 01 Capture frame 8 done\r\n1447666352955 Thread-1 Dasding 01 Capture frame 9 done\r\n1447666353055 Thread-1 Dasding 01 Capture frame 10 done\r\n1447666353155 Thread-1 Dasding 01 Capture frame 11 done\r\n1447666353258 Thread-1 Dasding 01 Capture frame 12 done\r\n1447666353358 Thread-1 Dasding 01 Capture frame 13 done\r\n1447666353459 Thread-1 Dasding 01 Capture frame 14 done\r\n1447666353559 Thread-1 Dasding 01 Capture frame 15 done\r\n1447666353659 Thread-1 Dasding 01 Capture frame 16 done\r\n1447666353759 Thread-1 Dasding 01 Capture frame 17 done\r\n1447666353886 Thread-1 Dasding 01 Capture frame 18 done\r\n1447666353986 Thread-1 Dasding 01 Capture frame 19 done\r\n1447666354086 Thread-1 Dasding 01 Capture frame 20 done\r\n1447666354186 Thread-1 Dasding 01 Capture frame 21 done\r\n1447666354287 Thread-1 Dasding 01 Capture frame 22 done\r\n1447666354387 Thread-1 Dasding 01 Capture frame 23 done\r\n1447666354487 Thread-1 Dasding 01 Capture frame 24 done\r\n1447666354587 Thread-1 Dasding 01 Capture frame 25 done\r\n1447666354687 Thread-1 Dasding 01 Capture frame 26 done\r\n1447666354787 Thread-1 Dasding 01 Capture frame 27 done\r\n1447666354887 Thread-1 Dasding 01 Capture frame 28 done\r\n1447666355013 Thread-1 Dasding 01 Capture frame 29 done\r\n1447666355113 Thread-1 Dasding 01 Capture frame 30 done\r\n1447666355213 Thread-1 Dasding 01 Capture frame 31 done\r\n1447666355313 Thread-1 Dasding 01 Capture frame 32 done\r\n1447666355413 Thread-1 Dasding 01 Capture frame 33 done\r\n1447666355513 Thread-1 Dasding 01 Capture frame 34 done\r\n1447666355614 Thread-1 Dasding 01 Capture frame 35 done\r\n1447666355714 Thread-1 Dasding 01 Capture frame 36 done\r\n1447666355814 Thread-1 Dasding 01 Capture frame 37 done\r\n1447666355914 Thread-1 Dasding 01 Capture frame 38 done\r\n1447666356018 Thread-1 Dasding 01 Capture frame 39 done\r\n1447666356118 Thread-1 Dasding 01 Capture frame 40 done\r\n1447666356296 Thread-1 Dasding 01 Capture frame 41 done\r\n1447666356396 Thread-1 Dasding 01 Capture frame 42 done\r\n1447666356497 Thread-1 Dasding 01 Capture frame 43 done\r\n1447666356597 Thread-1 Dasding 01 Capture frame 44 done\r\n1447666356697 Thread-1 Dasding 01 Capture frame 45 done\r\n1447666356797 Thread-1 Dasding 01 Capture frame 46 done\r\n1447666356897 Thread-1 Dasding 01 Capture frame 47 done\r\n1447666356997 Thread-1 Dasding 01 Capture frame 48 done\r\n1447666357097 Thread-1 Dasding 01 Capture frame 49 done\r\n1447666357198 Thread-1 Dasding 01 Capture frame 50 done\r\n1447666357298 Thread-1 Dasding 01 Capture frame 51 done\r\n1447666357398 Thread-1 Dasding 01 Capture frame 52 done\r\n1447666357498 Thread-1 Dasding 01 Capture frame 53 done\r\n1447666357598 Thread-1 Dasding 01 Capture frame 54 done\r\n1447666357698 Thread-1 Dasding 01 Capture frame 55 done\r\n1447666357798 Thread-1 Dasding 01 Capture frame 56 done\r\n1447666357899 Thread-1 Dasding 01 Capture frame 57 done\r\n1447666357999 Thread-1 Dasding 01 Capture frame 58 done\r\n1447666358099 Thread-1 Dasding 01 Capture frame 59 done\r\n1447666358199 Thread-1 Dasding 01 Capture frame 60 done\r\n1447666358299 Thread-1 Dasding 01 Capture frame 61 done\r\n1447666358399 Thread-1 Dasding 01 Capture frame 62 done\r\n1447666358500 Thread-1 Dasding 01 Capture frame 63 done\r\n1447666358600 Thread-1 Dasding 01 Capture frame 64 done\r\n1447666358700 Thread-1 Dasding 01 Capture frame 65 done\r\n1447666358800 Thread-1 Dasding 01 Capture frame 66 done\r\n1447666358900 Thread-1 Dasding 01 Capture frame 67 done\r\n1447666359000 Thread-1 Dasding 01 Capture frame 68 done\r\n1447666359100 Thread-1 Dasding 01 Capture frame 69 done\r\n1447666359201 Thread-1 Dasding 01 Capture frame 70 done\r\n1447666359414 Thread-1 Dasding 01 Capture frame 71 done\r\n1447666359514 Thread-1 Dasding 01 Capture frame 72 done\r\n1447666359614 Thread-1 Dasding 01 Capture frame 73 done\r\n1447666359715 Thread-1 Dasding 01 Capture frame 74 done\r\n1447666359815 Thread-1 Dasding 01 Capture frame 75 done\r\n1447666359915 Thread-1 Dasding 01 Capture frame 76 done\r\n1447666360015 Thread-1 Dasding 01 Capture frame 77 done\r\n1447666360115 Thread-1 Dasding 01 Capture frame 78 done\r\n1447666360215 Thread-1 Dasding 01 Capture frame 79 done\r\n1447666360316 Thread-1 Dasding 01 Capture frame 80 done\r\n1447666360416 Thread-1 Dasding 01 Capture frame 81 done\r\n1447666360516 Thread-1 Dasding 01 Capture frame 82 done\r\n1447666360616 Thread-1 Dasding 01 Capture frame 83 done\r\n1447666360716 Thread-1 Dasding 01 Capture frame 84 done\r\n1447666360816 Thread-1 Dasding 01 Capture frame 85 done\r\n1447666360916 Thread-1 Dasding 01 Capture frame 86 done\r\n1447666361017 Thread-1 Dasding 01 Capture frame 87 done\r\n1447666361117 Thread-1 Dasding 01 Capture frame 88 done\r\n1447666361217 Thread-1 Dasding 01 Capture frame 89 done\r\n1447666361317 Thread-1 Dasding 01 Capture frame 90 done\r\n1447666361417 Thread-1 Dasding 01 Capture frame 91 done\r\n1447666361517 Thread-1 Dasding 01 Capture frame 92 done\r\n1447666361617 Thread-1 Dasding 01 Capture frame 93 done\r\n1447666361717 Thread-1 Dasding 01 Capture frame 94 done\r\n1447666361818 Thread-1 Dasding 01 Capture frame 95 done\r\n1447666361918 Thread-1 Dasding 01 Capture frame 96 done\r\n1447666362018 Thread-1 Dasding 01 Capture frame 97 done\r\n1447666362118 Thread-1 Dasding 01 Capture frame 98 done\r\n1447666362219 Thread-1 Dasding 01 Capture frame 99 done\r\n```\r\n\r\nJust FYI, your code threw an error on writing images to files:\r\n\r\n```plain\r\nException in thread \"Thread-20\" java.lang.RuntimeException: could not open stream com.xuggle.xuggler.IStream@-1409148128[index:0;id:0;streamcoder:com.xuggle.xuggler.IStreamCoder@-1409147856[codec=com.xuggle.xuggler.ICodec@-1409148464[type=CODEC_TYPE_VIDEO;id=CODEC_ID_H264;name=libx264;];time base=1/1000000;frame rate=0/0;pixel type=YUV420P;width=770;height=433;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]: Operation not permitted\r\n\tat com.xuggle.mediatool.MediaWriter.openStream(MediaWriter.java:1192)\r\n\tat com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1052)\r\n\tat com.xuggle.mediatool.MediaWriter.encodeVideo(MediaWriter.java:742)\r\n\tat com.xuggle.mediatool.MediaWriter.encodeVideo(MediaWriter.java:783)\r\n\tat com.github.sarxos.webcam.WebcamViewerExample.saveClip(WebcamViewerExample.java:91)\r\n\tat com.github.sarxos.webcam.WebcamViewerExample.access$0(WebcamViewerExample.java:76)\r\n\tat com.github.sarxos.webcam.WebcamViewerExample$SaveClip.run(WebcamViewerExample.java:130)\r\n```\r\n\r\nI haven't investigate this further due to my time limits, but I see no issue in the code in Webcam Capture API code. I suppose your problem may be either:\r\n\r\n* Throttling in networking,\r\n* IP camera is not able to generate so many FPS per second in PULL mode,\r\n* Xuggler issue with parallel stream recording (this is out of scope of my knowledge)."}}