use of org.monte.media.math.Rational in project carina by qaprosoft.
the class DesktopVideoRecorder method startDesktopScreenRecording.
/**
* start Desktop Recording with a lot of parameters.
* if you have more than one monitor it will record just first one.
*
* Requirements:
* ScreenRecoder supports "AVI" and "QuickTime" format for recording the video.
* For "AVI" format you need to install TSCC Codec (Techsmith Screen Capture Codec)
* while "QuickTime" format is supported by Appleās QuickTime Player.
* https://www.techsmith.com/download.html
* https://1481d.wpc.azureedge.net/801481D/origin.assets.techsmith.com/Downloads/TSCC.msi
*
* @param fileNameBase String
* @param file File
* @param captureSize Rectangle
* @param videoFileFormat can be VideoFormat.AVI or VideoFormat.MOV
* @param withSound if true will try to record sound. Works only on MOV and with a lot of noises.
* @throws Exception java.lang.Exception
*/
public void startDesktopScreenRecording(String fileNameBase, File file, Rectangle captureSize, VideoFormat videoFileFormat, boolean withSound) throws Exception {
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
Format audio = null;
// AVI format
if (videoFileFormat.equals(VideoFormat.AVI)) {
if (withSound) {
// Not working AVI audio capabilities. Investigate if will be needed.
/*
* audio = new Format(MediaTypeKey, MediaType.AUDIO,
* EncodingKey, ENCODING_AVI_PCM,
* ByteOrderKey,ByteOrder.LITTLE_ENDIAN,
* SignedKey,true,SampleSizeInBitsKey,24);
*/
/*
* audio = new Format(MediaTypeKey,MediaType.AUDIO,EncodingKey,ENCODING_PCM_UNSIGNED,
* FrameRateKey, new Rational(48000L, 1L),
* SampleSizeInBitsKey, 16,
* ChannelsKey, 2,
* SignedKey,false);
*/
/*
* audio = new Format(MediaTypeKey, MediaType.AUDIO,
* EncodingKey, ENCODING_PCM_UNSIGNED,
* FrameRateKey, new Rational(48000L, 1L),
* SampleSizeInBitsKey,8,
* ChannelsKey, 2,
* SampleRateKey, new Rational(48000L, 1L),
* SignedKey, Boolean.valueOf(false)
* //,
* //AudioFormatKeys.ByteOrderKey, ByteOrder.BIG_ENDIAN
* );
*/
}
this.screenRecorder = new SpecializedScreenRecorder(gc, captureSize, new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI), new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey, Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60), new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, Rational.valueOf(30)), audio, file, fileNameBase);
}
// MOV format
if (videoFileFormat.equals(VideoFormat.MOV)) {
if (withSound) {
audio = new Format(MediaTypeKey, MediaType.AUDIO, EncodingKey, ENCODING_QUICKTIME_TWOS_PCM, FrameRateKey, new Rational(48000L, 1L), SampleSizeInBitsKey, 16, ChannelsKey, 2, SampleRateKey, new Rational(48000L, 1L), SignedKey, Boolean.valueOf(true), AudioFormatKeys.ByteOrderKey, ByteOrder.BIG_ENDIAN);
}
this.screenRecorder = new SpecializedScreenRecorder(gc, captureSize, new Format(MediaTypeKey, MediaType.FILE, FormatKeys.MimeTypeKey, MIME_QUICKTIME), new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_QUICKTIME_ANIMATION, CompressorNameKey, COMPRESSOR_NAME_QUICKTIME_ANIMATION, DepthKey, 24, FrameRateKey, Rational.valueOf(15)), new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, Rational.valueOf(30)), audio, file, fileNameBase);
}
LOGGER.info("Start video recording. \nAbsolute path: " + file.getAbsolutePath() + " . \nStarting name is '" + fileNameBase + "'. \nDimensions: " + captureSize.toString());
this.screenRecorder.start();
}