If this blog helped you in any way, please donate a dollar here

Wednesday, December 21, 2011

Encoding Webcam data in Java

Java is the blue eyed boy of modern society. From Open Source lovers to Oracle, they all love Java. So, apparently, something like capturing data from a webcam and creating a video out if it should be a walk in the walk in the park, right?


Well, in this case, the walk appears to be rather full of potholes! Not only that, the road seems to veer off and disappear at times.


You see, there are various multimedia frameworks available in Java that allow you to capture webcam, but all of them have a JNI interface. This is where things so ugly. On Linux, such specific bits of code rely on Video for Linux (v4l or v4l2) abstractions. On Windows, DirectShow is the way to go.