Menu

mpeg2, works in JMStudio, not in SimplePlayer

user
jignes
2004-08-10
2004-09-15
  • jignes

    jignes - 2004-08-10

    I am trying to develop a tool to extract frames from a video sequence recorded with a DVD Recorder, with the purpose of importing the frames into the image processing software ImageJ (written in JAVA). I want to use the JMF tools, and  I want to use fobs to provide the codec for the MPEG2 video file (*.m2v) which I extract from a VOB file with a demultiplexer.

    After installing fobs, I am able to open the *.m2v video using JMStudio perfectly. However, I am UNABLE to open the very same *m2v video file using a simple JMF player. The same simple player is able to open other files. In fact, if I change the extension of the video file to *mpg, the SimplePlayer is opens it with the crappy mpeg2 codec from JMStudio.

    The following is the code of the simpleplayer, the error message (stderr, stdout), and the log file from JMF. I don't know if the error is a bug in fobs, or a problem in my configuration. Thanks for the help and congratulations on an excellent project!.

    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;

    import java.net.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.protocol.*;

    public class JMFSimplePlayer extends Frame implements ControllerListener,WindowListener {

      Player videoPlayer;
     
      DataSource dataSource; //of the capture devices

      public JMFSimplePlayer(String title) {
        super(title);
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            dispose();
          }
        });
        play();
      }
       
      void play() {
        try {
          FileDialog fd = new FileDialog(this, "Select File", FileDialog.LOAD);
          fd.show();
          String filename = fd.getDirectory() + fd.getFile();
          MediaLocator mediaLocator = new MediaLocator("file:///" + filename);
          videoPlayer = Manager.createPlayer(mediaLocator);
          System.out.println("Adding controller listener");
          videoPlayer.addControllerListener(this);
          System.out.println("Starting player ...");
          videoPlayer.start();
        }
        catch (Exception e) {
          System.out.println(e.toString());
        }
      }

      void stop() {
        if (videoPlayer!=null) {
          videoPlayer.stop();
          videoPlayer.deallocate();
        }
      }

    public synchronized void controllerUpdate(ControllerEvent event) {
        System.out.println(event.toString());

        if (event instanceof RealizeCompleteEvent) {
          Component comp;

          System.out.println("Adding visual component");
          if ((comp = videoPlayer.getVisualComponent()) != null)
            add ("Center", comp);
          System.out.println("Adding control panel");
          if ((comp = videoPlayer.getControlPanelComponent()) != null)
            add("South", comp);
          validate();
        }
      }

      public static void main(String[] argv) {
        JMFSimplePlayer myFrame = new JMFSimplePlayer("Java Media Framework Project");
        myFrame.show();
        myFrame.setSize(300, 300);
      }
     
      public void windowActivated(WindowEvent we) {}
      public void windowClosed(WindowEvent we) {}
      public void windowClosing(WindowEvent we) {}
      public void windowDeactivated(WindowEvent we) {}
      public void windowDeiconified(WindowEvent we) {}
      public void windowIconified(WindowEvent we) {}
      public void windowOpened(WindowEvent we) {}

    }

    Output from STDERR:

    Open log file: c:\temp\jmf.log
    Parser Dynlink resolved
    javax.media.IncompatibleSourceException: Invalid DataSource
            at com.omnividea.media.parser.video.Parser.setSource(Parser.java:338)
            at com.sun.media.BasicSourceModule.createDemultiplexer(BasicSourceModule
    .java:138)
            at com.sun.media.BasicSourceModule.createModule(BasicSourceModule.java:9
    6)
            at com.sun.media.PlaybackEngine.setSource(PlaybackEngine.java:124)
            at com.sun.media.MediaPlayer.setSource(MediaPlayer.java:30)
            at javax.media.Manager.createPlayerForSource(Manager.java:1453)
            at javax.media.Manager.createPlayerForContent(Manager.java:1326)
            at javax.media.Manager.createPlayer(Manager.java:417)
            at JMFSimplePlayer.play(JMFSimplePlayer.java:32)
            at JMFSimplePlayer.<init>(JMFSimplePlayer.java:23)
            at JMFSimplePlayer.main(JMFSimplePlayer.java:69)
    javax.media.NoPlayerException: Cannot find a Player for :file:///C:\temp\movie.m2v

    And the LOG file:

    #
    # JMF Version 2.1.1e
    #

    ## Platform: Windows XP, x86, 5.1
    ## Java VM: Sun Microsystems Inc., 1.4.1_02

    $$ Profile: instantiation: 0 ms

    !! Input DataSource: com.omnividea.media.protocol.file.DataSource@1989f84
    !!   is not compatible with the MediaEngine.
    !!   It's likely that the DataSource is required to extend PullDataSource;
    !!   and that its source streams implement the Seekable interface
    !!   and with random access capability.
    $$ Profile: instantiation: 0 ms

    !! Input DataSource: com.sun.media.protocol.file.DataSource@123b25c
    !!   is not compatible with the MediaEngine.
    !!   It's likely that the DataSource is required to extend PullDataSource;
    !!   and that its source streams implement the Seekable interface
    !!   and with random access capability.

     
    • José San Pedro

      José San Pedro - 2004-08-10

      Hi,

      the problem seems to be in the DataSource that the parser is receiving... Try the following steps:

      1 - Make sure that com.omnividea is in your Protocol prefix list and Content Prefix List. Make sure that it is on the top of both lists too.

      2 - If the error persists, try using the Manager.createPlayer(DataSource) method instead of Manager.createPlayer(MediaLocator). To create the datasource use the following:
      videoPlayer = Manager.createPlayer(new com.omnividea.media.protocol.file.DataSource(mediaLocator));

      instead of

      videoPlayer = Manager.createPlayer(mediaLocator);

      I think this should solve your problem. Please, report back the results you get!

      Thanks for using Fobs.

      Cheers!

       
    • jignes

      jignes - 2004-08-11

      Thanks for your help.
      Unfortunately, the problem persists!

      com.omnividea are at the top of both prefix lists (they were already!).

      I have modified the JMFSimplePlayer class like you suggest, to create the player from a DataSource:

      MediaLocator mediaLocator = new MediaLocator("file:///" + filename);
           
            //videoPlayer = Manager.createPlayer(mediaLocator);
            DataSource ds = new com.omnividea.media.protocol.file.DataSource(mediaLocator);
            videoPlayer = Manager.createPlayer(ds);

      (I also tried the more compact version, without defining the ds variable, but it doe not matter...).

      Now, the error message in STDERR is less descriptive:

      Open log file: c:\temp\jmf.log
      Parser Dynlink resolved
      javax.media.NoPlayerException: Cannot find a Player for: com.omnividea.media.pro
      tocol.file.DataSource@1cbfe9d

      and the log file:

      #
      # JMF Version 2.1.1e
      #

      ## Platform: Windows XP, x86, 5.1
      ## Java VM: Sun Microsystems Inc., 1.4.1_02

      $$ Profile: instantiation: 0 ms

      !! Input DataSource: com.omnividea.media.protocol.file.DataSource@1cbfe9d
      !!   is not compatible with the MediaEngine.
      !!   It's likely that the DataSource is required to extend PullDataSource;
      !!   and that its source streams implement the Seekable interface
      !!   and with random access capability.

      As a note, let me add that, since now the use of com.omnividea Datasource is forced, the same error is obtained regardless of the movie file I try to open. Earlier (when createPlayer(MediaLocator) was used), only the movie with extension "*.m2v" gave the error. Probably this is an obvious behavior, but I report it just in case...

      And, of course, JMStudio can still open the *.m2v movie...

      Cheers!

       
    • Nobody/Anonymous

      Hi again,

      sorry for have you waiting... I'm quite busy right now.

      Anyway, I've been testing your code and it works like a charm for all the files I've tested. So... here comes the questions:

      1 - What version of Fobs and ffmpeg are you using??
      2 - How do you get the m2v file. Do you use ffmpeg to encode it? Maybe it will be useful if you could provide me with a small sample I can use to test and debug this issue.

      You can use the anonymous ftp server (ftp://138.100.76.92) to upload the sample file (please... not to big!!).

      Thanks for your cooperation in debugging fobs.

      cheers!

      Jos San Pedro Wandelmer

       
    • jignes

      jignes - 2004-08-16

      I have tryied to isolate FOBS as much as possible from the system, to try to pinpoint the problem.
      I start from a fresh installation of FOBS, version 0.2 (Fobs - 0.2 - 2004/06/04), and I use the jmf.properties file as included in the FOBS installation.
      I have stored my movie files and my JMFSimplePlayer source and class files into the FOBS folder.
      Then, I clear CLASSPATH prior to executing the JMFSimplePlayer class, and I invoke:

      java -classpath fobs4jmf.jar;jmf.jar;. JMFSimplePlayer

      If I load an avi movie, compressed with the Cinepack codec, everything works fine.
      If I try to load the *.m2v movie, I get the error messages.

      I have uploaded the movie.m2v file (where I have detected these problems) to the ftp address you provided. The file comes from video recorded using a Philips DVD-recorder, and it has been demuxed into the movie.m2v file using DVD-Decrypter.
      As I told you, my goal is to be able to use the recordings performed with a DVD-Recorder directly with the image processing software ImageJ, without th e need of a Video Frame Grabber.

      It would be great if you could test that video sequence in your system. I can open it without a problem with JMFStudio (java -classpath fobs4jmf.jar;jmf.jar;. JMFStudio), but I am unable to do it with the JMFSimplePlayer program.

      Thanks.

      Jordi.

       
      • José San Pedro

        José San Pedro - 2004-08-16

        Hi,

        well... I don't know if this is good or bad news... I've tried the video you uploaded to the ftp server with the Mac version of Fobs and the code you posted (JMFSimplePlayer.java) and everything seems to work fine. This is likely an issue with the native part in windows. Problem is I don't have windows available at the moment so I can't debug it. However, I will try the linux verison as soon as I can.

        Keep me informed of any progress on your side.... I will do so!

        Cheers!!!

         
    • jignes

      jignes - 2004-08-26

      Hi Jos,
      have you had a chance to look into the linux version of Fobs to see if it can open the mpeg2 file? As I said,
      using
      DataSource ds = new com.omnividea.media.protocol.file.DataSource(mediaLocator);
      videoPlayer = Manager.createPlayer(ds);

      in the SimplePlayer results in the error appearing regardless of the type of the movie file. So there is clearly a nasty interaction between some components  that prevents Fobs to start when using the SimplePlayer (?). However, it works fine launching JMStudio.
      It it helps, I managed to recompile Fobs in my windows machine, so I can alter any of the source files. If you think of some debugging test  I may try I would do it gladly.
      Also, I tried running JMFSimplePlayer in different versions of Java and I get the same result.

      Cheers,
      Jordi.

       
      • José San Pedro

        José San Pedro - 2004-08-26

        Hi Jordi,

        I'm sorry but I haven't had the chance to try the linux version. I'm currently on holidays, but next Wednesday I think I will have the chance to give it a glance. As I told you, mac version seems to work fine, so it must be some native related issue. I hope we can find where.

        However, if you can do some tests meanwhile I can give you some clues. The exception you get is thrown by the Parser class in the setSource method. This is the code:

            if (! (source instanceof com.omnividea.media.protocol.file.DataSource))
            {
              IncompatibleSourceException exp = new IncompatibleSourceException("Invalid DataSource");
              exp.printStackTrace();
              throw exp;
            }
            else {
              dataSource = (com.omnividea.media.protocol.file.DataSource) source;
              //System.out.println("\tPARSER URL: "+dataSource.getUrlName());
              if (dataSource.getUrlName() == null) {
                throw new IncompatibleSourceException("Invalid Datasource");
              }
            } // else is our DS

        So, as we know that the datasource is a com.omnividea.media.protocol.file.DataSource, the only possibility left is that the getUrlName returns a null string. I will try this as soon as i have the chance.

        Of course, please report back any results you get to help other users.

        Cheers

         
    • Christian Berger

      Hi Jordi, hi Jos, hi Folks!

      I've got today the same problem as described above: A DIVX5.0 movie can be played by JMStudio using fobs4jmf but not with a simple player environment in WinXP (not tested Linux)

      I've installed mingw (it's really tricky to get Python working for compiling fobs4jmf ;) and realized that decoder.cpp located in jmf-pi/ gets a corrupted reference to the parameter filename in the function avInit(...).

      So, I've manually entered my filename of the video file an everything works fine. Therefore, the problem is caused by a class calling avInit(...). In the fobs4jmf package, it's the class com.omnivideo.media.parser.video.Parser.

      I've checked the function setSource(DataSource source) and analyzed its parameter source. The object is fine, so, the error occurs inside that function. The problematic part is the call dataSource.getUrlName(). That function returns a null pointer and thus, the playback fails.

      I've replaced that call with the following:
      source.getLocator().getURL().toExternalForm() and replaced the parts concerning URL (i.e. I've removed "file://" and so on) so that the resulting string matched the absolute path of my video file
      (file://c:/movie/video.avi ---> c:\\\\movie\\\\video.avi).

      Then, I've passed that string to avInit that gets now "c:\\movie\\video.avi" and "tada", everything works as expected.

      After the weekend, I'll search the problem in the class com.omnividea.media.protocol.file.DataSource for providing a patch.

      Best regards,

         Christian

       
      • José San Pedro

        José San Pedro - 2004-09-10

        Hi Christian (and everyone),

        You've done a great job locating the bug. I did the same process and reach the same conclussions but I'm really busy now preparing the upcoming Fobs-0.3pre1. If you are able to provide such a patch I will be really greatful (as I'm sure will be everyone looking at this thread). I will include it in 0.3, of course. Thanks very much for your contribution. I hope this encourages other people to look inside the code and improve it.

        Cheers.

        PD: Tell me if you are not able to finish the patch so I can begin working on it.

         
    • Christian Berger

      Hi Folks (for those who aren't subscribed :)

      As promised I've made the patch concerning the
      problem mentioned above.

      I've placed the patch along with precompiled binaries and sources on my homepage:

      http://www.tu-bs.de/~y0018536

      If you've already installed the binary installation of
      fobs4jmf you simply have to replace fobs4jmf.jar
      with the new one downloadable from my site.

      Best regards,

         Christian

       
    • jignes

      jignes - 2004-09-13

      Hi Christian (and all other listeners...),

      I have tried your modified version of fobs4jmf, but it still does not work.
      I get the same error than before when trying to open a *m2v video stream with the SimplePlayer (JMStudio still works fine...). This is the new log file:

      #
      # JMF Version 2.1.1e
      #

      ## Platform: Windows XP, x86, 5.1
      ## Java VM: Sun Microsystems Inc., 1.4.1_02

      $$ Profile: instantiation: 16 ms

      !! Input DataSource: com.omnividea.media.protocol.file.DataSource@d1fa5
      !!   is not compatible with the MediaEngine.
      !!   It's likely that the DataSource is required to extend PullDataSource;
      !!   and that its source streams implement the Seekable interface
      !!   and with random access capability.
      $$ Profile: instantiation: 0 ms

      and this is the output to stdout:

      Open log file: C:\Archivos de programa\Fobs4JMF\jmf.log
      fobs4jmf - class library loaded.
      javax.media.NoPlayerException: Cannot find a Player for :file:///C:\Archivos de
      programa\Fobs4JMF\movie.m2v

      Note that "fobs4jmf - class library loaded" is printed, and not "Parser Dynlink resolved", so I am clearly using your modified fobs4jmf.  The log file and the error message looks almost exactly like with the original fobs4jmf. Only one difference: the "instantation" time is 16 ms (it was 0 ms in the original).

      I have looked at your source files, and I can see your modifications in DataSource.java, but I am unable to find any modifications in the Parser.java.

      Could you verify that there is nothing wrong with your fobs4jmf.jar?

      Thanks a lot!!

      P.S. : for some reason I am unable to recreate the jar file myself, to help in the debugging. It is probably "Java 101", but how do you build the jar file? (I am able to compile the *.java files, but the jar file I build does not seem to work... ?).

       
    • Christian Berger

      Hi jignes!

      I've checked your movie, too, and for me, it works fine (it's a gray scaled movie, "Q+0.1 dated from 27/07/04", is that correct?).

      Have you checked your movie with JMStudio?

      Another hint: Try to pass "file://c:\..." as an argument to the MediaLocator class rather than "file:///c:\...".

      I'll check the URL syntax if three "/"'s are allowed. If so, I have to modify my sources a little bit.

      Good luck,

         Christian

       
    • jignes

      jignes - 2004-09-14

      IT WORKS!!!!

      Thanks a lot, Christian.
      You were right: there was one slash too many. I have passed "file://c:\..." to MediaLocator instead of "file:///c:\..." and it works!
      Now, I will try to go beyond the SimplePlayer...

      Thanks again.

      Cheers,
      Jordi.

       
    • Christian Berger

      Hi Jordi, hi Folks!

      I've fixed the bug with (many :) leading slashes tomorrow and the new one is already downloadable from my website:

      http://www.tu-bs.de/~y0018536

      Best regards,

         Christian

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.