本文整理汇总了Java中org.monte.media.math.Rational类的典型用法代码示例。如果您正苦于以下问题:Java Rational类的具体用法?Java Rational怎么用?Java Rational使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rational类属于org.monte.media.math包,在下文中一共展示了Rational类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MonteScreenRecorder
import org.monte.media.math.Rational; //导入依赖的package包/类
public MonteScreenRecorder() {
GraphicsConfiguration gc = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice()
.getDefaultConfiguration();
this.files = new TreeSet<File>();
try {
this.screenRecorder = new ScreenRecorder(gc, new Format(
MediaTypeKey, MediaType.FILE, MimeTypeKey, FormatKeys.MIME_QUICKTIME),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey,
VideoFormatKeys.ENCODING_QUICKTIME_ANIMATION,
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)), null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: updateImage
import org.monte.media.math.Rational; //导入依赖的package包/类
private void updateImage() {
final Movie movie = getMovie();
if (movie == null) {
return;
}
execute(new Worker<BufferedImage>() {
@Override
protected BufferedImage construct() throws Exception {
Rational time=movie.getInsertionPoint();
return null;
}
@Override
protected void done(BufferedImage value) {
imagePanel.setImage(value);
}
});
}
示例3: ScreenRecorder
import org.monte.media.math.Rational; //导入依赖的package包/类
/**
* Creates a screen recorder.
*
* @param cfg Graphics configuration of the capture screen.
*/
public ScreenRecorder(GraphicsConfiguration cfg) throws IOException, AWTException {
this(cfg, null,
// the file format
new Format(MediaTypeKey, MediaType.FILE,
MimeTypeKey, MIME_QUICKTIME),
//
// the output format for screen capture
new Format(MediaTypeKey, MediaType.VIDEO,
EncodingKey, ENCODING_QUICKTIME_ANIMATION,
CompressorNameKey, COMPRESSOR_NAME_QUICKTIME_ANIMATION,
DepthKey, 24, FrameRateKey, new Rational(15, 1)),
//
// the output format for mouse capture
new Format(MediaTypeKey, MediaType.VIDEO,
EncodingKey, ENCODING_BLACK_CURSOR,
FrameRateKey, new Rational(30, 1)),
//
// the output format for audio capture
new Format(MediaTypeKey, MediaType.AUDIO,
EncodingKey, ENCODING_QUICKTIME_TWOS_PCM,
FrameRateKey, new Rational(48000, 1),
SampleSizeInBitsKey, 16,
ChannelsKey, 2, SampleRateKey, new Rational(48000, 1),
SignedKey, true, ByteOrderKey, ByteOrder.BIG_ENDIAN));
}
示例4: getDuration
import org.monte.media.math.Rational; //导入依赖的package包/类
@Override
public Rational getDuration() {
try {
ensureRealized();
} catch (IOException ex) {
ex.printStackTrace();
return new Rational(0, 1);
}
if (movieDuration == null) {
Rational maxDuration = new Rational(0, 1);
for (Track tr : tracks) {
Rational trackDuration = new Rational((tr.length * tr.scale + tr.startTime), tr.rate);
if (maxDuration.compareTo(trackDuration) < 0) {
maxDuration = trackDuration;
}
}
movieDuration = maxDuration;
}
return movieDuration;
}
示例5: timeToSample
import org.monte.media.math.Rational; //导入依赖的package包/类
@Override
public long timeToSample(int track, Rational time) {
Track tr = tracks.get(track);
// This only works, if all samples contain only one sample!
// FIXME - We foolishly assume that only audio tracks have more than one
// sample in a frame.
// FIXME - We foolishly assume that all samples have a sampleDuration != 0.
long index = time.getNumerator() * tr.rate / time.getDenominator() / tr.scale - tr.startTime;
if (tr.mediaType == AVIMediaType.AUDIO) {
int count = 0;
// FIXME This is very inefficient, perform binary search with sample.timestamp
// this will work for all media types!
for (int i = 0, n = tr.samples.size(); i < n; i++) {
long d = tr.samples.get(i).duration * tr.scale; // foolishly assume that sampleDuration = sample count
if (count + d > index) {
index = i;
break;
}
count += d;
}
}
return max(0, min(index, tr.samples.size()));
}
示例6: videoToString
import org.monte.media.math.Rational; //导入依赖的package包/类
private static String videoToString(Format f) {
StringBuilder buf = new StringBuilder();
buf.append(f.get(EncodingKey))//
.append(", ")//
.append(f.get(WidthKey))//
.append("x")//
.append(f.get(HeightKey))//
.append(", ")//
.append(f.get(DepthKey))//
.append("-bit, ")//
.append(f.get(FrameRateKey,new Rational(0,0)))//
.append(" fps")//
.append(f.get(FixedFrameRateKey,false) ? ", fixed rate" : "")//
.append(f.get(PixelAspectRatioKey,new Rational(1,1)).equals(new Rational(1, 1)) ? "" : ", " + f.get(PixelAspectRatioKey) + " pixel ratio")//
.append("")//
;
return buf.toString();
}
示例7: mouseDragged
import org.monte.media.math.Rational; //导入依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
if (movie == null) {
return;
}
if (pressedHandle != null) {
Rational time = posToTime(e.getX());
switch (pressedHandle) {
case SelectionStart:
time = Rational.min(time, movie.getSelectionEnd());
movie.setSelectionStart(time);
movie.setInsertionPoint(time);
break;
case SelectionEnd:
time = Rational.max(movie.getSelectionStart(), time);
movie.setSelectionEnd(time);
movie.setInsertionPoint(time);
break;
case InsertionPoint:
movie.setInsertionPoint(time);
break;
}
}
}
示例8: updateTimeLabel
import org.monte.media.math.Rational; //导入依赖的package包/类
protected void updateTimeLabel() {
Movie movie = getMovie();
Rational time = movie == null ? new Rational(0,1) : movie.getInsertionPoint();
int hours = (int) time.floor(1).getNumerator()/3600;
int minutes = (int) (time.floor(1).getNumerator() / 60) % 60;
int seconds = (int) (time.floor(1).getNumerator() % 60);
int frame = movie == null ? 0 : (int) (movie.timeToSample(0, time) - movie.timeToSample(0, time.floor(1)));
switch (labelMode) {
case TIME:
timeLabel.setText((hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
+ ":" + (seconds < 10 ? "0" + seconds : seconds)
+ "." + (frame < 10 ? "0" + frame : frame));
break;
case FRAME:
timeLabel.setText(Long.toString(movie.timeToSample(0, movie.getInsertionPoint()) ));
break;
}
}
示例9: reduceListRational
import org.monte.media.math.Rational; //导入依赖的package包/类
private static void reduceListRational(Rational value, InfGetter<Rational> g, ArrayList<AmigaDisplayInfo> infs) {
ArrayList<AmigaDisplayInfo> bestInfs = new ArrayList<AmigaDisplayInfo>();
bestInfs.add(infs.get(0));
float bestCost = g.get(infs.get(0)).subtract(value).floatValue();
bestCost *= bestCost;
for (Iterator<AmigaDisplayInfo> i = infs.iterator(); i.hasNext();) {
AmigaDisplayInfo inf = i.next();
Rational iv = g.get(inf);
if (iv.compareTo(value) != 0) {
i.remove();
}
float icost = iv.subtract(value).floatValue();
icost *= icost;
if (icost < bestCost) {
bestInfs.clear();
bestCost = icost;
} else if (icost == bestCost) {
bestInfs.add(inf);
}
}
if (infs.isEmpty()) {
infs.addAll(bestInfs);
}
}
示例10: SpecializedScreenRecorder
import org.monte.media.math.Rational; //导入依赖的package包/类
public SpecializedScreenRecorder(GraphicsConfiguration cfg, String name,
Configuration config) throws IOException, AWTException {
super(cfg, new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey,
config.getValue("video.format", MIME_QUICKTIME)), new Format(
MediaTypeKey, MediaType.VIDEO, EncodingKey,
config.getValue("video.encoding",
ENCODING_QUICKTIME_CINEPAK),
CompressorNameKey, config.getValue("video.compression",
COMPRESSOR_NAME_QUICKTIME_CINEPAK), DepthKey,
(int) 24, FrameRateKey, Rational.valueOf(Integer
.parseInt(config.getValue("video.format.frameRate",
"15"))), QualityKey, 1.0f, KeyFrameIntervalKey,
(int) (15 * 60)), new Format(MediaTypeKey, MediaType.VIDEO,
EncodingKey, "black", FrameRateKey, Rational.valueOf(30)), null);
this.name = name;
this.config = config;
this.setMaxFileSize(Long.parseLong(config.getValue("maxFileSize",MAX_SIZE_DEFAULT_KB)));
this.setMaxRecordingTime(Long.parseLong(config.getValue("maxRecordingTime",MAX_DURATION_DEFAULT_MS)));
}
示例11: writeMovie
import org.monte.media.math.Rational; //导入依赖的package包/类
private static void writeMovie(File file, BufferedImage[] frames) throws IOException {
MovieWriter out = Registry.getInstance().getWriter(file);
Format format = new Format(MediaTypeKey, MediaType.VIDEO, //
EncodingKey, ENCODING_AVI_MJPG,
FrameRateKey, new Rational(30, 1),//
WidthKey, frames[0].getWidth(), //
HeightKey, frames[0].getHeight(),//
DepthKey, 24
);
int track = out.addTrack(format);
try {
Buffer buf = new Buffer();
buf.format = new Format(DataClassKey, BufferedImage.class);
buf.sampleDuration = format.get(FrameRateKey).inverse();
for (int i = 0; i < frames.length; i++) {
buf.data = frames[i];
out.write(track, buf);
}
} finally {
out.close();
}
}
示例12: initScreen
import org.monte.media.math.Rational; //导入依赖的package包/类
/**
* initializes a graphic configurations
*/
public static void initScreen() {
// get the graphics configuration of the current screen
GraphicsConfiguration gc = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();
// set screen recorder configuration
try {
screenLogger = new ScreenRecorder(gc, null,
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)),
null, new File(pathToFile));
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (AWTException awte) {
awte.printStackTrace();
}
}
示例13: getScreenRecorder
import org.monte.media.math.Rational; //导入依赖的package包/类
private MonteScreenRecorder getScreenRecorder() {
int frameRate = videoConfiguration.frameRate();
Format fileFormat = new Format(MediaTypeKey, MediaType.VIDEO, MimeTypeKey, FormatKeys.MIME_AVI);
Format screenFormat = new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey,
ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
DepthKey, 24, FrameRateKey, Rational.valueOf(frameRate),
QualityKey, 1.0f,
KeyFrameIntervalKey, 15 * 60);
Format mouseFormat = new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black",
FrameRateKey, Rational.valueOf(frameRate));
Dimension screenSize = videoConfiguration.screenSize();
int width = screenSize.width;
int height = screenSize.height;
Rectangle captureSize = new Rectangle(0, 0, width, height);
return MonteScreenRecorderBuilder
.builder()
.setGraphicConfig(getGraphicConfig())
.setRectangle(captureSize)
.setFileFormat(fileFormat)
.setScreenFormat(screenFormat)
.setFolder(new File(videoConfiguration.folder()))
.setMouseFormat(mouseFormat).build();
}
示例14: ScreenGrabber
import org.monte.media.math.Rational; //导入依赖的package包/类
public ScreenGrabber(ScreenRecorder recorder, long startTime) throws AWTException, IOException {
this.recorder = recorder;
this.captureArea = recorder.captureArea;
this.robot = new Robot(recorder.captureDevice);
this.mouseFormat = recorder.mouseFormat;
this.mouseCaptures = recorder.mouseCaptures;
this.sync = recorder.sync;
this.cursorImg = recorder.cursorImg;
this.cursorImgPressed = recorder.cursorImgPressed;
this.cursorOffset = recorder.cursorOffset;
this.videoTrack = recorder.videoTrack;
this.prevScreenCaptureTime = new Rational(startTime, 1000);
this.startTime = startTime;
Format screenFormat = recorder.screenFormat;
if (screenFormat.get(DepthKey, 24) == 24) {
videoImg = new BufferedImage(this.captureArea.width, this.captureArea.height, BufferedImage.TYPE_INT_RGB);
} else if (screenFormat.get(DepthKey) == 16) {
videoImg = new BufferedImage(this.captureArea.width, this.captureArea.height, BufferedImage.TYPE_USHORT_555_RGB);
} else if (screenFormat.get(DepthKey) == 8) {
videoImg = new BufferedImage(this.captureArea.width, this.captureArea.height, BufferedImage.TYPE_BYTE_INDEXED, Colors.createMacColors());
} else {
throw new IOException("Unsupported color depth " + screenFormat.get(DepthKey));
}
videoGraphics = videoImg.createGraphics();
videoGraphics.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
videoGraphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
videoGraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
}
示例15: grabMouse
import org.monte.media.math.Rational; //导入依赖的package包/类
/**
* Captures the mouse cursor.
*/
private void grabMouse() throws InterruptedException {
long now = System.currentTimeMillis();
if (now > getStopTime()) {
future.cancel(false);
return;
}
PointerInfo info = MouseInfo.getPointerInfo();
Point p = info.getLocation();
if (!info.getDevice().equals(captureDevice)
|| !captureArea.contains(p)) {
// If the cursor is outside the capture region, we
// assign Integer.MAX_VALUE to its location.
// This ensures that all mouse movements outside of the
// capture region get coallesced.
p.setLocation(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
// Only create a new capture event if the location has changed
if (!p.equals(prevCapturedMouseLocation) || mouseWasPressed != mousePressedRecorded) {
Buffer buf = new Buffer();
buf.format = format;
buf.timeStamp = new Rational(now, 1000);
buf.data = p;
buf.header = mouseWasPressed;
mousePressedRecorded = mouseWasPressed;
mouseCaptures.put(buf);
prevCapturedMouseLocation.setLocation(p);
}
if (!mousePressed) {
mouseWasPressed = false;
}
}