JMF 2.1.1 audio capture from an applet

I'm trying to write an implementation of a soft phone as an applet. All I want the user to do is download the JRE and browse to my web page. I've included the JMF jar files in my applet and signed it. My problem is that even though the applet is signed, I still can't capture audio from it. I keep getting "java.lang.RuntimeException: No permission to capture from applets." Is it possible to write an applet that can capture audio without requiring the user to install the JMF or modify their policy files? I am using JMF 2.1.1e and JRE 1.6.0_02
Thanks,
Phil

Well, there's lots of bad news, and some good news.
Applets have always been problematic, and are
becoming more so by the quarter. That is entirely
without putting JMF into the mix.
As you may have figured by now, JMF will not work
in applets unless it has already been installed,
even then, the installer will ask during installation
if the end-user wishes to 'Allow applet capture' and
that defaults to false.
A far better alternative for launching JMF for a
project that comes from the internet, is using
JWS (Java web start) to launch an application (or
applet) as a free floating GUI. I had an example
of this up at my JavaSaver site, but unfortunately
JavaSaver is offline for the time being.
In any case, I think you have it mostly wrong by
looking to the JMF, since JavaSound was introduced
into the J2SE around Java 1.3.
I recommend looking to JWS to launch a trusted
Java application directly onto screen, that uses
the JavaSound API for the recording.
I have an example here, of a sound based JWS app.
<http://www.physci.org/sound/audiotrace.html>
The source of an early version is also available..
<http://www.physci.org/test/oscilloscope/AudioTrace.java>
Other tests I did (not finished) indicated it
was quite possible to capture sound and record
it to disk (AudioTrace makes no attempt to store
the audio signal, just plot it on-screen) using
the J2SE sound API.

Similar Messages

  • Audio Capture from DV Tape

    I've reviewed many posts here about audio capture but, I am unable to figure out what the "trick" is to capturing audio alone with the video using the new iMovie. I'm connected via Firewire and I'm able to view the video in capture mode but, I hear no sound. I've checked iMovie Preferences and System Preferences and everything seems to be OK there.
    Is this the way this new version of this program functions? I wish I didn't have to post a msg here because, I'm trying to read the previous post and trying anything that seems to pertain to my issue without the desired results.
    Can someone please shed some light on what's going on with this function of this program?

    I assume you are wanting to hear the audio as you are importing and not that you have no audio once it is imported.
    imovie 08 doesn't play audio while importing. While you are using tape (that imports in real time) imovie now imports from a variety of different types of camera such as AVCHD (which isn't imported at real time. Therefore it is no longer logical to playback audio on import.

  • Capture from an Applet, No device message, Help me !!!

    My applet can capture and save the image.
    It is really working very well through applet viewer (1.4.2),
    but why.. why it says "No device" message on the web browser (IE 6.0) ?
    Please help me...

    hi;
    i have the same problem too.
    did u find a solution for that problem, if so could u share ur knowledge?
    my email : [email protected]

  • Lost audio capture 'what you hear' from conexant

    I have an HP Pavilion DV2278ea laptop running Vista 32bit and have all OS updates apart from those announced in the last few weeks. I recently upgraded the software for the Conexant High Definition onboard sound card to the latest August 08 version 4.36.7.60 C. All seemed fine until I came to do an audio capture from an internet stream using Roxio. The only capture device listed was the microphone - there used to be one that said Conexant Audio 'What you Hear' to capture anything heard through the speakers. On checking Sounds in Control Panel the only recording device is the microphone. Sound works okay from both the internal and external speakers. I've tried rolling back the drivers but its still the same. Any help would be greatly appreciated. Many thanks.
    This question was solved.
    View Solution.

    Ok this has driven me mad for the last few days but I found the solution:
    Windows Vista Recording Input Source selections for recording streaming audio, sound from media players or just about anything you can hear coming through your speakers are Hidden from view and Disabled by Default. (I'm sorry - but why!!?!   )
    If your sound card/system supports recording streaming audio Input Source selections such as: Stereo Mix, What U Hear, Wave Out Mix, Wave or a similar selection, here's what you need to do to Enable it for recording:
    Right-Click on your Speaker Icon in your System Tray, (near your clock), select "Recording Devices".
    In the Sound window that opens, near the top, select the "Recording" TAB.
    Move your cursor down to where devices are shown.
    Right-Click in the blank white area and select "Show Disabled Devices".
    If supported, new selections will appear such as: Stereo Mix, What U Hear, etc. Right-Click on "Stereo Mix", "What U Hear" or similar and select "Enable".
    Right-Click on the same item again and select "Set as Default Device". Click OK.
    Now in the recorder's Options in the "Input Source" box, you should have the "Stereo Mix", "What U Hear" or similar source available to select for recording streaming, etc.
    (You can also Enable other hidden selections like Microphone, Line In, etc. if they are not already shown).

  • Merging and saving audio capture + file from disk

    Hi,
    I need to combine an audio file (read from disk) with an audio capture from a microphone and save the combined audio to a file.
    I created processors for both, merged the data sources and created a processor from the merged data source.
    If I use that as an input to a player, it seems to play OK : I hear the combination of the audio file and the microphone over the speakers (albeit with a delay of the microphone input).
    But when I try to save this merged processor's data source (I tried 2 different ways based on samples I found) I get the following exceptions respectively
    writeToFile
    javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.RawBufferMux$RawBufferDataSource@121cc40
         at javax.media.Manager.createDataSink(Manager.java:1894)
         at soundTest.MergeTest4.writeToFile(MergeTest4.java:108)
         at soundTest.MergeTest4.runTest(MergeTest4.java:70)
         at soundTest.MergeTest4.main(MergeTest4.java:207)
    writeToFile2:
    Unable to handle format: LINEAR, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed
    Unable to handle format: LINEAR, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 176400.0 frame rate, FrameSize=32 bits
    Failed to realize: com.sun.media.ProcessEngine@691f36
    Error: Unable to realize com.sun.media.ProcessEngine@691f36
    javax.media.CannotRealizeException
         at javax.media.Manager.blockingCall(Manager.java:2005)
         at javax.media.Manager.createRealizedProcessor(Manager.java:914)
         at soundTest.MergeTest4.saveFile(MergeTest4.java:83)
         at soundTest.MergeTest4.runTest(MergeTest4.java:71)
         at soundTest.MergeTest4.main(MergeTest4.java:208
    Here's the code (apologies for heavy use of static and poor error handling)
    public class MergeTest4 {
           private static final Format AUDIO_FORMAT = new AudioFormat(AudioFormat.LINEAR);
           private static final int TIME_OUT = 2000;
         private static void runTest() throws Exception {
           DataSource ds1 = getCaptureDataSource();
           DataSource ds2 = Manager.createDataSource(new URL("file:///c:/temp/test.wav"));
           Processor processor1 = Manager.createProcessor(ds1);          
           Processor processor2 = Manager.createProcessor(ds2);  
           configureAndStart(processor1);
           configureAndStart(processor2);
           DataSource[] sources = { processor1.getDataOutput(), processor2.getDataOutput()};
           DataSource mergedDS = Manager.createMergingDataSource(sources);
           Processor mergedProcessor = Manager.createProcessor(mergedDS);    
           configureAndStart(mergedProcessor);
            //This works
            Player player = Manager.createRealizedPlayer(mergedProcessor.getDataOutput());
             player.start();          
             //This does not work
             //  writeToFile(mergedProcessor);
             //  writeToFile2(mergedProcessor);
        private static void writeToFile2(Processor processor) throws Exception {
              ProcessorModel outputPM = new ProcessorModel(processor.getDataOutput(),
                    new Format[]{ new AudioFormat(AudioFormat.LINEAR)},
                    new FileTypeDescriptor(FileTypeDescriptor.WAVE)
            MediaLocator dest = new MediaLocator("file://./rec.wav");
            Processor outputProcessor = Manager.createRealizedProcessor(outputPM);
            DataSource newDS = outputProcessor.getDataOutput();
            newDS.connect();
            newDS.start();
            DataSink dataSink = Manager.createDataSink(newDS, dest);
            dataSink.open();
            dataSink.start();
          //  dataSink.addDataSinkListener(this);
            outputProcessor.start();
         private static void writeToFile(Processor processor) throws Exception {
              StateHelper sh = new StateHelper(processor);
              if (!sh.realize(10000)) {
                   System.exit(-1);
               processor.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.WAVE));
               MediaLocator dest = new MediaLocator("file://c:/temp/foo.wav");
               DataSink filewriter = Manager.createDataSink(processor.getDataOutput(), dest);
               filewriter.open();
               StreamWriterControl swc = (StreamWriterControl) processor.getControl("javax.media.control.StreamWriterControl");
               //set limit to 5MB
               if (swc != null) {
                   swc.setStreamSizeLimit(5000000);
               try {
                   filewriter.start();
               } catch (IOException e) {
                   System.exit(-1);
               // Capture for 20 seconds
               sh.playToEndOfMedia(20000);
               sh.close();
               filewriter.close();
         private static DataSource getCaptureDataSource() {
              try {
                   Vector captureDevices = CaptureDeviceManager.getDeviceList(AUDIO_FORMAT);
                    CaptureDeviceInfo audiocaptureDevice=null;
                    if (captureDevices.size() > 0) {
                         audiocaptureDevice = (CaptureDeviceInfo) captureDevices.get(0);
                    } else {
                         System.out.println("Can't find suitable audio capture device.");
                        return null;
                    return Manager.createDataSource(audiocaptureDevice.getLocator());
              } catch (Exception ex) {
                   ex.printStackTrace();
              return null;
         private static void start(Player player) {
              player.start();
              waitForState(player, Processor.Realized);
         private static void configure(Processor p) {
              p.configure();
              waitForState(p, Processor.Configured);
         private static void configureAndStart(Processor p) {
              p.configure();
              waitForState(p, Processor.Configured);
              start(p);
         private static void waitForState(Player player, int state) {
             if (player.getState() == state) {
                 return;
             long startTime = new Date().getTime();
             final Object waitListener = new Object();
             ControllerListener cl = new ControllerListener() {
                 @Override
                 public void controllerUpdate(ControllerEvent ce) {
                     synchronized (waitListener) {
                         waitListener.notifyAll();
             try {
                 player.addControllerListener(cl);
                 synchronized (waitListener) {
                     while (player.getState() != state && new Date().getTime() - startTime < TIME_OUT) {
                         try {
                             waitListener.wait(500);
                         } catch (InterruptedException ex) {
                             ex.printStackTrace();
             } finally {
                 player.removeControllerListener(cl);
         Any idea what needs to be changed for this to work?
    Thanks
    Philippe

    Drew
    Now that you've got as far as doing GUIs, you must learn to read the API. Here/s a link.
    Is it something like: out.textBox.text() ??
    Not quite. In fact, not at all. The syntax implies that out has a member textBox which in turn has a method text. That's pretty far removed from reality, isn't it?
    From the code you posted, you apparently know that out.println(...) takes a String parameter. Now go look up the API and find a method of JTextField that returns a String, that Returns the text contained in this TextComponent.
    ^Hint: it's a method inherited from JTextComponent^
    Get the text from the JTextField and pass it as a parameter to out.println. That's all there is to it.
    luck, db
    Blasted multiposter didn't have the decency to indicate here that the immediate problem was resolved, just went ahead and started a [new thread|http://forum.java.sun.com/thread.jspa?threadID=5282987].
    One for the little black book.
    Edited by: Darryl.Burke

  • Jmf video capture in an Applet

    Hello
    I use netBeans 6.9.1 and would like to use JMF and the webcam capture JMF function in my applet
    but Iget a no permission error see below
    How can I get out of that?
    Thank you
    Fred
    Public class SourceCam extends java.applet.Applet implements Runnable {
    public int wmax,hmax,ix, x1, y1, x2, y2,y3,y4=0;
    public double yc1=0.0,yc2=0.0, yc3=0.0,yc4=0.0,yc5=0.0,yc6=0.0;
    Color colors[] = new Color[50];
    int[] couleur=new int[50];
    Thread runner;
    Frame f=new Frame("Stimulated Polarized Light @FF ");
    public static Player player = null;
    public static MediaPlayer MediaPlayer1=null;
    public CaptureDeviceInfo di = null;
    public MediaLocator ml = null;
    run:
    java.lang.RuntimeException: No permission to capture from applets
    java.lang.RuntimeException: No permission to capture from applets
    javax.media.NoPlayerException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.lang.RuntimeException: No permission to capture from applets
    at javax.media.Manager.createPlayerForContent(Manager.java:1362)
    at javax.media.Manager.createPlayer(Manager.java:417)
    at javax.media.Manager.createRealizedPlayer(Manager.java:553)
    at org.me.light.SourceCam.init(SourceCam.java:58)
    at sun.applet.AppletPanel.run(AppletPanel.java:424)
    at java.lang.Thread.run(Thread.java:662)

    I did that already
    i.e. what is written in
    Q: Can I capture audio or video from within an Applet with JMF 2.1.1?
    By default (for security reasons), JMF 2.1.1 does not allow capture from an applet. The user can turn this on by using JMFRegistry.
    Run "java JMFRegistry", select the UserSettings tab and check "Allow Capture From Applets". If the browser's security permits loading native libraries, then you will now be able to capture audio/video from an applet.
    but the program lines
    try
    player = Manager.createRealizedPlayer(ml);
    FormatControl formatControl = (FormatControl)player.getControl("javax.media.control.FormatControl");
    Component co = formatControl.getControlComponent();
    Thread.sleep(2000);
    player.start();
    give always the same error
    java.lang.RuntimeException: No permission to capture from applets
    java.lang.RuntimeException: No permission to capture from applets
    why?
    I am working inside the netbeans 6.9.1 editor

  • Weird Audio Capture

    Lately I've had trouble with DV audio capturing from our camcorder. Instead of 48 kHz, the audio will be something like 48,010.4 Hz. This happens most often on long captures (half hour or more). This is a major pain, because the fix is to render the clip on a 48 kHz timeline, then export it.
    Any ideas what the problem could be and how to fix it?
    Thanks, gurus.

    There have been a number of instances reported here (on the forum) of Sony and Canon cameras with audio drifting.
    The only real solutions are:
    1. Capture in short (5-10 min) segments to minimize the drift effect (Jim's suggestion)
    2. Re-conform the audio after capture (what you are doing)
    3. Try a different camera that works in DVCAM format. DVCAM locks the audio and video together - so no drift.
    Good luck.
    x

  • I captured from mini-dv camcorder to FCP7 using control from my computer and firewire. I cannot find the file or clips I transferred anywhere except for in Finder. How do I get the clips from Finder to FCP7. Also I did not see audio on the computer meters

    I captured from mini-dv camcorder to FCP7 using control from my computer. I only find the capture clip in Finder. How do I get the clip in Finder to FCP7.
    Also my audio in the capture was not showing up on my audio meters on my computer-is this normal. Thanks

    you will not see the audio meters from within fcp move while capturing. 
    If you only see the captured clip in the finder, not within fcp, there's something wrong.  You might try deleting your fcp preferences
    https://discussions.apple.com/docs/DOC-2491

  • How to fix audio  of a video captured from DV output of camcorder using Adobe Premiere Elements 8?

    Hello,
    I purchased Adobe Premiere Elements 8 about one week ago.  I installed it and everything seem to work well in my first project.  I am new at editing videos but I was succesful in testing it by loading an existing video file in avi format from my computer and then doing some very basic editing (I splitted 2 scenes and added a title). 
    After my first succesful project (described above) I started a brand new project. Here, I want to capture a one hour video  from the dv output of a video camera. So I connected the camera to the PC and then started adobe elements 8.  Before starting the capture I only checked the boxes that said "capture video" and "capture audio" (the other 2 boxes that said download to timeline and autoanalyze were left unchecked).  After that I started the capture process.
    After the video capture was completed, a small window opened at the bottom saying that a PEAK FILE was being generated.    After the peak file generation finished, I looked at the captured video.  The video looked perfect.  However the audio of the video was too fast. By this, I mean that the voices of the people in the movie were like they were speaking at more than twice the normal speed.  Or to explain it in a different way, they sounded like the  chipmunks.
    So now I come to the question of this thread I started.  Is there a way that I can fix the audio part of the video I captured?  I will appreciate any help on this. Below I listed a few additional details in case this is needed.
    Thanks,
    ronel_8
    PS.  Here are some more details about my system:
    1) Operating System: Windows XP
    2) I am capturing the video on an external drive with 40 GB of available space. The external drive is connected to a PC via a USB connection.
    3) Computer CPU: 2.4 GHZ
    4) Computer RAM: 1.25 GB
    5) Video tape is about one hour long.

    Hello Bill and Steve,
    Your responses are very helpful.  Although I was not able to fix the problem yet I do seem to think from what you both say that my system may be too slow to capture the one hour video. In any case I will copy below more details about the system as you requested:
    1) Results from running Gspot:
    The audio section of the Gspot window was blank. That is, no information was there.  The File and Container sections say:
    File Size: 12.6 GB
    Note: 7.63 GB unneeded bytes at the end of the file
    DV Type1 AVI
    2) I did run the Gspot on another good avi file (captured to the PC with same camcorder) and says:
    Codec PCM Audio
    32kHz 1024 kb/s tot (2 chnls).
    I suppose these are the audio settings from the camera.
    3) Yes, I am capturing video from a miniDV camcorder (JVC GR-D70U).
    4) I did not defragment the external drive prior to capturing the video with the audi problem.  So I will give that I try and see if it solves the problem.
    5) The external drive I am using is formatted to NTFS.
    6) The computer is a Dell Dimension 2400, CPU: 2.4 GHZ, RAM: 1.25 GB
    7) HDD Size=74GB and 11 GB of free space.  But I am downloading video to external drive that has 60 GB free space.
    One last piece of information that may be useful.  If I open the AVI file (that I captured with Adobe Premiere Elements) with Windows Media Player, the audi sounds good.  However if I open it with Adobe it has the problem I mentioned in my previous e-mail.
    I'll aprreciate any further hints.
    Thanks again,
    ronel_8

  • My audio gets out of sync with my video after capturing from Sony XDCAM

    Everything was fine. I captured content from my Sony XDCAM, created pieces, no problem. Imported a .mov from my older FCP (5.1.4). FCP told me I needed to change my settings in order to use the .mov with my current timeline. I said OK, fine. Now, when I capture from my XDCAM some of the audio is in sync but it goes out fairly quickly. Any Ideas? I noticed in the bin the clips which are out of sync have a different data rate then the good ones. HELP!

    Everything was fine. I captured content from my Sony XDCAM, created pieces, no problem. Imported a .mov from my older FCP (5.1.4). FCP told me I needed to change my settings in order to use the .mov with my current timeline. I said OK, fine. Now, when I capture from my XDCAM some of the audio is in sync but it goes out fairly quickly. Any Ideas? I noticed in the bin the clips which are out of sync have a different data rate then the good ones. HELP!

  • Is it possible to monitor audio through my mac while capturing from a tape in FCPX

    Is it possible to monitor audio through my mac while capturing from a tape in FCPX?

    I am sure that as you import a tape you will hear the audio as well as see the video.
    Have you got FCP X?
    If not, download the free 30 day trial.
    http://www.apple.com/finalcutpro/trial/

  • JMF bundlejava.lang.RuntimeException: No permission to capture from applets

    Hello!
    I'm developing a SIP Softphone Applet which works with Java Media Framework 2.1 (uses RTP).
    I want to make a jmf bundle for my applet, that is very important for me, because users will not install Java Media Framework.
    I have done a jar which contains unpacked JMF, it works very nice when I lunch my applet (jar) as a simple Java application, but NOT IN BROWSER...
    I have used JMFRegistry for generate a jmf.properties file that allows devices to be captured from applets...
    When I try to run my application from browser one error appears : java.lang.RuntimeException: No permission to capture from applets, because the jmf.jar doesn't detect jmf.properties...
    I don't need to use system variables (CLASSPATH), registry because it will require a restart of the system.
    Sorry for my bad English and I wish that I have exposed my minds correctly.
    Help me please!!!
    Thanks!!!

    Hi!
    1.Are you getting this error in Vista or XP ?
    Response:
    I have this error on XP. (I've tried this on the Vista, but there are some problems with JMF...)
    2. If XP,
    a) Do you have any service packs installed in your system ?
    Response:
    Not, I haven't installed any Service Packs.
    b) Which browsers you tried ? In all browsers are you getting this error ?
    Response:
    I'm tried on Internet Explore and on Firefox. The error is in both browsers.
    3. For your Java Application requires JMF to be installed in client machine ?
    Response:
    Not, I don't need to install JMF on client machine, because I must to bundle JMF in my application...
    4. How to create a jar with unpacked JMF ? (is it jmf installer from sun)
    Response:
    Yes, there is a installer from sun (for Windows is .exe, but on linux there are some problems: some packages are missed).
    I use Intellij Idea to develop my Softphone and in this IDE there is a nice plugin "Jar Tool", which can help you to archive...
    I have tried to unjar JMF with 7zip, after that I make a jar with Netbeans IDE and it works...
    5. Did you singed your applet ?
    Response:
    Sure, I've signed my applet...
    Good luck, friend... If you will resolve this problem (to include jmf.properties somewhere and applet will work from browser...) tell me please...

  • Repeated audio capture in midlets... a new audio everytime from user...

    Hi guys can you help me in getting repeated audio capture in midlets... a new audio everytime from user...
    just the part where
    captureplayer,playbackplayer to null
    recordcontrol=null.....
    manager to realize captureplayer
    recordcontrol.setstream ---->doesn't work for me.
    Any ideas will be helpful

    I assume you are wanting to hear the audio as you are importing and not that you have no audio once it is imported.
    imovie 08 doesn't play audio while importing. While you are using tape (that imports in real time) imovie now imports from a variety of different types of camera such as AVCHD (which isn't imported at real time. Therefore it is no longer logical to playback audio on import.

  • Playing an audio file from applet

    Hi friends,
    I have a problem to be solved .
    Please help me.
    I have to play an audio file from applet.When the applet loads it shold start playing .There is a progress bar in the applet it shold alsomove corresponding to that.
    How can i do that.Give me an idea.
    I know nothing about jmf.
    I am using j2sdk1.4,windows 2000 server.

    Andrew,
    Forgive my naivety, but i struggle with JAVA! I am desperately trying to create a JAVA plugin to SERVOY and have to date been successful with a few things. Record, Playback, convert to .spx.
    I am really struggling with implementing a rewind and fastforward function of the type you have. I thought it would be easy, but it appears not.
    At the bottom is the complete code from my class that is called by the servoy plugin wrapper,
    i had thought that adding some simple jump 500 ms would have been easy in something like this:
    public AudioStream js_FastForward (AudioStream as) throws IOException {
    !!! Line or two here to move the play head forward !!!
         AudioPlayer.player.start(as);
         return as;
    Can you give me any pointers to how i code that fast forward bit.
    many thanks
    David
    package com.d2e.MyPlugin;
    import com.servoy.j2db.scripting.IScriptObject;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.awt.Button;
    import javax.sound.sampled.*;
    import org.xiph.speex.*;
    import org.xiph.speex.spi.*;
    import  sun.audio.*;    //import the sun.audio package
    public class MyPluginProvider implements IScriptObject  {
          public void JSencode()
             throws IOException{
               /** Version of the Speex Encoder */
                final String VERSION = "Java Speex Command Line Encoder v0.9.7 ($Revision: 1.5 $)";
                /** Copyright display String */
                final String COPYRIGHT = "Copyright (C) 2002-2004 Wimba S.A.";
                /** Print level for messages : Print debug information */
                final int DEBUG = 0;
                /** Print level for messages : Print basic information */
                final int INFO  = 1;
                /** Print level for messages : Print only warnings and errors */
                final int WARN  = 2;
                /** Print level for messages : Print only errors */
                final int ERROR = 3;
                int printlevel = INFO;
                /** File format for input or output audio file: Raw */
                final int FILE_FORMAT_RAW  = 0;
                /** File format for input or output audio file: Ogg */
                final int FILE_FORMAT_OGG  = 1;
                /** File format for input or output audio file: Wave */
                final int FILE_FORMAT_WAVE = 2;
                int srcFormat  = FILE_FORMAT_OGG;
                int destFormat = FILE_FORMAT_WAVE;
                int mode       = -1;
                int quality    = 4;
                /** Defines the encoders algorithmic complexity. */
                 int complexity = 3;
                /** Defines the number of frames per speex packet. */
                 int nframes    = 1;
                /** Defines the desired bitrate for the encoded audio. */
                 int bitrate    = -1;
                /** Defines the sampling rate of the audio input. */
                 int sampleRate = -1;
                /** Defines the number of channels of the audio input (1=mono, 2=stereo). */
                 int channels   = 1;
                /** Defines the encoder VBR quality setting (float from 0 to 10). */
                 float vbr_quality = -1;
                /** Defines whether or not to use VBR (Variable Bit Rate). */
                 boolean vbr    = false;
                /** Defines whether or not to use VAD (Voice Activity Detection). */
                 boolean vad    = false;
                /** Defines whether or not to use DTX (Discontinuous Transmission). */
                 boolean dtx    = false;
              //HArd code src format and dest
               // private String srcPath ="junk.wav";
              srcFormat = FILE_FORMAT_WAVE;
              destFormat = FILE_FORMAT_OGG;
              //destPath="junk.spx";
             byte[] temp    = new byte[2560]; // stereo UWB requires one to read 2560b
             final int HEADERSIZE = 8;
             final String RIFF      = "RIFF";
             final String WAVE      = "WAVE";
             final String FORMAT    = "fmt ";
             final String DATA      = "data";
             final int WAVE_FORMAT_PCM = 0x0001;
             // Open the input stream
             DataInputStream dis = new DataInputStream(new FileInputStream("junk.wav"));
             // Prepare input stream
           //DP - Sort out the Wave File
               // read the WAVE header
               dis.readFully(temp, 0, HEADERSIZE+4);
               // Read other header chunks
               dis.readFully(temp, 0, HEADERSIZE);
               String chunk = new String(temp, 0, 4);
               int size = readInt(temp, 4);
               while (!chunk.equals(DATA)) {
                 dis.readFully(temp, 0, size);
                 if (chunk.equals(FORMAT)) {
                   typedef struct waveformat_extended_tag {
                   WORD wFormatTag; // format type
                   WORD nChannels; // number of channels (i.e. mono, stereo...)
                   DWORD nSamplesPerSec; // sample rate
                   DWORD nAvgBytesPerSec; // for buffer estimation
                   WORD nBlockAlign; // block size of data
                   WORD wBitsPerSample; // Number of bits per sample of mono data
                   WORD cbSize; // The count in bytes of the extra size
                   } WAVEFORMATEX;
                   if (readShort(temp, 0) != WAVE_FORMAT_PCM) {
                     System.err.println("Not a PCM file");
                     return;
                   channels = readShort(temp, 2);
                   sampleRate = readInt(temp, 4);
                   if (readShort(temp, 14) != 16) {
                     System.err.println("Not a 16 bit file " + readShort(temp, 18));
                     return;
                   // Display audio info
                   if (printlevel <= DEBUG) {
                     System.out.println("File Format: PCM wave");
                     System.out.println("Sample Rate: " + sampleRate);
                     System.out.println("Channels: " + channels);
                 dis.readFully(temp, 0, HEADERSIZE);
                 chunk = new String(temp, 0, 4);
                 size = readInt(temp, 4);
               if (printlevel <= DEBUG) System.out.println("Data size: " + size);
           //DP ENd sort wave file 
           //Now Choose the mode , we have a file sampled at 44100
                 mode = 2; // Ultra-wideband
             // Construct a new encoder
             SpeexEncoder speexEncoder = new SpeexEncoder();
             speexEncoder.init(mode, quality, sampleRate, channels);
             if (complexity > 0) {
               speexEncoder.getEncoder().setComplexity(complexity);
             if (bitrate > 0) {
               speexEncoder.getEncoder().setBitRate(bitrate);
             if (vbr) {
               speexEncoder.getEncoder().setVbr(vbr);
               if (vbr_quality > 0) {
                 speexEncoder.getEncoder().setVbrQuality(vbr_quality);
             if (vad) {
               speexEncoder.getEncoder().setVad(vad);
             if (dtx) {
               speexEncoder.getEncoder().setDtx(dtx);
             // Display info
             // Open the file writer
             AudioFileWriter writer;
             if (destFormat == FILE_FORMAT_OGG) {
               writer = new OggSpeexWriter(mode, sampleRate, channels, nframes, vbr);
             else if (destFormat == FILE_FORMAT_WAVE) {
               nframes = PcmWaveWriter.WAVE_FRAME_SIZES[mode-1][channels-1][quality];
               writer = new PcmWaveWriter(mode, quality, sampleRate, channels, nframes, vbr);
             else {
               writer = new RawWriter();
             writer.open("junk.spx");
             writer.writeHeader("Encoded with: " + VERSION);
             int pcmPacketSize = 2 * channels * speexEncoder.getFrameSize();
             try {
               // read until we get to EOF
               while (true) {
                 dis.readFully(temp, 0, nframes*pcmPacketSize);
                 for (int i=0; i<nframes; i++)
                   speexEncoder.processData(temp, i*pcmPacketSize, pcmPacketSize);
                 int encsize = speexEncoder.getProcessedData(temp, 0);
                 if (encsize > 0) {
                   writer.writePacket(temp, 0, encsize);
             catch (EOFException e) {}
             writer.close();
             dis.close();
            * Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
            * @param data the data to read.
            * @param offset the offset from which to start reading.
            * @return the integer value of the reassembled bytes.
           protected static int readInt(final byte[] data, final int offset)
             return (data[offset] & 0xff) |
                    ((data[offset+1] & 0xff) <<  8) |
                    ((data[offset+2] & 0xff) << 16) |
                    (data[offset+3] << 24); // no 0xff on the last one to keep the sign
            * Converts Little Endian (Windows) bytes to an short (Java uses Big Endian).
            * @param data the data to read.
            * @param offset the offset from which to start reading.
            * @return the integer value of the reassembled bytes.
           protected static int readShort(final byte[] data, final int offset)
             return (data[offset] & 0xff) |
                    (data[offset+1] << 8); // no 0xff on the last one to keep the sign
         AudioFormat audioFormat;
           TargetDataLine targetDataLine;
         public Class[] getAllReturnedTypes() {
              // TODO Auto-generated method stub
              return null;
         public String[] getParameterNames(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public String getSample(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public String getToolTip(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public boolean isDeprecated(String arg0) {
              // TODO Auto-generated method stub
              return false;
         public String js_Record (String name){
              captureAudio();
              return "Started Recording " +name;
        public String js_StopRecord (String name) throws IOException{
             //new ActionListener(){
             //   public void actionPerformed(ActionEvent e)
                  //Terminate the capturing of input data
                  // from the microphone.
                  targetDataLine.stop();
                  targetDataLine.close();
              //  }//end actionPerformed
             //};//end ActionListener
                 // JSpeexEnc ("junk.wav","output.spx");
                  JSencode();
              return "Stop Records " +name;
        //Play audio file
        public AudioStream js_Playback (String name) throws IOException{
             InputStream in = new FileInputStream("junk.wav");
             AudioStream as = new AudioStream(in);        
             AudioPlayer.player.start(as);           
             return as;
        public AudioStream js_ContPlay (AudioStream as) throws IOException {
             AudioPlayer.player.start(as);           
             return as;
         //Stop Play
        public AudioStream js_Stop_Playback (AudioStream as) throws IOException{
             AudioPlayer.player.stop(as);
              return as;
         //This method captures audio input from a
        // microphone and saves it in an audio file.
        private void captureAudio(){
          try{
            //Get things set up for capture
            audioFormat = getAudioFormat();
            DataLine.Info dataLineInfo =
                                new DataLine.Info(
                                  TargetDataLine.class,
                                  audioFormat);
            targetDataLine = (TargetDataLine)
                     AudioSystem.getLine(dataLineInfo);
            //Create a thread to capture the microphone
            // data into an audio file and start the
            // thread running.  It will run until the
            // Stop button is clicked.  This method
            // will return after starting the thread.
            new CaptureThread().start();
          }catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
          }//end catch
        }//end captureAudio method  
    //  This method creates and returns an
        // AudioFormat object for a given set of format
        // parameters.  If these parameters don't work
        // well for you, try some of the other
        // allowable parameter values, which are shown
        // in comments following the declarations.
        private AudioFormat getAudioFormat(){
          float sampleRate = 44100.0F;
          //8000,11025,16000,22050,44100
          int sampleSizeInBits = 16;
          //8,16
          int channels = 1;
          //1,2
          boolean signed = true;
          //true,false
          boolean bigEndian = true;
          //true,false
          return new AudioFormat(sampleRate,
                                 sampleSizeInBits,
                                 channels,
                                 signed,
                                 bigEndian);
        }//end getAudioFormat
        class CaptureThread extends Thread{
               public void run(){
                 AudioFileFormat.Type fileType = null;
                 File audioFile = null;
                 //Set the file type and the file extension
                 // based on the selected radio button.
                 //if(aifcBtn.isSelected()){
                  // fileType = AudioFileFormat.Type.AIFC;
                  // audioFile = new File("junk.aifc");
                // }else if(aiffBtn.isSelected()){
                 //  fileType = AudioFileFormat.Type.AIFF;
                 //  audioFile = new File("junk.aif");
                // }else if(auBtn.isSelected()){
                 //  fileType = AudioFileFormat.Type.AU;
                 //  audioFile = new File("junk.au");
                // }else if(sndBtn.isSelected()){
                //   fileType = AudioFileFormat.Type.SND;
                 //  audioFile = new File("junk.snd");
                // }else if(waveBtn.isSelected()){
                 fileType = AudioFileFormat.Type.WAVE;
                 audioFile = new File("junk.wav");
                // }//end if
                 try{
                   targetDataLine.open(audioFormat);
                   targetDataLine.start();
                   AudioSystem.write(
                         new AudioInputStream(targetDataLine),
                         fileType,
                         audioFile);
                 }catch (Exception e){
                   e.printStackTrace();
                 }//end catch
               }//end run
             }//end inner class CaptureThread
    }

  • Image capture from avi vfw device can't find video modes

    Hello
    Here my issu, i have implemented image capture from a video device using jmf 2.1.1e performancepack, using a webcam everything is fine but when i use the video capture source i want to use i can only work with format 720x480 pal and i require 720x576 pal.
    jmf seem not to reconize video format from this source, but the video is correcty displayed and image correctly captured. I'm surprised it is half working:decoding&render is ok to but not format choice.
    I have check it is not because i'm in ntsc mode (ntsc is 720x480) because my analogic source is pal and color are correct (if with device software i change to ntsc mode i have a black&with but using jmf i'm in color so i'm in pal mode)
    Difference bettween the webcam and my device is that my device is an avi encoder so in jmf webcam is javax.media.format.YUVFormat and my device com.sun.media.format.AviVideoFormat
    i have tried many thing:
    install codec pack (divx6, another codec pack)
    try to use Fobs4JMF
    register in JMStudio IBMdecoder, jffmpeg
    Tanks for any help
    the device support many configuration UYVY 235x288 352x576 .... 720x576 but JMF offer only 1 video mode for this device.
    here in jmf my capture device info:
    Name = vfw:Microsoft WDM Image Capture (Win32):0
    Locator = vfw://0
    Output Formats---->
    0. com.sun.media.format.AviVideoFormat
    UYVY, 720x480, Length=691200 0 extra bytes
    and with a web cam:
    Name = vfw:Microsoft WDM Image Capture (Win32):0
    Locator = vfw://0
    Output Formats---->
    0. javax.media.format.YUVFormat
    YUV Video Format: Size = java.awt.Dimension[width=640,height=480] MaxDataLength = 460800 DataType = class [B yuvType = 2 StrideY = 640 StrideUV = 320 OffsetY = 0 OffsetU = 307200 OffsetV = 384000
    1. javax.media.format.RGBFormat
      RGB, 160x120, Length=57600, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=480, Flipped
    2. javax.media.format.RGBFormat
      RGB, 176x144, Length=76032, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=528, Flipped
    3. javax.media.format.RGBFormat
      RGB, 320x240, Length=230400, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=960, Flipped
    4. javax.media.format.RGBFormat
      RGB, 352x288, Length=304128, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=1056, Flipped
    5. javax.media.format.RGBFormat
      RGB, 640x480, Length=921600, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=1920, Flipped
    6. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=160,height=120] MaxDataLength = 28800 DataType = class [B yuvType = 2 StrideY = 160 StrideUV = 80 OffsetY = 0 OffsetU = 19200 OffsetV = 24000
    7. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=176,height=144] MaxDataLength = 38016 DataType = class [B yuvType = 2 StrideY = 176 StrideUV = 88 OffsetY = 0 OffsetU = 25344 OffsetV = 31680
    8. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=320,height=240] MaxDataLength = 115200 DataType = class [B yuvType = 2 StrideY = 320 StrideUV = 160 OffsetY = 0 OffsetU = 76800 OffsetV = 96000
    9. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=352,height=288] MaxDataLength = 152064 DataType = class [B yuvType = 2 StrideY = 352 StrideUV = 176 OffsetY = 0 OffsetU = 101376 OffsetV = 126720[/i]

    I have find some information at l'article http://archives.java.sun.com/cgi-bin/wa?A2=ind0111&L=jmf-interest&P=22779
    but i didn't find "sample programs on the JMF Solutions page" which is about VFWDeviceQuery
    so i have trouble with point 2 so this article.
    I have try to rewrite VFWDeviceQuery:
    i just have add dimension 720x576 and "UYVY" in the variable declaration, then compile and replace VFWDeviceQuery .java in jmf.jar in but it is not working)
    I miss information on what to do on VFWDeviceQuery to try more
    About jmf soucre file, i have used the source file jmf-2_1_1e-scsl-src but i have some package missing such as com.ibm.media.codec.audio.BufferedEncoder ...
    so i can't use debugger on all jmf package and check how VFWDeviceQuery is working.
    if someone have information about please help me:
    - "sample programs on the JMF Solutions page" about VFWDeviceQuery
    - how to rewrite VFWDeviceQuery to support UYVY
    - how to compile entier jmf source files
    V.

Maybe you are looking for

  • Help needed with Response File

    Hi, I am trying to perform a silent installation of jre 1.4.1 international version.I have created the following Response File .But I am getting a result Code= -3 when I use start /w c:\j2re-1_4_1_01-windows-i586-i -s -a -s -f1c:\setup.iss -f2c:\setu

  • Apple will not boot up after RAM upgrade

    I purchased 2 Centon 2GB (PC2-5300 SO-DIMM DDR2-667) sticks of ram. I know my machine's max is 3GB. I read that 2 2GB sticks will work with my model. The computer will recognize 4GB, but only use 3GB. After I install the RAM and turned the computer o

  • How to put the column name and variable value in the alert message.

    Dear, how can i put the column name and variable value in the alert message text. i want to display an alert which tell the user about the empty textboxes. that these textboxes must be filled. Regards: Muhammad Nadeem CHIMERA PVT. LTD. LAHORE [email 

  • DMEE WITH PASSAGE UNICODE

    Hi everybody I need to new how to resolve a problem with the passage to new release (6.0) and unicode. I tried to create a file of payment with DMEE but the file is with format incorrect. There are many "#". thank for your help.

  • HTC One M8 Led notification light

    just got the new HTC One and the led does not flash when i get a notification like a text or email. all those options are checked in the settings under Display