# HG changeset patch # User Robert McIntyre # Date 1342718935 18000 # Node ID 302d5e9ad120ee4d9593487d3a1f05687dee4634 # Parent 30cea3f0f30aa81f045a6cecf717fe6ee90757ab adjust format diff -r 30cea3f0f30a -r 302d5e9ad120 build.xml --- a/build.xml Tue Feb 28 11:17:04 2012 -0600 +++ b/build.xml Thu Jul 19 12:28:55 2012 -0500 @@ -16,10 +16,12 @@ + + @@ -54,6 +56,9 @@ + + + diff -r 30cea3f0f30a -r 302d5e9ad120 src/ca/randelshofer/AVIOutputStream.java --- a/src/ca/randelshofer/AVIOutputStream.java Tue Feb 28 11:17:04 2012 -0600 +++ b/src/ca/randelshofer/AVIOutputStream.java Thu Jul 19 12:28:55 2012 -0500 @@ -1,7 +1,7 @@ /** * @(#)AVIOutputStream.java 1.5.1 2011-01-17 * - * Copyright (c) 2008-2011 Werner Randelshofer, Immensee, Switzerland. +* Copyright (c) 2008-2011 Werner Randelshofer, Immensee, Switzerland. * All rights reserved. * * You may not use, copy or modify this file, except in compliance with the @@ -1337,7 +1337,7 @@ // Specifies an indicator of the quality of the data in the stream. // Quality is represented as a number between 0 and 10,000. // For compressed data, this typically represents the value of the - // quality parameter passed to the compression software. If set to –1, + // quality parameter passed to the compression software. If set to -1, // drivers use the default quality value. d.writeUInt(0); // dwSampleSize diff -r 30cea3f0f30a -r 302d5e9ad120 src/ca/randelshofer/ImageOutputStreamAdapter.java --- a/src/ca/randelshofer/ImageOutputStreamAdapter.java Tue Feb 28 11:17:04 2012 -0600 +++ b/src/ca/randelshofer/ImageOutputStreamAdapter.java Thu Jul 19 12:28:55 2012 -0500 @@ -1,7 +1,7 @@ /* * @(#)ImageOutputStreamAdapter.java 1.1 2011-01-07 * - * Copyright © 2010 Werner Randelshofer, Immensee, Switzerland. + * Copyright (c) 2010 Werner Randelshofer, Immensee, Switzerland. * All rights reserved. * * You may not use, copy or modify this file, except in compliance with the diff -r 30cea3f0f30a -r 302d5e9ad120 src/ca/randelshofer/SeekableByteArrayOutputStream.java --- a/src/ca/randelshofer/SeekableByteArrayOutputStream.java Tue Feb 28 11:17:04 2012 -0600 +++ b/src/ca/randelshofer/SeekableByteArrayOutputStream.java Thu Jul 19 12:28:55 2012 -0500 @@ -1,7 +1,7 @@ /* * @(#)SeekableByteArrayOutputStream.java 1.0 2010-12-27 * - * Copyright © 2010 Werner Randelshofer, Immensee, Switzerland. + * Copyright (c) 2010 Werner Randelshofer, Immensee, Switzerland. * All rights reserved. * * You may not use, copy or modify this file, except in compliance with the diff -r 30cea3f0f30a -r 302d5e9ad120 src/com/aurellem/capture/Capture.java --- a/src/com/aurellem/capture/Capture.java Tue Feb 28 11:17:04 2012 -0600 +++ b/src/com/aurellem/capture/Capture.java Thu Jul 19 12:28:55 2012 -0500 @@ -18,19 +18,21 @@ import com.jme3.system.JmeSystem; /** - * Use the methods in this class for capturing consistent, high quality video - * and audio from a jMonkeyEngine3 application. To capture audio or video do - * the following: + * Use the methods in this class for capturing consistent, + * high quality video and audio from a jMonkeyEngine3 + * application. To capture audio or video do the following: * - * 1.) Set your application's timer to an IsoTimer. Create the IsoTimer with the - * desired video frames-per-second. + * 1.) Set your application's timer to an IsoTimer. Create + * the IsoTimer with the desired video + * frames-per-second. * - * 2.) Call captureAudio and/or captureVideo on the Application as desired - * before starting the Application. + * 2.) Call captureAudio and/or captureVideo on the + * Application as desired before starting the + * Application. * - * See the Basic and Advanced demos in the examples section for more - * information. If you have any trouble, please PM me on the jMonkeyEngine - * forums. My username is bortreb. + * See the Basic and Advanced demos in the examples section + * for more information. If you have any trouble, please PM + * me on the jMonkeyEngine forums. My username is bortreb. * * @author Robert McIntyre */ @@ -38,57 +40,69 @@ public class Capture { /** - * Use this function to capture video from your application. You - * specify the framerate at which the video will be recording by setting - * the Application's timer to an IsoTimer created with the desired + * Use this function to capture video from your + * application. You specify the framerate at which the + * video will be recording by setting the Application's + * timer to an IsoTimer created with the desired * frames-per-second. * - * There are three ways to record and they are selected by the - * properties of the file that you specify. + * There are three ways to record and they are selected + * by the properties of the file that you specify. * - * 1.) (Preferred) If you supply an empty directory as the file, then - * the video will be saved as a sequence of .png files, one file per - * frame. The files start at 0000000.png and increment from there. - * You can then combine the frames into your preferred - * container/codec. If the directory is not empty, then writing - * video frames to it will fail, and nothing will be written. + * 1.) (Preferred) If you supply an empty directory as + * the file, then the video will be saved as a + * sequence of .png files, one file per frame. The + * files start at 0000000.png and increment from + * there. You can then combine the frames into your + * preferred container/codec. If the directory is + * not empty, then writing video frames to it will + * fail, and nothing will be written. * - * 2.) If the filename ends in ".avi" then the frames will be encoded as - * a RAW stream inside an AVI 1.0 container. The resulting file - * will be quite large and you will probably want to re-encode it to - * your preferred container/codec format. Be advised that some - * video payers cannot process AVI with a RAW stream, and that AVI - * 1.0 files generated by this method that exceed 2.0GB are invalid - * according to the AVI 1.0 spec (but many programs can still deal - * with them.) Thanks to Werner Randelshofer for his excellent work - * which made AVI file writer option possible. + * 2.) If the filename ends in ".avi" then the frames + * will be encoded as a RAW stream inside an AVI 1.0 + * container. The resulting file will be quite + * large and you will probably want to re-encode it + * to your preferred container/codec format. Be + * advised that some video payers cannot process AVI + * with a RAW stream, and that AVI 1.0 files + * generated by this method that exceed 2.0GB are + * invalid according to the AVI 1.0 spec (but many + * programs can still deal with them.) Thanks to + * Werner Randelshofer for his excellent work which + * made AVI file writer option possible. * - * 3.) Any non-directory file ending in anything other than ".avi" will - * be processed through Xuggle. Xuggle provides the option to use - * many codecs/containers, but you will have to install it on your - * system yourself in order to use this option. Please visit - * http://www.xuggle.com/ to learn how to do this. + * 3.) Any non-directory file ending in anything other + * than ".avi" will be processed through Xuggle. + * Xuggle provides the option to use many + * codecs/containers, but you will have to install + * it on your system yourself in order to use this + * option. Please visit http://www.xuggle.com/ to + * learn how to do this. * * @param app The Application from which you wish to record Video. * @param file The file to which the video will be captured. * @throws IOException */ - public static void captureVideo(final Application app, final File file) throws IOException{ + public static void captureVideo + (final Application app, final File file) throws IOException{ final AbstractVideoRecorder videoRecorder; if (file.getCanonicalPath().endsWith(".avi")){ videoRecorder = new AVIVideoRecorder(file);} else if (file.isDirectory()){ videoRecorder = new FileVideoRecorder(file);} - else { videoRecorder = new XuggleVideoRecorder(file);} + else { + videoRecorder = new XuggleVideoRecorder(file); + } Callable thunk = new Callable(){ public Object call(){ ViewPort viewPort = app.getRenderManager() - .createPostView("aurellem video record", app.getCamera()); + .createPostView("aurellem video record", + app.getCamera()); viewPort.setClearFlags(false, false, false); @@ -107,28 +121,34 @@ /** - * Use this function to capture audio from your application. Audio data - * will be saved in linear PCM format at 44,100 hertz in the wav container - * format to the file that you specify. + * Use this function to capture audio from your + * application. Audio data will be saved in linear PCM + * format at 44,100 hertz in the wav container format to + * the file that you specify. * - * Note that you *have* to use an IsoTimer for your Application's timer - * while recording audio or the recording will fail. Also ensure that your - * IsoTimer obeys the following constraints: + * Note that you *have* to use an IsoTimer for your + * Application's timer while recording audio or the + * recording will fail. Also ensure that your IsoTimer + * obeys the following constraints: * - * 1.) The frames-per-second value of the IsoTimer cannot be lower than 10 - * frames-per-second. + * 1.) The frames-per-second value of the IsoTimer + * cannot be lower than 10 frames-per-second. * - * 2.) The frames-per-second value of the IsoTimer must evenly divide - * 44,100. + * 2.) The frames-per-second value of the IsoTimer must + * evenly divide 44,100. * - * @param app The Application from which you wish to record Audio. - * @param file the target file to which you want to record audio data. + * @param app The Application from which you wish to + * record Audio. + * @param file the target file to which you want to + * record audio data. * @throws IOException */ - public static void captureAudio(final Application app, final File file) throws IOException{ + public static void captureAudio + (final Application app, final File file) throws IOException{ AppSettings settings = null; - if (app.getContext() != null){settings = app.getContext().getSettings();} + if (app.getContext() != null){ + settings = app.getContext().getSettings();} if (settings == null){settings = new AppSettings(true);} settings.setAudioRenderer("Send"); app.setSettings(settings); diff -r 30cea3f0f30a -r 302d5e9ad120 src/com/aurellem/capture/audio/WaveFileWriter.java --- a/src/com/aurellem/capture/audio/WaveFileWriter.java Tue Feb 28 11:17:04 2012 -0600 +++ b/src/com/aurellem/capture/audio/WaveFileWriter.java Thu Jul 19 12:28:55 2012 -0500 @@ -21,37 +21,38 @@ public class WaveFileWriter implements SoundProcessor { - public File targetFile; - private WaveAudioOutputStream wao; - private TDataOutputStream tos; - private boolean initialized = false; + public File targetFile; + private WaveAudioOutputStream wao; + private TDataOutputStream tos; + private boolean initialized = false; - public WaveFileWriter(File targetFile) throws FileNotFoundException{ - tos = new TNonSeekableDataOutputStream( - new FileOutputStream(targetFile)); - } + public WaveFileWriter(File targetFile) + throws FileNotFoundException{ + tos = new TNonSeekableDataOutputStream + (new FileOutputStream(targetFile)); + } - public void init(AudioFormat format){ - wao = new WaveAudioOutputStream(format,AudioSystem.NOT_SPECIFIED, tos); + public void init(AudioFormat format){ + wao = new WaveAudioOutputStream(format,AudioSystem.NOT_SPECIFIED, tos); + } + + public void process(ByteBuffer audioSamples, int numSamples, AudioFormat format) { + audioSamples.clear(); + if (!initialized){ + init(format); + initialized = true; } - public void process(ByteBuffer audioSamples, int numSamples, AudioFormat format) { - audioSamples.clear(); - if (!initialized){ - init(format); - initialized = true; - } - - byte[] data = new byte[numSamples]; - audioSamples.get(data, 0, numSamples); - try {wao.write(data, 0, numSamples);} - catch (IOException e) {e.printStackTrace();} - } + byte[] data = new byte[numSamples]; + audioSamples.get(data, 0, numSamples); + try {wao.write(data, 0, numSamples);} + catch (IOException e) {e.printStackTrace();} + } - public void cleanup() { - try {wao.close();} - catch (IOException e) {e.printStackTrace();} - } + public void cleanup() { + try {wao.close();} + catch (IOException e) {e.printStackTrace();} + } } diff -r 30cea3f0f30a -r 302d5e9ad120 src/com/aurellem/capture/video/XuggleVideoRecorder.java --- a/src/com/aurellem/capture/video/XuggleVideoRecorder.java Tue Feb 28 11:17:04 2012 -0600 +++ b/src/com/aurellem/capture/video/XuggleVideoRecorder.java Thu Jul 19 12:28:55 2012 -0500 @@ -19,40 +19,43 @@ public class XuggleVideoRecorder extends AbstractVideoRecorder{ - IMediaWriter writer; - BufferedImage frame; - int videoChannel = 0; - long currentTimeStamp = 0; - boolean videoReady = false; + + IMediaWriter writer; + BufferedImage frame; + int videoChannel = 0; + long currentTimeStamp = 0; + boolean videoReady = false; + + public XuggleVideoRecorder(File output) + throws IOException {super(output);} - public XuggleVideoRecorder(File output) throws IOException {super(output);} + public void initVideo(){ + this.frame = new BufferedImage( + width, height, + BufferedImage.TYPE_3BYTE_BGR); + this.writer = ToolFactory.makeWriter(this.targetFileName); + writer.addVideoStream(videoChannel, + 0, IRational.make(fps), + width, height); + this.videoReady = true; + } - public void initVideo(){ - this.frame = new BufferedImage( - width, height, - BufferedImage.TYPE_3BYTE_BGR); - this.writer = ToolFactory.makeWriter(this.targetFileName); - writer.addVideoStream(videoChannel, - 0, IRational.make(fps), - width, height); - this.videoReady = true; - } - - public void record(BufferedImage rawFrame) { - if (!this.videoReady){initVideo();} - // convert the Image into the form that Xuggle likes. - this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); - writer.encodeVideo(videoChannel, - frame, - currentTimeStamp, TimeUnit.NANOSECONDS); + public void record(BufferedImage rawFrame) { + if (!this.videoReady){initVideo();} + // convert the Image into the form that Xuggle likes. + this.frame.getGraphics().drawImage(rawFrame, 0, 0, null); + writer.encodeVideo(videoChannel, + frame, + currentTimeStamp, TimeUnit.NANOSECONDS); - currentTimeStamp += (long) (1000000000.0 / fps); - } + currentTimeStamp += (long) (1000000000.0 / fps); + } - public void finish() { - writer.close(); - } + public void finish() { + writer.close(); + } + }