Navigate to Here to download the screen recorder JAR, name is "MonteScreenRecorder.jar" and add this jar file your desired project.
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.awt.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.monte.media.math.Rational;
import org.monte.media.Format;
import org.monte.screenrecorder.ScreenRecorder;
import static org.monte.media.VideoFormatKeys.*;
public class VideoScreenCapture {
static ScreenRecorder screenRecorder;
public static void main(String[] args) throws IOException, AWTException {
// Provides information about the display screen such as size and resolution
GraphicsConfiguration gconfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
/* The output format (AVI) of the movie with number of frames/sec.
Specifies the mouse cursor color and refresh rate.
If 'NULL', audio will NOT be recorded. */
screenRecorder = new ScreenRecorder(gconfig,
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, (int) 24, FrameRateKey, Rational.valueOf(15),
QualityKey, 1.0f,
KeyFrameIntervalKey, (int) (15 * 60)),
new Format(MediaTypeKey, MediaType.VIDEO,
EncodingKey, "black",
FrameRateKey, Rational.valueOf(30)), null);
//create firefox instance
WebDriver driver = new FirefoxDriver();
// Start Capturing the Video
screenRecorder.start();
// Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// Launch google website
driver.navigate().to("http://www.google.com/");
// Maximize the browser
driver.manage().window().maximize();
// Click on Gmail
driver.findElement(By.linkText("Gmail")).click();
// Back previos state
driver.navigate().back();
// Forwart previos state
driver.navigate().forward();
//Navigate to facebook
driver.get("http://www.facebook.com/");
//Close the Browser.
driver.close();
// Stop the ScreenRecorder
screenRecorder.stop();
}
}
Output:
The recorded video is saved in the "C:\users\<
What will the format for recording audio in ScreenRecorder class
ReplyDelete