MP4 with Processing - Problem

edited June 2014 in Library Questions

Hallo,

Problem, benötige Hilfe:

Wunsch:

  • mit Processing ein mp4 speichern (auf Basis von Einzelbildern)

Gemacht:

Fehler:

  • The type new ImageObserver(){} must implement the inherited abstract method ImageObserver.imageUpdate(Image, int, int, int, int, int)
  • No library found for com.xuggle.xuggler
    No library found for om.cuggle.mediatool

Unbenannt

_________________in english (i try)________________________

Hello

Problem, need help:

Wishes:

  • to save a mp4 with processing (based of singleFrames)

Done:

Issue:

  • The type new ImageObserver(){} must implement the inherited abstract method ImageObserver.imageUpdate(Image, int, int, int, int, int)
  • No library found for com.xuggle.xuggler
    No library found for om.cuggle.mediatool

Unbenannt

srry, but my english is not so well

Tagged:

Answers

  • Libraries must be installed in the sketchbook, the place where your sketches (Processing programs) are stored, not in the place where you installed Processing.

    See also How to Install a Contributed Library.

  • edited June 2014

    THX PhiLoh, but it doesn't work: it appears the same issue like before.

    1. i copied this filder https://github.com/artclarke/xuggle-xuggler/tree/master/src/com/xuggle in this folder C:/Users/Dog/Documents/Processing/libraries/com/xuggle/
    2. i unziped this Jar-file (C:/Programme (x86)/Java/jre8/lib/rt.jar) and copied the content (rt/Java) to C:/Users/Dog/Documents/Processing/libraries/java. Now it contains now f.e. C:/Users/Dog/Documents/Processing/libraries/java/awt/image/ImageObserver.class
    3. i downloaded "xuggle-xuggler-5.4.jar" renamed it in xuggle.jar and copied it in C:/Users/Dog/Documents/Processing/libraries/xuggler/ (like in the tutorial?!)

    please help me. the issue is again the same. :(

  • I don't understand the first two steps... Only the third one is necessary, I think. And the path should be: C:/Users/Dog/Documents/Processing/libraries/xuggler/library/xuggle.jar

  • edited June 2014

    thx, but the issue is also the same.

    The path is now: C:\Users\Georg\Documents\Processing\libraries\xuggler\library\xuggle.jar

    btw my Processing-Import-Code:

    import processing.opengl.*;
    
    import com.xuggle.xuggler.*;
    import com.xuggle.mediatool.*;
    
    import java.awt.image.BufferedImage;
    import java.awt.image.ImageObserver;
    import java.util.concurrent.TimeUnit;
    

    :(

  • Mmm, I copy & pasted paths from your message without really reading them... With a new eye (waking up...), I can see another issue: xuggle / xuggler. You have to choose with or without r. Ie. folder name and jar name should have the same name (without the .jar suffix, of course).

  • edited June 2014

    OK, out of curiosity, I tried to use this Xuggler. I downloaded the fat jar file at http://xuggle.googlecode.com/svn/trunk/repo/share/java/xuggle/xuggle-xuggler/5.4/ and renamed xuggle-xuggler-5.4.jar to xuggler.jar
    I put it in <Processing sketchbook path>/libraries/xuggler/library
    I copied the example sketch and modified it a bit. I think we can get rid of the ImageObserver, removing the error you had (Image is probably ambiguous by default).
    My slightly modifier sketch is:

    // Based on rbrauer's code: http://forum.processing.org/one/topic/sketch-video-catpure-with-ffmpeg-and-xuggle.html
    
    import com.xuggle.xuggler.*;
    import com.xuggle.mediatool.*;
    
    import java.awt.image.BufferedImage;
    import java.util.concurrent.TimeUnit;
    
    IMediaWriter mediaWriter;
    IStreamCoder streamCoder;
    BufferedImage bufferedImage;
    int videoRate = 30;
    long startTime;
    long frameTime;
    
    void setup()
    {
      size(1024, 768);
    
      ellipseMode(CENTER);
    
      mediaWriter = ToolFactory.makeWriter(sketchPath("output.mp4"));
      mediaWriter.addVideoStream(0, 0,
          ICodec.ID.CODEC_ID_MPEG4,
          IRational.make(videoRate),
          width, height);
      streamCoder = mediaWriter.getContainer().getStream(0).getStreamCoder();
    
      bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
      startTime = frameTime = System.nanoTime();
    }
    
    void draw()
    {
       background(sin(frameCount / 25f) * 255);
       ellipse(mouseX, mouseY, 100, 100);
       loadPixels();
    
       long currentTime = System.nanoTime() - frameTime;
       if (currentTime >= 1000.0 / videoRate)
       {
        bufferedImage.getGraphics().drawImage(g.getImage(), 0, 0, null);
        mediaWriter.encodeVideo(0, bufferedImage, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
        frameTime = System.nanoTime();
      }
    }
    
    void mouseClicked()
    {
      mediaWriter.close();
      exit();
    }
    

    Also used more explicit variable names...

    But there is a last problem which I don't have time, right now, to solve: this library depends on a number of other libraries (which might have their own dependencies!). A problem solved by Maven, Ivy or other build tools, but which we have to solve by hand in Processing...

    The dependencies are listed at: http://xuggle.googlecode.com/svn/trunk/repo/share/java/xuggle/xuggle-xuggler/5.4/xuggle-xuggler-5.4.pom
    Basically, we have to add a logger system and an Apache library

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.6.4</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>1.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>1.0.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.0.0</version>
      <scope>runtime</scope>
    </dependency>
    
  • edited June 2014

    Hello PhiLho,

    i renamed it in xuggler.jar and copied your code in my sketch.

    issue:

    df

    mmmh.. i don't understand your suggestion to add a logger system and an Apache library. >>What should i do with this content from the xuggle-xuggler-5.4.pom?

  • Mmm, it is a bit complex, I will go back there later.
    If you want to advance, go to Maven Central and try to locate the jars listed above. Then you can put them (no need to rename them) in the same folder than xuggler.jar.

  • After a long search i noticed that the "slf4j"-library was missed.

    import org.slf4j.*;

    now it works :)

    BUT: :/

    it plays the rendered Video faster as 30fps. if i change the variable vidRate=30 to 25 or 60, so it doesn't change the speed from the video.

    Question: How can i affect the speed from the video?????

Sign In or Register to comment.