JMF and audio streams

Hi all,
I am writing an application that reads an audio stream and performs some analysis on the audio samples (e.g. detection of dtmf tones). I'd like to be able to write some code that works both on streams from files and from RTP connections (in order to easily write test classes). I made a little test program that reads a wav file with javasound and does some audio analysis.
public static void main(String[] args)
   AudioInputStream sound = AudioSystem.getAudioInputStream(new File(args[0]));
   int length = (int) sound.getFrameLength();
   for(int i=0; i<length; i++)
      byte[] sample = new byte[2];
      int res = in.read(sample, 0, sample.length);
      if(res != sample.length)
         throw new RuntimeException(
            "Couldn't read a 2 bytes sample from audio stream.");
      if(!in.getFormat().isBigEndian())
         byte tmp = sample[0];
         sample[0] = sample[1];
         sample[1] = tmp;
      DataInputStream ds = new DataInputStream(
         new ByteArrayInputStream(sample));
      goertzel(ds.readShort());
}Now, I tried to do the same using JMF but I failed. More specific in JMF:
1) How can I get informations about the stream I'm reading? (e.g. all infos I can get from AudioInputStream's getFormat() method)
2) Is there a way to get a stream from a DataSource and determine at runtime if the stream is in a particular format I'm expecting, WITHOUT bothering if it is coming form RTP, audio file or something else?
3) Eventually, Is it hard to use the stream I'm reading to create a new DataSource that some other component will use?

Sorry but.. I don't know which is the appropriate subclass: I can't find it. I guess you missed "instanceof" in Java 101, eh?
Moreover I'd like to find a class that is not something like "RTPStream" or "AudioFileInputStream" but something representing just the audio stream itself.There are ways you can get access to the raw data as it flows through the system, but as far as I know, there's no way of gaining random access to the audio stream itself...
Note that a solution could be to use javasound AudioInputStream class and a simple java rtp library. I could implement my Audio analysis methods in order to work on "abstract streams" (given a particular audio format), then write a test class that work with audio files and a real application that gets input streams from RTP connections.
I just want to know whether JMF allows me do do that or not?It'd be relatively simple to use JMF to receive an RTP stream and "export" it to JavaSound... you'd just need to write a custom DataSink.

Similar Messages

  • Sync of Video and Audio streams

    I got a main project to make a video conferance system. And i'm not sure how to sync the video and Audio streams. (Audio need to have higher priority than video)
    Video is all moust real-time but audio is around 0.5 sec delay at the fastest.
    I realy need to find out how to sync them since its one of my main subjects in the project.
    So if anyone know how to, plz let me know.

    Hello,
    I try to implement a videoconference in Java with JMF. At the reception, audio and vid�o aren't synchronizing. I'm looking for a solution to resolve this problem because i think in this kind of application, audio and video tracks must be synchronized. I'd like to know when and how can i do the synchronization : at the capture, before transmission, or at the reception ?

  • IOS 8 and Bluetooth Phone and Audio Streaming Failing

    I have a 2013 Nissan Pathfinder and a 2015 Nissan Leaf, both with bluetooth phone integration and audio streaming support.  Both cars worked fine when I had two iPhone 5s paired to both cars and running latest iOS 7.  Both phones worked in both cars and could fully integrate to make calls and also to stream audio from device to car.
    When I upgraded one iPhone 5s to iOS 8 and replaced the other with an iPhone 6Plus running iOS 8, both are having problems with both cars.
    1.  Both gave a "failed connection" message but the phones do actually pair.
    2.  Both cars show a phone handset with a line through it on the in-car display which means no connection.
    3.  The "5 bars" cell signal indicator on the in-car display no longer shows up.
    3.  Outgoing calls made from phone and put through car system work fine except for some garbled audio.
    4.  Incoming calls make the wrong screen appear on the nissan display and can not be answered by the display on the car.  Pushing the answer button on the in-car display doesn't do anything.
    Lots of other tiny issues.  Apple needs a fix here.  I called Nissan and they said it's 100% Apple's fault.
    Anyone else having issues with Nissan Bluetooth integration or any other manufacturer?

    We have a 2008 Nissan Sentra - The bluetooth pairs ok.  When a call comes in on my 5S or my wife's 4S the bluetooth does not do anything.  The bluetooth does not ring and it does not connect to the call.  The call has to be answered on the phone.  Like I said, the phones are paired.  You can access Siri through the bluetooth to initiate a call.  Once the call is connecting, the bluetooth drops off and there is no sound.  Just like when you receive a call.  Apple needs to fix this.  This is completely ridiculous.  I WAS going to buy an iPhone 6.  I will not if this is not fixed.

  • My video and audio streaming always break-up (or I have delays)

    When I watch a video from MSNBC thevideo and audio streaming always delays. Any idea what the problem is or how I can fix it.

    Premiere does not work well with variable frame rate video which, I expect, the ipad produces, You might have to convert the footage before you import it into Premiere. Do a forum search for variable frame rate, there are a lot of posts.

  • Multiplex a mpeg2 video and audio stream recorded via a satellite receiver

    I would like to know if upgrading to QuickTime pro and/or adding the QuickTime MPEG2 add-on would allow me to multiplex a mpeg2 video and audio stream recorded via a European satellite receiver (like the Aston Xena 1800 HDU) in order to make movies that can later on be converted to be viewed on my iPod.
    Mac Mini   Mac OS X (10.4.9)  

    No. The MPEG-2 component is to play MPEG-2 not encode it.
    Use Toast. I assume you have separate audio and video transport streams, if they are named identically (1.m2v and 1.m2a) Toast will detect that and multiplex into a new MPEG-2. If not , add the video stream to Toast, which will ask for an audio stream to go with it. Either way it makes an MPEG-2 anew.
    Of course you cannot use MPEG-2 in iPod so rip that DVD (Toast can make just an image and you can mount that) to get the VOB file, then use MPEG Streamclip or iSquint to convert the muxed MPEG-2 file to MP4 suitable for iPod.
    Note I am very curious - are you sure this device delivers separate audio and video streams? Not a proper muxed MPEG-2 file? If the latter then just MPEG Streamclip or iSquint will do.

  • JMF and Darwin Streaming Server.

    I have darwin streaming the sample files.
    I use JMF to connect to darwin.
    The connection is made, The server knows Jmf is connected , the server streams, verified with packet monitor.
    The problem is that JMFStudio just does not start playing the video.
    Any one know why, or have it working??

    One strange thing I noticed, is that while monitoring jmfstudio transmit to jmfstudio across network,
    I use ETHEREAL to monitor the packets, and ports being used. ETHEREAL usually just picks JMF RTP packets as UDP, which is right, but.....
    DSS5 even though JMF is connected across lan to DSS5 the picture does not show.
    WHile monitoring the packets, ETHEREAL picks the DSS5 packet s as RTP and every 20th RTCP.
    So, what i am thinking is the DSS5 RTP packetizer is of better quality than JMF, and the result is that JMF is not fully aware of the 'true' specifications of RTP.
    maybe......

  • JMF and MP3 streaming

    Hi,
    I tried to write an JMF Plugin for an MP3 audio stream. The plugin should buffer the compressed MP3 data, but
    extending the AVReceive2.java with a plugin did not send any output to the player.
    Would someone please help me with a code snapshot?
    Any better ideas than using a plugin for MP3 stream buffering?
    Thanks in advance,
         Florian

    hope this help this is a code i found in a search on this forum hope it helps
    //: SimplePlayer.java
    // This is a simple JMF Program that will play any support audio
    import java.io.*;
    import java.net.*;
    import javax.media.*;
    public class SimplePlayer {
    private static Player player;
    private File file;
    private URL url;
    private String filename;
    public SimplePlayer(String filename) {
    this.filename = filename;
    initalizePlayer(filename);
    private void initalizePlayer(String filename) {
    try {
    file = new File(filename);
    this.filename = file.getName();
    url = file.toURL();
    System.out.println("Initalizing Player ...");
    player = Manager.createPlayer(url);
    System.out.println("Player Initalized ...");
    catch (Exception e) {
    e.printStackTrace();
    public static void main(String args[]) {
    if(args.length == 0) {
    System.out.println("Usage: java SimplePlayer [filename] \n\n" +
    "Example: \n" +
    "\tWindows - java SimplePlayer c:\\mp3\\GoodSong.mp3 \n" +
    "\tUnix - java SimplePlayer \\usr\\mp3\\GoodSong.mp3");
    else
    /* This for loop concatenates the input
    string received at the command line.
    If the command line input has spaces
    java will parse by the spaces.
    For example: java SimplePlayer c:\My
    Music Directory\Very Good Song.mp3
    Before for loop:
    args[0] = "c:\My"
    args[1] = "Music"
    args[2]
    = "Directory\Very"
    args[3] = "Good"
    args[4] = "Song.mp3"
    After for loop:
    args[0] = "c:\My Music
    Directory\Very Good Song.mp3"
    for(int i = 1; args.length > i; i++) {
    args[0] += " " + args[ i ];
    SimplePlayer sp = new SimplePlayer(args
    [0]);
    String input;
    try {
    BufferedReader in = new
    BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter Command: ");
    while(!(input = in.readLine
    ()).equals("quit")) {
    if(input.toLowerCase
    ().equals("play")) {
    System.out.println("Playing " + sp.filename + "...");
    player.start();
    else if(input.toLowerCase
    ().equals("stop")) {
    System.out.println("Stopping " + sp.filename + "...");
    player.stop();
    else {
    System.out.println("Invalid Command...");
    System.out.println("Enter Command: ");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    System.out.println("Closing Player");
    player.stop();
    player.close();
    System.exit(0);

  • Muxing m2v and audio stream

    Hi,
    I have a mpeg2 video stream (m2v) and a AIFF audio stream. Can I combine these into one stream. I thought Quicktime Pro can do this. I opened both the streams, copied the audio stream and in the video stream I did "Add to Movie" from the Edit menu. I was able to play it fine.
    But, when I try to save it, Quicktime fails with "Unknown error occurred (-1)". Is this a limitation of Quicktime?. Is there any other way to do the muxing?
    Thank you for the help.
    Ansari
    MacBook Mac OS X (10.4.9) 2GB, 160GB hard drive
    MacBook   Mac OS X (10.4.8)   1GB, 120GB hard drive

    Among other things, MPEG Streamclip can demultiplex VOB or MPEG into .m2v video and .aiff, .ac3 or .m1a (a.k.a .mp2) components.
    It can also easily be used to multiplex video and audio files together: just place similarily named .m2v and .aiff, .ac3 or .m1a files in the same folder, drop the .m2v file on MPEG Streamclip, and convert them to MPEG with PCM, .ac3 or .m1a audio. If necessary, MPEG Streamclip can encode new .m1a audio at 192-384 kb/s.

  • JMF and audio encryption

    Hello,
    I have successfully compiled and run a JMF program to transmit/receive RTP streams by re-using example programs in the API guide.
    I am fairly new in this area. I would like to figure out how audio encryption works. Can someone point me to somewhere where I can give a head start on this? I guess first thing I want to understand what is the general approach to the encryption in RTP. Do I have to create a custom AudioFormat so that only my program play it?
    Or is it possible to encrypt the default packets using some key and encryption algorithm? The picture in my mind is that once audio is captured and ready to be transmitted over, I would like call some method which encrypts the packets and hence once receiver receives the packets, it first decrypts the packets and then does whatever it supposed to do..
    Any help, pointer, example code is appreciated.
    Thanks!

    Thanks for the answer.
    Looking at the example at the link you provided, AVTransmit3.java is pretty similar to what I have in the program.
    As far I can see write() method, in RTPSocketAdapter.java, does the actual data transfer in this example. However, in my program, start() in AVTransmit.java is called do start the tranmission. In start () method, processor.start() is called. Here is the code for that:
         * Starts the transmission. Returns null if transmission started ok.
         * Otherwise it returns a string with the reason why the setup failed.
        public synchronized String start() {
            String result;
            // Create a processor for the specified media locator
            // and program it to output JPEG/RTP
            result = createProcessor();
            if (result != null)
                return result;
            // Create an RTP session to transmit the output of the
            // processor to the specified IP address and port no.
            result = createTransmitter();
            if (result != null) {
                processor.close();
                processor = null;
                return result;
            // Start the transmission
            processor.start();
            return null;
        }Could I do what I want in a simple way without using sockets? Could I modify createTransmitter() to achieve this?
    Would it be possible to encrypt dataOutput before caaling createSendStream? Or does it not even make sense?
    sendStream = rtpMgrs.createSendStream(dataOutput, i);
        private String createTransmitter() {
            // Cheated.  Should have checked the type.
            PushBufferDataSource pbds = (PushBufferDataSource)dataOutput;
            PushBufferStream pbss[] = pbds.getStreams();
            rtpMgrs = new SessionManager[pbss.length];
            SessionAddress localAddr, destAddr;
            InetAddress ipAddr;
            SendStream sendStream;
            int port;
            SourceDescription srcDesList[];
            for (int i = 0; i < pbss.length; i++) {
                try {
                    rtpMgrs[i] = new RTPSessionMgr();          
                    srcDesList = new SourceDescription[] {
                        new SourceDescription(
                                            SourceDescription.SOURCE_DESC_EMAIL,
                                            "[email protected]",
                                            1,
                                            false),
                        new  SourceDescription(SourceDescription.SOURCE_DESC_CNAME,
                                            rtpMgrs.generateCNAME(),
    1,
    false),
    new SourceDescription(SourceDescription.SOURCE_DESC_TOOL,
    "JMF RTP Player v2.0",
    1,
    false),
    localAddr = new SessionAddress();
    port = portBase + 2*i;
    ipAddr = InetAddress.getByName(ipAddress);
    destAddr = new SessionAddress(ipAddr, port,
    ipAddr, port + 1);
    rtpMgrs[i].initSession(localAddr, srcDesList, 0.05, 0.25);
    rtpMgrs[i].startSession(destAddr, 1, null);
    temp = "Started transmission channel at " + ipAddress + " " + port + "\n";
    MyApp.DisplayMess(temp);
    //System.err.println("Created RTP session: " + ipAddress + " " + port);
    sendStream = rtpMgrs[i].createSendStream(dataOutput, i);
    sendStream.start();
    } catch (Exception e) {
    return e.getMessage();
    Thanks very much again!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problems with JMF and audio files.

    Sofware:
    Java Version 1.5.0_03
    JMF Version 2.1.1e
    Windows XP SP2
    I have a application that consists of 2 parts. The first is an editor for creating exercises, like multiple-choice, matching and so on. The second part is a &#8220;client&#8221;, used to solve the exercises. The client uses Java Webstart.
    When I include audio clips in the exercises they play just fine using the client, but in the editor program I just get a clicking sound, and then the application stops responding.
    The strange part is that the editor and client use the exact same code to playback audio clips.
    The old version of the editor (developed for Java 1.3.x) works just fine under Java 1.3.x, but when the same byte-code is launched under Java 1.5 I get the same problem (clicking sound and then the application stops responding).
    Any suggestions?

    When installing JMF, two new packages are stored in the jre\lib\ext folder : jmf.jar and sound.jar.
    Sound.jar contains the same api that are in the packages sound.midi and sound sampled contained in jre.
    Maybe these new api are an improved version but i noticed some trouble playing sound and i delete sound.jar file, now it works fine.
    Try this, maybe you had the same problem.

  • IPhone video and audio streaming over GSM and 3G networks?

    Is the iPhone 3G capable of streaming live audio and video from the iPhone 3G to an Xserve to a webpage, through GSM and 3G connections ?

    The iPhone camera does not support video at this time.

  • Is there any method to remember the running subtitle and audio stream when navigating through menus?

    I have a language Menu named 'Setup' with 4 buttons 1.English  2.Spanish  3.Spanglish  4.Subtitle Off.
    To reach this page you have to hit Setup button on Main Menu. The setup button takes to a sub-menu of Setup where I have a symbol of 'tick' at Subtitle Off indicating the state of the current subtitle stream. I have 3 more sub-menus with similar buttons but with 'tick' at different languages indicating the state of the current running/selected language, 2nd page has English with tick, 3rd page has Spanish with tick and 4th has Spanglish with tick. My client wants me to jump on the respective language ticked page when you hit the setup button on Main Menu. As far as I understand we cannot assign a code in Encore to a single button to read what subtitle stream is running.
    Is there any method to remember the running stream when navigating through menus?
    I have done this in Sonic Scenarist.
    Regards,
    A Gandhi

    I think this was added in a "newer" version of Encore (meaning anywhere from CS4 up). In any event, it is available in Encore CS6.
    There is a menu (not button) property that allows yoi9u to make the active subtitle track button the default (i.e. selected/highlight shows) just as you want.

  • HT201066 Record video and audio stream

    There doesn't appear to be any way to simply record the audio going to your speakers while recording the screen, at least not without using an internal or external microphone. Is there other software that will do this?

    I can't think of an easier way since GB doesn't record video. To make the syncing easier you could do a little clapperboard effect, like clapping your hands, at the beginning of the recording. Then you should be able to align picture and sound perfectly.

  • Bandwidth Shaping for limiting Video and Audio Streaming

    Hi,
    How do I setup this on the SRP527W?
    I already block most of the video stuff on the internet.
    But I want to make this one more step.
    Thanks   
    Best Regards,
    Mr. Simon Yee
    Document Control
    Budi Feed Sdn. Bhd.(827186-P)
    Lot 11940, Jalan Perajurit 1,
    Off Jalan Perajurit,
    Kampung Tengah,
    Telok Gong, 
    42000 Port Klang,
    Selangor Darul Ehsan.
    Tel :-- 603-3134 1081
    Notice of Confidentiality:
    The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.  Any review, re-transmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited.  If you received this in error, please contact the sender immediately by return electronic transmission and then immediately delete this transmission, including all attachments, without copying, distributing or disclosing same.

    Hello Mr Yee,
    I found a link from the cisco site where you could find the configuration steps for Traffic Shaping.
    http://www.cisco.com/en/US/docs/ios/12_0/qos/configuration/guide/qcgts.html
    hope you find this answer useful, if it was satisfactory  for you, please mark the question as Answered.
    Thank you

  • Getting Ripped DVD Video and Audio Into Encore

    Do you have previously authored DVDs that need rework?  Do you want to add menus with greater impact and functionality?  Do you want to add some additional program or supplemental material?  Does a client want their product demo DVD to be updated to reflect the capabilities of the new and improved version, but the source files no longer exist?  Using Adobe Encore DVD and a freeware utility called DVD Decrypter (DVDD), you can accomplish this quickly and easily.
    Disclaimer: I do not support the illegal copying and/or distribution of copyrighted works.  The authors and distributors of the software I use have made it clear that they do not support illegal copying.  This guide is intended solely to assist you in ripping and copying DVD video to which you have the legal rights.  Any use of this guide to infringe the copyright of someone else’s intellectual property is prohibited.
    This guide is based on Adobe Encore DVD 1.5.1 and DVD Decrypter version 3.5.4.0.  Let’s Begin!
    Place the DVD to be ripped in your DVD drive and launch DVDD.  If you have more than one drive (e.g., a DVD-ROM and a DVD burner) make sure the one with the disc is selected in the Source dropdown list in the main program window.  Now we need to set up DVDD to extract video in a way that is “Encore friendly”.  This is the toughest part of the whole exercise.  Click on the Tools menu item and choose “Settings…”. 
    Settings
    General Tab: You can leave these set at their defaults if you like.  Personally, I specify a custom Default Destination.  I put my ripped video assets all in one place anyway, and having a default destination means I have one less thing to do when I rip a DVD.
    IFO Mode Tab: Make sure that “Select Main Movie PGC” and “Enable Stream Processing” are checked.  “Uncheck Suspect Cells” is probably a good default safety check.  If your hard disks are formatted as NTFS, set File Splitting to “None”.  I leave “Copy IFO File” checked with the default sub-items checked.  Make sure that “Patch M2V Timecode” is unchecked.  The items in the Create Additional Files section are purely optional.  The author of DVDD has been kind enough to list which programs need which files; notice that Encore DVD isn’t listed as needing any of these extra files.  I do keep the “Stream Information” box checked.  DVDD generates very informative file names, but I like to keep “Include PGC Number” under File Names checked.  Be advised you will get some lengthy file names after DVDD is finished ripping.
    Stream Processing Tab: Since we enabled stream processing in the IFO Mode tab, we need to tell DVDD how to process those streams.  To save yourself time and confusion later, check the “Convert PCM to WAV” box.  Earlier versions of Encore required a Demuxed audio stream and a Raw video stream.  Encore 1.5.1 can accept either type of video stream (Raw or Demuxed) but it does still require a Demuxed audio stream.  However, I still recommend using Raw video and Demuxed audio, if only because it seems to be somewhat faster to process in DVDD.  This workflow is also backward-compatible with earlier versions of Encore.
    So let’s set up the Stream Processing tab now.  In the Demux box, enter “0x8? 0xA? 0xC?”.  This ensures that all audio streams in the selected PGC, whether AC3, PCM or MPEG will be set to Demux.  In the Raw box, enter “0xE0”.  This ensures that the video from the selected PGC will be set to Raw.  
    Additional Notes about the Stream Processing Tab:
    1. For those of you asking the question, “What the heck is a PGC?” it’s just DVD-speak for the titles in a DVD project.  And I’m not talking about the opening or end credits, either; I’m talking about the titles that result, for example, from the timelines you create in an Encore DVD project.  There is a subtle difference between a PGC and a VTS (title set), but that's not important right now.
    2. Happily, recent versions of DVDD create a WAV file after ripping that will import directly into Encore.  Versions prior to 3.2.0.0 would create a WAV file that had to be imported to, and exported from, a sound editing program like Adobe Audition, Goldwave or SoundForge before Encore would recognize it.
    Events Tab: For convenience sake, I recommend setting “Set Program Mode” in the Startup section to “IFO”.  That way, whenever you launch DVDD, it will look familiar to you.  You may safely ignore all of the other tabs in the Settings dialog. 
    Ripping
    1.Under the Input Tab of the main program window, select the PGC you want to rip.  You can only do one at a time.
    2.Switch to the Stream Processing Tab.  Verify that Enable Stream Processing is checked.
    3.Check or uncheck any or all of the video and audio streams that are listed.  Highlight each one to verify that all audio streams are set to Demux and the video stream is set to Raw.
    4.If you didn’t select Default Destination in the General Settings Tab, then you need to tell DVDD where to put the ripped files now.
    5.Click on the big DVD-to-Disk icon.
    6.DVDD will announce, quite loudly, when it has finished.  At that point you can rename the files or import them as is into Encore.
    I hope you find this guide useful and that it helps you get the most out of your investment in Adobe Encore DVD.
    Guide © Jeff Bellune 2005

    OK, I can't tell you what we are doing, you'll have to trust me that it's for a very good cause. I'll simplify the use case as an example. If I can do the following we'll be OK:
    1) Read video/audo files from a DVD that we created
    2) Open these files with the QuickTime Player, click on Export to Apple TV to create an output file.
    I'd rather not do an interim conversion of the video data (like use a 3rd party app to convert to mp4 first and then read into QT, but I'm considering a conversion to DV) because that could seriously hurt the apps effectiveness. I also can't use another app (MPEG Streamclip, HandBrake, VisualHub, etc.) to do the conversion.

Maybe you are looking for