Processing and 4K video (2160p)

Hey, I'm trying to make a project where a 4K video is played. I'm having some issues with the Movie class. The videos plays for 2 seconds then the sound stops and the video plays at about 2 fps.

Here are my video file settings:

Dimensions: 3840x2160
Codecs: H.264, AAC
Duration: 1m26s
Bitrate: 30mbps

And here is my code (pretty simple for now):

import processing.video.*;
import processing.opengl.*;
Movie movie;

void setup(){
    size(1280, 720, P3D);
    frameRate(30);

    movie = new Movie(this, "movie_30.mp4");
    movie.loop();
}

void draw(){
    background(0);
    image(movie,0,0,1280,720);
}

void movieEvent(Movie m) {
    m.read();
}

After messing with bitrates and resolutions it seems that Processing can't read 4K files, is there any way to work around this ?

Thanks !

Tagged:

Answers

  • edited December 2014
    • Why do you need P3D renderer in order to display some Movie? :-&
    • Also, image() w/ 5 parameters is slow due to resizing.
    • Actually, set() & background() are faster than image()! \m/
    • What about noLoop() + redraw()? Only refresh canvas when a new movieEvent() is available! *-:)
    • And last optimization, size() w/ exact Movie dimensions! :-bd

    Dunno whether those speedier methods gonna make any diff. But it doesn't hurt trying them out, does it? :-@

    /**
     * Speediest Movie Play (v1.0)
     * by GoToLoop (2014/Dec/04)
     *
     * forum.processing.org/two/discussion/8471/
     * processing-and-4k-video-2160p
     */
    
    import processing.video.Movie;
    Movie mv;
    boolean isPaused;
    
    void setup() {
      if (mv == null) {
        ( mv = new Movie(this, "movie_30.mp4") ).loop();
        while (mv.width == 0)  delay(50);
      }
    
      size(mv.width, mv.height, JAVA2D);
    
      noSmooth();
      noLoop();
      frameRate(30);
    }
    
    void draw() {
      background(mv);
    }
    
    void mousePressed() {
      if (isPaused ^= true)  mv.pause();
      else                   mv.play();
    }
    
    void movieEvent(Movie m) {
      m.read();
      redraw();
    }
    
  • Thanks for the response, I tried your code but I still get the same 2 seconds of sound + slow video playback.

    I had P3D on so I could apply a shader to a plane with the movie as a texture. I simply forgot to remove it for the sake of simplicity.

  • Just a guess, try running 64bit Processing and increasing the maximum available memory in the Processing preferences settings.

  • Another shot in the dark. Try video uncompressed or using a codec that is low in processor demanding, like appleProRes. The file is huge, but the performance tends to be better when playing. Heavily compressed codecs need a lot of cpu to play.

  • I'm running processing on a Mac so it's already 64 bits, I upped the memory to 1024Mb and saw no change, I'll try switching to AppleProRes. I might also test this on a PC to see if OSX is the issue here.

  • edited December 2014

    After running it on Windows (without success), with ProRes and MP4 formats, I can almost confirm that 4K is not supported as of right now by Processing.

  • edited December 2014

    And by extension to "gstreamer-java" framework either. Which "processing-video" is a wrapper for it: :(|)

  • I have the same issue, any clue to play 4K video with processing ?

Sign In or Register to comment.