We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
GO back edit your post
Select code
Hit ctrl-o
Empty line before and after the code
Would you expect that to do a multi-level pretty print ? (I am using a chromebook so am used to quirks of nature )
Ctrl-t in the pde editor will indent stuff nicely. Then paste it here, highlight it and hit Ctrl-o.
So I have indented and reposted... Watching this from top command, it appears to be running, burning the same amount of CPU and memory. Just not getting to draw() anything
The jump() always hang. I spent a lot of time with that, and I couldn't find any solution.
https://forum.processing.org/two/discussion/13673/jump-in-videolibrary-causes-java-error#latest
I haven't tried this fork yet
https://github.com/codeanticode/processing-glvideo/commit/e101d3e28c9d3d3fb48844a1341065c7ac575494
Maybe it solves the problem.
But don't use jump() with the current version of the library. Your program will always hang, it is just a matter of time.
@RaulF : thanks for joining in, will take a look at the fork
You are welcome. Let me know if it works.
prospect of being 140 commits behind is too daunting. I will have to park this project and hope @gohai can find time to think about this