Mercurial > jmeCapture
changeset 14:e299cd89074d
creating Advanced Audio documentation.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 27 Oct 2011 21:55:51 -0700 |
parents | 6dc62c7866c2 |
children | be5ac56826be |
files | build.xml src/com/aurellem/capture/examples/AdvancedAudio.java src/com/aurellem/capture/examples/AdvancedVideo.java src/com/aurellem/capture/examples/Basic.java src/com/aurellem/capture/hello/AdvancedAudio.java src/com/aurellem/capture/hello/BasicAVRecord.java src/com/aurellem/capture/hello/HelloVideo.java |
diffstat | 7 files changed, 331 insertions(+), 312 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/build.xml Thu Oct 27 21:08:17 2011 -0700 1.2 +++ b/build.xml Thu Oct 27 21:55:51 2011 -0700 1.3 @@ -7,10 +7,16 @@ 1.4 <property name="lib" value="lib"/> 1.5 1.6 <path id="classpath"> 1.7 - <pathelement path="${lib}/jme"/> 1.8 + <pathelement path="${lib}/audio-send.jar"/> 1.9 + <pathelement path="${lib}/commons-cli.jar"/> 1.10 + <pathelement path="${lib}/jMonkeyEngine3.jar"/> 1.11 + <pathelement path="${lib}/jME3-test.jar"/> 1.12 + <pathelement path="${lib}/logback-classic.jar"/> 1.13 + <pathelement path="${lib}/logback-core.jar"/> 1.14 <pathelement path="${lib}/lwjgl.jar"/> 1.15 - <pathelement path="${lib}/xuggle/xuggle-xuggler.jar"/> 1.16 - <pathelement path="${lib}/audio-send.jar"/> 1.17 + <pathelement path="${lib}/slf4j-api.jar"/> 1.18 + <pathelement path="${lib}/xuggle-xuggler.jar"/> 1.19 + <pathelement path="${lib}/xuggle-xuggler-test.jar"/> 1.20 </path> 1.21 1.22 <target name="prepare">
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Thu Oct 27 21:55:51 2011 -0700 2.3 @@ -0,0 +1,163 @@ 2.4 +package com.aurellem.capture.examples; 2.5 + 2.6 +import java.io.File; 2.7 + 2.8 +import com.aurellem.capture.IsoTimer; 2.9 +import com.aurellem.capture.audio.MultiListener; 2.10 +import com.aurellem.capture.audio.WaveFileWriter; 2.11 +import com.jme3.app.SimpleApplication; 2.12 +import com.jme3.audio.AudioNode; 2.13 +import com.jme3.audio.Listener; 2.14 +import com.jme3.input.controls.ActionListener; 2.15 +import com.jme3.input.controls.MouseButtonTrigger; 2.16 +import com.jme3.material.Material; 2.17 +import com.jme3.math.ColorRGBA; 2.18 +import com.jme3.math.Quaternion; 2.19 +import com.jme3.math.Vector3f; 2.20 +import com.jme3.scene.Geometry; 2.21 +import com.jme3.scene.shape.Box; 2.22 +import com.jme3.system.AppSettings; 2.23 + 2.24 + 2.25 +/** 2.26 + * 2.27 + * Demonstrates advanced use of the audio capture and recording features. 2.28 + * Multiple perspectives of the same scene are simultaneously rendered to 2.29 + * different sound files. 2.30 + * 2.31 + * A key limitation of the way multiple listeners are implemented is that 2.32 + * only 3D positioning effects are realized for listeners other than the 2.33 + * main LWJGL listener. This means that audio effects such as environment 2.34 + * settings will *not* be heard on any auxiliary listeners, though sound 2.35 + * attenuation will work correctly. 2.36 + * 2.37 + * Multiple listeners as realized here might be used to make AI entities 2.38 + * that can each hear the world from their own perspective. 2.39 + * 2.40 + * @author Robert McIntyre 2.41 + * 2.42 + */ 2.43 + 2.44 +public class AdvancedAudio extends SimpleApplication { 2.45 + 2.46 + public static void main(String[] args) { 2.47 + 2.48 + AdvancedAudio app = new AdvancedAudio(); 2.49 + AppSettings settings = new AppSettings(true); 2.50 + 2.51 + settings.setAudioRenderer("Send"); 2.52 + app.setSettings(settings); 2.53 + app.setShowSettings(false); 2.54 + app.start(); 2.55 + app.setPauseOnLostFocus(false); 2.56 + } 2.57 + 2.58 + private AudioNode audio_gun; 2.59 + private AudioNode audio_nature; 2.60 + private Geometry player; 2.61 + private Listener auxListener = new Listener(); 2.62 + public File data1 = new File("/home/r/tmp/data1.wav"); 2.63 + public File data2 = new File("/home/r/tmp/data2.wav"); 2.64 + public File data3 = new File("/home/r/tmp/data3.wav"); 2.65 + 2.66 + private File makeTarget(int n){ 2.67 + return new File("/home/r/tmp/assload-" + n + ".wav"); 2.68 + } 2.69 + 2.70 + 2.71 + @Override 2.72 + public void simpleInitApp() { 2.73 + this.setTimer(new IsoTimer(60)); 2.74 + 2.75 + 2.76 + if (this.audioRenderer instanceof MultiListener){ 2.77 + MultiListener rf = (MultiListener)this.audioRenderer; 2.78 + 2.79 + for (int n = 0; n < 0; n++){ 2.80 + Listener zzz = new Listener(); 2.81 + rf.addListener(zzz); 2.82 + rf.registerSoundProcessor( 2.83 + zzz, new WaveFileWriter(makeTarget(n))); 2.84 + } 2.85 + Listener listener3 = new Listener(); 2.86 + rf.addListener(auxListener); 2.87 + rf.addListener(listener3); 2.88 + rf.registerSoundProcessor(new WaveFileWriter(data1)); 2.89 + rf.registerSoundProcessor(auxListener, new WaveFileWriter(data2)); 2.90 + rf.registerSoundProcessor(listener3, new WaveFileWriter(data3)); 2.91 + } 2.92 + flyCam.setMoveSpeed(40); 2.93 + 2.94 + /** just a blue box floating in space */ 2.95 + Box box1 = new Box(Vector3f.ZERO, 1, 1, 1); 2.96 + player = new Geometry("Player", box1); 2.97 + Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); 2.98 + mat1.setColor("Color", ColorRGBA.Blue); 2.99 + player.setMaterial(mat1); 2.100 + rootNode.attachChild(player); 2.101 + 2.102 + /** custom init methods, see below */ 2.103 + initKeys(); 2.104 + initAudio(); 2.105 + 2.106 + this.audioRenderer.playSource(audio_gun); 2.107 + 2.108 + 2.109 + 2.110 + } 2.111 + 2.112 + /** We create two audio nodes. */ 2.113 + private void initAudio() { 2.114 + //audioRenderer.setEnvironment(Environment.Cavern); 2.115 + /* gun shot sound is to be triggered by a mouse click. */ 2.116 + audio_gun = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false); 2.117 + //audio_gun = new AudioNode(assetManager, "Sound/Effects/dream.wav", false, false); 2.118 + audio_gun.setLooping(false); 2.119 + audio_gun.setVolume(2); 2.120 + audio_gun.setPositional(true); 2.121 + 2.122 + 2.123 + /* nature sound - keeps playing in a loop. */ 2.124 + audio_nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", false, false); 2.125 + audio_nature.setLooping(true); 2.126 + audio_nature.setPositional(true); 2.127 + audio_nature.setLocalTranslation(Vector3f.ZERO.clone()); 2.128 + audio_nature.setVolume(3); 2.129 + audio_nature.updateGeometricState(); 2.130 + } 2.131 + 2.132 + /** Declaring the "Shoot" action, and 2.133 + * mapping it to a trigger (mouse click). */ 2.134 + private void initKeys() { 2.135 + inputManager.addMapping("Shoot", new MouseButtonTrigger(0)); 2.136 + inputManager.addListener(actionListener, "Shoot"); 2.137 + } 2.138 + 2.139 + /** Defining the "Shoot" action: Play a gun sound. */ 2.140 + private ActionListener actionListener = new ActionListener() { 2.141 + @Override 2.142 + public void onAction(String name, boolean keyPressed, float tpf) { 2.143 + if (name.equals("Shoot") && !keyPressed) { 2.144 + audioRenderer.playSource(audio_gun); // play once! 2.145 + } 2.146 + } 2.147 + }; 2.148 + 2.149 + /** Move the listener with the camera - for 3D audio. */ 2.150 + @Override 2.151 + public void simpleUpdate(float tpf) { 2.152 + Vector3f loc = cam.getLocation(); 2.153 + Quaternion rot = cam.getRotation(); 2.154 + listener.setLocation(loc); 2.155 + listener.setRotation(rot); 2.156 + auxListener.setLocation(loc); 2.157 + auxListener.setRotation(rot); 2.158 + if (audio_gun.getStatus() == AudioNode.Status.Stopped){ 2.159 + System.out.println("I'm Stopped!"); 2.160 + this.requestClose(false); 2.161 + } 2.162 + 2.163 + 2.164 + } 2.165 + 2.166 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/com/aurellem/capture/examples/AdvancedVideo.java Thu Oct 27 21:55:51 2011 -0700 3.3 @@ -0,0 +1,75 @@ 3.4 +package com.aurellem.capture.examples; 3.5 + 3.6 +import java.io.File; 3.7 +import java.io.IOException; 3.8 + 3.9 +import com.aurellem.capture.Capture; 3.10 +import com.aurellem.capture.IsoTimer; 3.11 +import com.aurellem.capture.video.AbstractVideoRecorder; 3.12 +import com.jme3.app.SimpleApplication; 3.13 +import com.jme3.material.Material; 3.14 +import com.jme3.math.ColorRGBA; 3.15 +import com.jme3.math.Vector3f; 3.16 +import com.jme3.scene.Geometry; 3.17 +import com.jme3.scene.shape.Box; 3.18 + 3.19 +/** Recording Video from an application suitable for upload to youtube.*/ 3.20 +public class AdvancedVideo extends SimpleApplication { 3.21 + 3.22 + /*File staticVideo = 3.23 + new File("/home/r/bullshit.avi"); 3.24 + */ 3.25 + File movingVideo = 3.26 + new File("/home/r/tmp/bullshit2.flv"); 3.27 + 3.28 + AbstractVideoRecorder movingRecorder ; 3.29 + 3.30 + public static void main(String[] args){ 3.31 + AdvancedVideo app = new AdvancedVideo(); 3.32 + app.start(); 3.33 + } 3.34 + 3.35 + public void initVideo(){ 3.36 + this.setTimer(new IsoTimer(60)); 3.37 + /*try{ 3.38 + // set the timer to 30fps lock-step 3.39 + this.setTimer(new IsoTimer(30)); 3.40 + 3.41 + //ViewPort compositeViewPort = renderManager.createFinalView("composite", cam); 3.42 + //compositeViewPort.attachScene(this.rootNode); 3.43 + //compositeViewPort.attachScene(this.guiNode); 3.44 + this.viewPort.setClearFlags(true, true, true); 3.45 + this.viewPort.setBackgroundColor(ColorRGBA.Black); 3.46 + movingRecorder = new AVIVideoRecorder(movingVideo); 3.47 + this.stateManager.attach(movingRecorder); 3.48 + this.viewPort.addFinalProcessor(movingRecorder); 3.49 + this.viewPort.attachScene(this.guiNode); 3.50 + 3.51 + }catch (IOException e) { 3.52 + e.printStackTrace();} 3.53 + */ 3.54 + try {Capture.captureVideo(this, movingVideo);} 3.55 + catch (IOException e) {e.printStackTrace();} 3.56 + 3.57 + } 3.58 + protected Geometry player; 3.59 + 3.60 + public void simpleInitApp() { 3.61 + initVideo(); // begin recording! 3.62 + /** this blue box is our player character */ 3.63 + Box b = new Box(Vector3f.ZERO, 1, 1, 1); 3.64 + player = new Geometry("blue cube", b); 3.65 + Material mat = new Material(assetManager, 3.66 + "Common/MatDefs/Misc/Unshaded.j3md"); 3.67 + mat.setColor("Color", ColorRGBA.Blue); 3.68 + player.setMaterial(mat); 3.69 + rootNode.attachChild(player); 3.70 + } 3.71 + 3.72 + /* Use the main event loop to trigger repeating actions. */ 3.73 + public void simpleUpdate(float tpf) { 3.74 + // make the player rotate: 3.75 + player.rotate(0, 2*tpf, 0); 3.76 + } 3.77 + 3.78 +} 3.79 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/com/aurellem/capture/examples/Basic.java Thu Oct 27 21:55:51 2011 -0700 4.3 @@ -0,0 +1,84 @@ 4.4 +package com.aurellem.capture.examples; 4.5 + 4.6 +import java.io.File; 4.7 +import java.io.IOException; 4.8 + 4.9 +import jme3test.helloworld.HelloAudio; 4.10 +import jme3test.helloworld.HelloJME3; 4.11 +import jme3test.niftygui.TestNiftyExamples; 4.12 +import jme3test.water.TestPostWater; 4.13 + 4.14 +import com.aurellem.capture.Capture; 4.15 +import com.aurellem.capture.IsoTimer; 4.16 +import com.jme3.app.SimpleApplication; 4.17 + 4.18 + 4.19 +/** 4.20 + * 4.21 + * Demonstrates how to use basic Audio/Video capture with a jMonkeyEngine 4.22 + * application. You can use these techniques to make high quality cutscenes 4.23 + * or demo videos, even on very slow laptops. 4.24 + * 4.25 + * @author Robert McIntyre 4.26 + * 4.27 + */ 4.28 + 4.29 +public class Basic { 4.30 + 4.31 + public static void basicVideo() throws IOException{ 4.32 + File video = File.createTempFile("HelloJME3", ".avi"); 4.33 + System.out.println("Saving video to: " + video.getCanonicalPath()); 4.34 + SimpleApplication app = new HelloJME3(); 4.35 + app.setTimer(new IsoTimer(60)); 4.36 + app.setShowSettings(false); 4.37 + 4.38 + Capture.captureVideo(app, video); 4.39 + app.start(); 4.40 + } 4.41 + 4.42 + public static void basicVideoGUI() throws IOException { 4.43 + File video = File.createTempFile("GUI", ".avi"); 4.44 + System.out.println("Saving video to: " + video.getCanonicalPath()); 4.45 + SimpleApplication app = new TestNiftyExamples(); 4.46 + app.setTimer(new IsoTimer(60)); 4.47 + app.setShowSettings(false); 4.48 + 4.49 + Capture.captureVideo(app, video); 4.50 + app.start(); 4.51 + } 4.52 + 4.53 + public static void basicAudio() throws IOException{ 4.54 + File audio = File.createTempFile("BasicAudio", ".wav"); 4.55 + System.out.println("Saving audio to: " + audio.getCanonicalPath()); 4.56 + SimpleApplication app = new HelloAudio(); 4.57 + app.setTimer(new IsoTimer(60)); 4.58 + app.setShowSettings(false); 4.59 + 4.60 + // you will not hear the audio while it is being captured. 4.61 + Capture.captureAudio(app, audio); 4.62 + 4.63 + app.start(); 4.64 + } 4.65 + 4.66 + public static void basicAudioVideo() throws IOException{ 4.67 + File video = new File("/home/r/tmp/basicVideo.avi"); 4.68 + File audio = new File("/home/r/tmp/basicAudio.wav"); 4.69 + 4.70 + SimpleApplication app = new TestPostWater(); 4.71 + app.setTimer(new IsoTimer(60)); 4.72 + app.setShowSettings(false); 4.73 + 4.74 + Capture.captureVideo(app, video); 4.75 + Capture.captureAudio(app, audio); 4.76 + 4.77 + app.start(); 4.78 + } 4.79 + 4.80 + 4.81 + public static void main(String[] ignore) throws IOException{ 4.82 + basicVideo(); 4.83 + basicVideoGUI(); 4.84 + basicAudio(); 4.85 + basicAudioVideo(); 4.86 + } 4.87 +}
5.1 --- a/src/com/aurellem/capture/hello/AdvancedAudio.java Thu Oct 27 21:08:17 2011 -0700 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,158 +0,0 @@ 5.4 -package com.aurellem.capture.hello; 5.5 - 5.6 -import java.io.File; 5.7 - 5.8 -import com.aurellem.capture.IsoTimer; 5.9 -import com.aurellem.capture.audio.MultiListener; 5.10 -import com.aurellem.capture.audio.WaveFileWriter; 5.11 -import com.jme3.app.SimpleApplication; 5.12 -import com.jme3.audio.AudioNode; 5.13 -import com.jme3.audio.Listener; 5.14 -import com.jme3.input.controls.ActionListener; 5.15 -import com.jme3.input.controls.MouseButtonTrigger; 5.16 -import com.jme3.material.Material; 5.17 -import com.jme3.math.ColorRGBA; 5.18 -import com.jme3.math.Quaternion; 5.19 -import com.jme3.math.Vector3f; 5.20 -import com.jme3.scene.Geometry; 5.21 -import com.jme3.scene.shape.Box; 5.22 -import com.jme3.system.AppSettings; 5.23 - 5.24 - 5.25 -/** 5.26 - * 5.27 - * 5.28 - * 5.29 - * @author Robert McIntyre 5.30 - * 5.31 - */ 5.32 - 5.33 -public class AdvancedAudio extends SimpleApplication { 5.34 - 5.35 - 5.36 - 5.37 - public static void main(String[] args) { 5.38 - 5.39 - // Logger.getLogger("com.jme3").setLevel(Level.OFF); 5.40 - 5.41 - AdvancedAudio app = new AdvancedAudio(); 5.42 - AppSettings settings = new AppSettings(true); 5.43 - 5.44 - settings.setAudioRenderer("Send"); 5.45 - app.setSettings(settings); 5.46 - app.setShowSettings(false); 5.47 - app.start(); 5.48 - app.setPauseOnLostFocus(false); 5.49 - } 5.50 - 5.51 - 5.52 - 5.53 - private AudioNode audio_gun; 5.54 - private AudioNode audio_nature; 5.55 - private Geometry player; 5.56 - private Listener auxListener = new Listener(); 5.57 - public File data1 = new File("/home/r/tmp/data1.wav"); 5.58 - public File data2 = new File("/home/r/tmp/data2.wav"); 5.59 - public File data3 = new File("/home/r/tmp/data3.wav"); 5.60 - 5.61 - private File makeTarget(int n){ 5.62 - return new File("/home/r/tmp/assload-" + n + ".wav"); 5.63 - } 5.64 - 5.65 - 5.66 - @Override 5.67 - public void simpleInitApp() { 5.68 - this.setTimer(new IsoTimer(60)); 5.69 - 5.70 - 5.71 - if (this.audioRenderer instanceof MultiListener){ 5.72 - MultiListener rf = (MultiListener)this.audioRenderer; 5.73 - 5.74 - for (int n = 0; n < 0; n++){ 5.75 - Listener zzz = new Listener(); 5.76 - rf.addListener(zzz); 5.77 - rf.registerSoundProcessor( 5.78 - zzz, new WaveFileWriter(makeTarget(n))); 5.79 - } 5.80 - Listener listener3 = new Listener(); 5.81 - rf.addListener(auxListener); 5.82 - rf.addListener(listener3); 5.83 - rf.registerSoundProcessor(new WaveFileWriter(data1)); 5.84 - rf.registerSoundProcessor(auxListener, new WaveFileWriter(data2)); 5.85 - rf.registerSoundProcessor(listener3, new WaveFileWriter(data3)); 5.86 - } 5.87 - flyCam.setMoveSpeed(40); 5.88 - 5.89 - /** just a blue box floating in space */ 5.90 - Box box1 = new Box(Vector3f.ZERO, 1, 1, 1); 5.91 - player = new Geometry("Player", box1); 5.92 - Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); 5.93 - mat1.setColor("Color", ColorRGBA.Blue); 5.94 - player.setMaterial(mat1); 5.95 - rootNode.attachChild(player); 5.96 - 5.97 - /** custom init methods, see below */ 5.98 - initKeys(); 5.99 - initAudio(); 5.100 - 5.101 - this.audioRenderer.playSource(audio_gun); 5.102 - 5.103 - 5.104 - 5.105 - } 5.106 - 5.107 - /** We create two audio nodes. */ 5.108 - private void initAudio() { 5.109 - //audioRenderer.setEnvironment(Environment.Cavern); 5.110 - /* gun shot sound is to be triggered by a mouse click. */ 5.111 - audio_gun = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false); 5.112 - //audio_gun = new AudioNode(assetManager, "Sound/Effects/dream.wav", false, false); 5.113 - audio_gun.setLooping(false); 5.114 - audio_gun.setVolume(2); 5.115 - audio_gun.setPositional(true); 5.116 - 5.117 - 5.118 - /* nature sound - keeps playing in a loop. */ 5.119 - audio_nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", false, false); 5.120 - audio_nature.setLooping(true); 5.121 - audio_nature.setPositional(true); 5.122 - audio_nature.setLocalTranslation(Vector3f.ZERO.clone()); 5.123 - audio_nature.setVolume(3); 5.124 - audio_nature.updateGeometricState(); 5.125 - } 5.126 - 5.127 - /** Declaring the "Shoot" action, and 5.128 - * mapping it to a trigger (mouse click). */ 5.129 - private void initKeys() { 5.130 - inputManager.addMapping("Shoot", new MouseButtonTrigger(0)); 5.131 - inputManager.addListener(actionListener, "Shoot"); 5.132 - } 5.133 - 5.134 - /** Defining the "Shoot" action: Play a gun sound. */ 5.135 - private ActionListener actionListener = new ActionListener() { 5.136 - @Override 5.137 - public void onAction(String name, boolean keyPressed, float tpf) { 5.138 - if (name.equals("Shoot") && !keyPressed) { 5.139 - audioRenderer.playSource(audio_gun); // play once! 5.140 - } 5.141 - } 5.142 - }; 5.143 - 5.144 - /** Move the listener with the camera - for 3D audio. */ 5.145 - @Override 5.146 - public void simpleUpdate(float tpf) { 5.147 - Vector3f loc = cam.getLocation(); 5.148 - Quaternion rot = cam.getRotation(); 5.149 - listener.setLocation(loc); 5.150 - listener.setRotation(rot); 5.151 - auxListener.setLocation(loc); 5.152 - auxListener.setRotation(rot); 5.153 - if (audio_gun.getStatus() == AudioNode.Status.Stopped){ 5.154 - System.out.println("I'm Stopped!"); 5.155 - this.requestClose(false); 5.156 - } 5.157 - 5.158 - 5.159 - } 5.160 - 5.161 -}
6.1 --- a/src/com/aurellem/capture/hello/BasicAVRecord.java Thu Oct 27 21:08:17 2011 -0700 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,76 +0,0 @@ 6.4 -package com.aurellem.capture.hello; 6.5 - 6.6 -import java.io.File; 6.7 -import java.io.IOException; 6.8 - 6.9 -import jme3test.helloworld.HelloAudio; 6.10 -import jme3test.helloworld.HelloJME3; 6.11 -import jme3test.niftygui.TestNiftyExamples; 6.12 -import jme3test.water.TestPostWater; 6.13 - 6.14 -import com.aurellem.capture.Capture; 6.15 -import com.aurellem.capture.IsoTimer; 6.16 -import com.jme3.app.SimpleApplication; 6.17 - 6.18 - 6.19 -/** 6.20 - * 6.21 - * Demonstrates how to use basic Audio/Video capture with a jMonkeyEngine 6.22 - * application. 6.23 - * 6.24 - * @author Robert McIntyre 6.25 - * 6.26 - */ 6.27 - 6.28 -public class BasicAVRecord { 6.29 - 6.30 - public static void basicVideo() throws IOException{ 6.31 - File video = File.createTempFile("HelloJME3", ".avi"); 6.32 - System.out.println("Saving video to: " + video.getCanonicalPath()); 6.33 - SimpleApplication app = new HelloJME3(); 6.34 - app.setTimer(new IsoTimer(60)); 6.35 - 6.36 - Capture.captureVideo(app, video); 6.37 - app.start(); 6.38 - } 6.39 - 6.40 - public static void basicVideoGUI() throws IOException { 6.41 - File video = File.createTempFile("GUI", ".avi"); 6.42 - System.out.println("Saving video to: " + video.getCanonicalPath()); 6.43 - SimpleApplication app = new TestNiftyExamples(); 6.44 - app.setTimer(new IsoTimer(60)); 6.45 - 6.46 - Capture.captureVideo(app, video); 6.47 - app.start(); 6.48 - } 6.49 - 6.50 - public static void basicAudio() throws IOException{ 6.51 - File audio = File.createTempFile("BasicAudio", ".wav"); 6.52 - System.out.println("Saving audio to: " + audio.getCanonicalPath()); 6.53 - SimpleApplication app = new HelloAudio(); 6.54 - app.setTimer(new IsoTimer(60)); 6.55 - 6.56 - // you will not hear the audio while it is being captured. 6.57 - Capture.captureAudio(app, audio); 6.58 - 6.59 - app.start(); 6.60 - } 6.61 - 6.62 - public static void basicAudioVideo() throws IOException{ 6.63 - File video = new File("/home/r/tmp/basicVideo.avi"); 6.64 - File audio = new File("/home/r/tmp/basicAudio.wav"); 6.65 - 6.66 - SimpleApplication app = new TestPostWater(); 6.67 - app.setTimer(new IsoTimer(60)); 6.68 - 6.69 - Capture.captureVideo(app, video); 6.70 - Capture.captureAudio(app, audio); 6.71 - 6.72 - app.start(); 6.73 - } 6.74 - 6.75 - 6.76 - public static void main(String[] ignore) throws IOException{ 6.77 - basicAudio(); 6.78 - } 6.79 -}
7.1 --- a/src/com/aurellem/capture/hello/HelloVideo.java Thu Oct 27 21:08:17 2011 -0700 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,75 +0,0 @@ 7.4 -package com.aurellem.capture.hello; 7.5 - 7.6 -import java.io.File; 7.7 -import java.io.IOException; 7.8 - 7.9 -import com.aurellem.capture.Capture; 7.10 -import com.aurellem.capture.IsoTimer; 7.11 -import com.aurellem.capture.video.AbstractVideoRecorder; 7.12 -import com.jme3.app.SimpleApplication; 7.13 -import com.jme3.material.Material; 7.14 -import com.jme3.math.ColorRGBA; 7.15 -import com.jme3.math.Vector3f; 7.16 -import com.jme3.scene.Geometry; 7.17 -import com.jme3.scene.shape.Box; 7.18 - 7.19 -/** Recording Video from an application suitable for upload to youtube.*/ 7.20 -public class HelloVideo extends SimpleApplication { 7.21 - 7.22 - /*File staticVideo = 7.23 - new File("/home/r/bullshit.avi"); 7.24 - */ 7.25 - File movingVideo = 7.26 - new File("/home/r/tmp/bullshit2.flv"); 7.27 - 7.28 - AbstractVideoRecorder movingRecorder ; 7.29 - 7.30 - public static void main(String[] args){ 7.31 - HelloVideo app = new HelloVideo(); 7.32 - app.start(); 7.33 - } 7.34 - 7.35 - public void initVideo(){ 7.36 - this.setTimer(new IsoTimer(60)); 7.37 - /*try{ 7.38 - // set the timer to 30fps lock-step 7.39 - this.setTimer(new IsoTimer(30)); 7.40 - 7.41 - //ViewPort compositeViewPort = renderManager.createFinalView("composite", cam); 7.42 - //compositeViewPort.attachScene(this.rootNode); 7.43 - //compositeViewPort.attachScene(this.guiNode); 7.44 - this.viewPort.setClearFlags(true, true, true); 7.45 - this.viewPort.setBackgroundColor(ColorRGBA.Black); 7.46 - movingRecorder = new AVIVideoRecorder(movingVideo); 7.47 - this.stateManager.attach(movingRecorder); 7.48 - this.viewPort.addFinalProcessor(movingRecorder); 7.49 - this.viewPort.attachScene(this.guiNode); 7.50 - 7.51 - }catch (IOException e) { 7.52 - e.printStackTrace();} 7.53 - */ 7.54 - try {Capture.captureVideo(this, movingVideo);} 7.55 - catch (IOException e) {e.printStackTrace();} 7.56 - 7.57 - } 7.58 - protected Geometry player; 7.59 - 7.60 - public void simpleInitApp() { 7.61 - initVideo(); // begin recording! 7.62 - /** this blue box is our player character */ 7.63 - Box b = new Box(Vector3f.ZERO, 1, 1, 1); 7.64 - player = new Geometry("blue cube", b); 7.65 - Material mat = new Material(assetManager, 7.66 - "Common/MatDefs/Misc/Unshaded.j3md"); 7.67 - mat.setColor("Color", ColorRGBA.Blue); 7.68 - player.setMaterial(mat); 7.69 - rootNode.attachChild(player); 7.70 - } 7.71 - 7.72 - /* Use the main event loop to trigger repeating actions. */ 7.73 - public void simpleUpdate(float tpf) { 7.74 - // make the player rotate: 7.75 - player.rotate(0, 2*tpf, 0); 7.76 - } 7.77 - 7.78 -} 7.79 \ No newline at end of file