I suggest that the Xuggle library does what you want - although it may actually be a wrapper around a native library such as ffmpeg.
Here is a snippet of sample code that encodes screenshots of the desktop on flv (mp4):
final Robot robot = new Robot(); final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
This code is from this tutorial on the Xuggle website.
More advanced encoding is also on the Xuggle website here .
If the native shell is what you wanted, run the web search "IContainerFormat flv" for the other bits of the sample code.
In addition, a very similar question already exists.
Update: Original Java Implementation
Check out ScreenVideoEncoder.java from the bigbluebutton project on github.
source share