script dies quietly -- no logs, memory ? gc ?

edited March 2018 in Raspberry PI

the following code performs a random scratch between two videos ( they should be of equal length: for testing purposes, use the same video under 2 different names). It will run for anywhere between a few hundred and a few thousand draw() cycles before it hangs. I believe that this is memory/gc related as the prog survives longer for smaller format movies but upping GUI memory to 750M ( on a Pi3) cannot ultimately save it. I cannot find any logs.

Down to the choice of library this code runs without issue on Mac OS with 336 I need this to run as a appliance hence my choice of RPI

     import gohai.glvideo.*; 

     class GLmovie_ext {
        GLMovie mov;
        float length;
     };

     GLmovie_ext[] m = new GLmovie_ext[2];

     int now_showing;
     boolean loaded = false;

     void setup() {
        //frameRate(50);
        size(500, 500, P2D);
        //fullScreen(P2D);
        //noCursor();
        m[0] = new GLmovie_ext();
        m[0].mov = new GLMovie(this, "clock_red.m4v", GLVideo.MUTE);
        m[1] = new GLmovie_ext();
        m[1].mov = new GLMovie(this, "clock_green.m4v", GLVideo.MUTE);

        thread("loadMovies");
     }

     void loadMovies() {
        m[0].mov.loop();
        m[1].mov.loop();
        m[0].mov.volume(0);
        m[1].mov.volume(0);
        while (! m[0].mov.playing() || ! m[1].mov.playing()) delay(10);
        m[0].length = m[0].mov.duration();
        m[1].length = m[1].mov.duration();
        while ( m[0].length < 32 || m[1].length < 32 || abs( m[0].length - m[1].length ) > 0.1 ) {
           m[0].length = max( m[0].length, m[0].mov.duration());
           m[1].length = max( m[1].length, m[1].mov.duration());
        }
        now_showing = 1;
        runTime = (m[0].length + m[1].length) / 2.0;
        loaded = true;
     }

     float cumulError = 0;
     int drawCnt = 0;
     float runTime;

     void draw () {
        background(0);
        clear();
        if (!loaded) {
           textSize(10);
           fill(255);
           text("loading ...", width/2, height/2);
        } else {
        if (m[now_showing].mov.available()) m[now_showing].mov.read() ;
        image( m[now_showing].mov, (width-m[now_showing].mov.width)/2, (height-m[now_showing].mov.height)/2);
        int alternate = (now_showing+1) %2;
        if ( runTime < m[now_showing].mov.time() + m[alternate].mov.time() ) {
           float cutPoint = m[now_showing].mov.time();
           alternate = now_showing;
           now_showing = (now_showing+1) %2;
           cutPoint = random(0.99)save+(runTime-save); // in the range from here to other's end point
        // now get alternate where we need it
           float distance = abs(cutPoint - save);
           float gap = runTime - 2distance; // -1 .. -ve --> overshoot +ve means time in hand .. +1
           float correction = save + gap;
           while (correction > runTime) correction -= runTime;
           m[alternate].mov.jump( correction);
        }
        }
        stroke(color(#FF0000));
        fill(color(#FF0000));
        line(0, 10, width * (m[0].mov.time()/runTime), 10);
        if (now_showing == 0) {
           ellipse(0, 10, 10, 10);
        }
        stroke(color(#00FF00));
        fill(color(#00FF00));
        line(width * (1-m[1].mov.time()/runTime), 20, width, 20);
        if (now_showing == 1) {
           ellipse(width, 20, 10, 10);
        }
        drawCnt++;
        text(drawCnt, 40, 40);
        if (drawCnt % 1000 == 0) System.gc();
     }

Answers

Sign In or Register to comment.