Mercurial > jmeCapture
view src/com/aurellem/capture/Capture.java @ 42:b1bc965a38d2
use reflection to set timer for MotionTrack for now
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 03 Nov 2011 18:47:21 -0700 |
parents | 784a3f4e6202 |
children | 388f9d062012 |
line wrap: on
line source
1 package com.aurellem.capture;3 import java.io.File;4 import java.io.IOException;5 import java.util.concurrent.Callable;7 import com.aurellem.capture.audio.MultiListener;8 import com.aurellem.capture.audio.WaveFileWriter;9 import com.aurellem.capture.video.AVIVideoRecorder;10 import com.aurellem.capture.video.AbstractVideoRecorder;11 import com.aurellem.capture.video.FileVideoRecorder;12 import com.aurellem.capture.video.XuggleVideoRecorder;13 import com.jme3.app.Application;14 import com.jme3.audio.AudioRenderer;15 import com.jme3.renderer.ViewPort;16 import com.jme3.scene.Spatial;17 import com.jme3.system.AppSettings;19 public class Capture {21 public static void captureVideo(final Application app, final File file) throws IOException{23 final AbstractVideoRecorder videoRecorder;24 // The XuggleVideoRecorder is better than the AVIVideoRecorder in every way25 // except for ease of installation. The excellent work by Werner Randelshofer26 // is used as a fallback option. Please visit http://www.xuggle.com/ to learn27 // how to set up the XuggleVideoRecorder.29 if (file.getCanonicalPath().endsWith(".avi")){30 videoRecorder = new AVIVideoRecorder(file);}31 else if (file.isDirectory()){32 videoRecorder = new FileVideoRecorder(file);}33 else { videoRecorder = new XuggleVideoRecorder(file);}35 Callable<Object> thunk = new Callable<Object>(){36 public Object call(){38 ViewPort viewPort =39 app.getRenderManager()40 .createPostView("aurellem record", app.getCamera());42 viewPort.setClearFlags(false, false, false);44 // get GUI node stuff45 for (Spatial s : app.getGuiViewPort().getScenes()){46 viewPort.attachScene(s);47 }49 app.getStateManager().attach(videoRecorder);50 viewPort.addProcessor(videoRecorder);51 return null;52 }53 };54 app.enqueue(thunk);55 }58 public static void captureAudio(final Application app, final File file) throws IOException{59 AppSettings settings = new AppSettings(true);60 settings.setAudioRenderer("Send");61 app.setSettings(settings);62 final WaveFileWriter writer = new WaveFileWriter(file);64 Callable<Object> thunk = new Callable<Object>(){65 public Object call(){66 AudioRenderer ar = app.getAudioRenderer();67 if (ar instanceof MultiListener){68 MultiListener ml = (MultiListener)ar;69 ml.registerSoundProcessor(writer);70 }71 return null;72 }73 };75 app.enqueue(thunk);76 }78 }