Pure-Java Screen Recorder (obsolete)
I am working on a new AVIWriter class, which provides a higher level API than the AVIOutputStream class.
There is still a long way to go, so I decided to write a screen recorder as a demo for the upcoming class.
This recorder uses java.awt.Robot to capture the screen, and java.awt.MouseInfo for capturing the mouse cursor.
Screen changes are captured with a frame rate of up to 15 fps. Mouse cursor movements with up to 30 fps.
For encoding the videos with AVI, I have implemented the Techsmith Screen Capture Codec in pure Java. This codec is essentially the Microsoft RLE encoder with ZIP compression applied to each video frame.
To play back a recorded video, you may have to install the free codec from www.techsmith.com.
For QuickTime, the videos are encoded with the Apple Animation codec, which I already had implemented some time ago.
You can download the file ScreenRecorder.jar. Double click the file to start the screen recorder. The .jar file also includes the source code of the recorder. The code is preliminary, and may substantially change in future releases.
Update 2012-02-04:
A newer version of the screen recorder is available at http://www.randelshofer.ch/monte
Update 2012-01-13:
The code described in this article is obsolete. Stay tuned for a new recorder which also supports audio capture in AVI files.
Update 2011-07-05:
The rate of screen and mouse captures can now be adjusted individually.
Update 2011-05-13:
I have added support for audio capture. This feature is currently only available with QuickTime videos, since AVIWriter is not finished yet. Audio is recorded from line-in. Line-in is usually the microphone of the computer.
Update 2011-05-09:
I have changed the code so that it will record into the home folder “Videos” on Windows, and into “Movies” on Mac OS X and everywhere else. In the prior version, recording silently failed if this folder did not exist. Now, an error message is displayed.
Update 2014-01-22:
I have closed the comment section for this article, because the screen recorder class is obsolete. Take a look at the Monte Media Library for newer versions.
Comments are closed.
Hai Werner,
I downloaded the jar file and working on it, it is very nice and working great thanks for that.
But I want to record the Audio which is coming out from the music player in my PC. Is it possible to record like that.
Please, can you help me out from this requirement.
Thank you
Bhargava Naluvala
Hi Bhargava,
Yes, recording audio generated by the PC is possible. The screen recorder records audio from line in. To record audio generated by the PC, connect the audio output jacket and the audio input jacket with a cable.
You can buy this kind of cable at every electronics store.
Best,
Werner
Hai Werner,
Thanks for your reply now Iam able to record the lineout audio coming from my pc, but the thing is when Iam recording the video for 1 min the file size is going up to 100MB, is there any way to reduce the size of the recorded file by coding.
Please, help me out
Thanks
Bhargava
bhargava,
The file size is determined by your choice of the codecs, rate settings and the amount of screen changes.
With the default settings of the screen recorder (QuickTime, Screen Capture Codec, Millions of colors, 10 fps screen rate, 30 fps mouse rate, 22.050 Hz audio) on a 1024 x 768 computer screen, I get about 10 MB per minute, while browsing through a few Internet pages and writing an e-mail.
hth,
Werner
Hello Werner,
ya, me to getting 10 MB per minute with the settings which you have given but while recording a video on the screen i am getting the file size as 100MB per minute.
I think it is the bit rate problem, is there any way to control or to set the bit rate in this application..
if there could you please help me out from this requirement.
Thanks
Bhargava
Hi Bhargava,
Screen recorders are not suited for capturing videos.
It is not clear to me, why you want to do this?
I mean, if you already have a video file, why perform a screen capture?
Anyway. Here are two possibilities for reducing the file size:
Postprocessing with a third-party tool: After capturing the video with the Screen Capture codec, use ffmpeg to re-encode the screen recording with H.264. This will give the best results, but you may encounter problems with bandwidth and space limitations of your hard disk while recording.
Bandwidth-Limitation while recording: The JPEG codec supports different quality settings. Recording a full-screen video with JPEG 50 % encoding will yield a smaller file size than the TechSmith Codec. The file will still be huge though. Again, you can postprocess it with ffmpeg, but since the JPEG codec introduces artefacts, the resulting movie will have two generations of compression artefacts (JPEG + H.264).
hth,
Werner
what does colour means here?
In Quicktime format the audio is having disturbance.why it is so?
Hey Bhargava, It was really helpful..thanks a lot..
Hi Priyanka,
The “Colors” option specifies the number of colors that are recorded. This is used to limit the bandwidth of a recording. For hundreds of colors, 8-bits per pixel are needed; for thousands of colors 16-bits are needed, for millions of colors 24-bits.
I haven’t noticed issues with audio recordings. What kind of disturbance do you experience? Have you ensured that the microphone level of your computer is properly set. For example, if the microphone level is set too high, audio amplitudes will be clipped resulting in distorted sounds.
Hello Werner,
I have checked it..but with avi format the audio quality is good..but not with quicktime..can you please explain the different encoding techniques that you have provided?
thank you,
priyanka
Priyanka,
Audio is passed through from the audio channel. No encoding is applied.
Maybe the screen recorder does not specify the proper audio format (for example big endian instead of little endian).
Which audio setting did you use, and on which platform did you perform the recording?
I am not asking about encoding for the audio but i am asking about video that you have given in the combo box i.e. Screen Capture,Runlength,png,jpeg-100% and jpeg 50%?
The video encoding formats are linked in the blog articles. You can click on a link to get more information about a format.
Hello Werner,
I am currently working on screen recording with audio feature application.The jar file which you have provided is exactly what am looking for.I just want to pass parameters at the run time to the jar file.The main purpose of this research is the user don’t need to click the record button to start the recording & click again to stop the recording.When it received Start parameter the jar should start the recording & when it received Stop parameter the jar should stop the recording.Guide me how to pass parameters & in which file i have to make changes to reach my destination.Thanks in advance.
Hello Werner,
When playing the recorded video the audio is not clear & very noisy.I used Quicktime,20 FPS & Primary Sound Capture Driver with 44.100 Hz,Stereo.When played in windows media player the audio is so good but i couldn’t able to watch the video.When played in VLC player the video is so good but audio is heavily disturbed & very noisy.When played in quick time player it asks me to install additional softwares.How can i record & play the video with audio without any noise & disturbance?Please guide me to solve this issue?
When you plan support for audio in AVI files format???
Hi Werner,
Thanks for the wonderful article. This works perfectly fine. But when system goes to idle or sleep mode, i see only black videos with no recordings.
Have you come across this issue?
Thanks
Veera
I have made the java screen recorder now how do I export it to MP4 and compress it to make less then 4 MB for 1 minutes full screen recording..
http://www.screencast-o-matic.com/ also have the screen recorder and its gives less then 4 mb file size ever time for 1 minute recording .. how is that possible .
Regards,
Puneet Thakur
Hi,
Screen recorder records a black screen when the machine is not connected and something is going on in that machine.
i am using montescreen recorder jar, any help would be great.
Thanks in advance.
I am trying to open the file in windows media player and quicktime it will not work