Forums > Javascript

JitterListener and jit.qt.movie read…bug?

July 5, 2007 | 8:17 pm

I would expect that a JitterListener would catch the "read" message that normally comes out of a jit.qt.movie object, but this doesn’t seem to be the case? Here is a simple javascript and patch that I would expect this to post a "read <1/0>" in the max window…but it does not! It does, however, post a "flatten" message after that is successful.

/*
listens to a jit.qt.movie’s output. It doesn’t seem to generate a "read" message after I read a file? The savemovie and flatten are in here simple to demonstarte that the listener is working at least for the "flatten" command
*/

var mov01 = new JitterObject("jit.qt.movie");
mov01.autostart = 0;
var mov01listen = new JitterListener(mov01.getregisteredname(), listenresults);
var movpath = ".";

function listenresults(event)
{
post("nlistener",event.eventname);
}

function readmov(v){
mov01.read(v);
mov01.savemoviecopy(movpath);
mov01.flatten(movpath);
}

function savepath(v){
post("npath",v);
movpath = v+"junk.mov";
}

//end simplelistener.js

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 188 172 63 196617 jit.qt.movie;
#P newex 211 30 48 196617 loadbang;
#P message 212 54 29 196617 path;
#P newex 202 109 88 196617 prepend savepath;
#N thispatcher;
#Q end;
#P newobj 212 75 61 196617 thispatcher;
#P message 89 109 99 196617 readmov dozer.mov;
#P newex 112 132 88 196617 js simplelisten.js;
#P connect 1 0 0 0;
#P connect 3 0 0 0;
#P connect 2 1 3 0;
#P connect 5 0 4 0;
#P connect 4 0 2 0;
#P window clipboard copycount 7;


July 5, 2007 | 8:22 pm

also, i’d expect the savemoviecopy to generate something that the listener would "hear", but it doesn’t seem to either…

p


July 9, 2007 | 5:13 pm

if I can’t get "read" reportage from the jitter listener, is there another way to find out if a js-instance of jit.qt.movie has sucessfully read a movie? I was hoping to incorporate this with a Task, such that once the listener heard the file was read, it would execute the Task.


July 9, 2007 | 6:10 pm

all you have to do is read the movie with

result = mov01.read(v);

then result[0] will return the name of the file, and result[1] will return a 0 or a 1 depending on whether the read was successful.


July 9, 2007 | 6:22 pm

right…I guess the sad part is that sequencing this with Tasks is perhaps more of a pain. I did something similar with the Listener for flatten, and eventually got that to work, and I was hoping to pretty much reuse that code but listen for "read", rather than flatten. I expected the "read" to come from the Listener, since the Jitter 1.62 docs, when discussing the Listener in Tutorial 47, state:
"…For example, when you read a movie file into jit.qt.movie, the
object outputs the message read followed by the movie?s filename and a status number out its status outlet. "


July 9, 2007 | 6:25 pm

I am pretty sure that asyncread works with the Listener. read, being
synchronous, doesn’t.

jb

Am 09.07.2007 um 18:22 schrieb pnyboer:

>
> right…I guess the sad part is that sequencing this with Tasks is
> perhaps more of a pain. I did something similar with the Listener
> for flatten, and eventually got that to work, and I was hoping to
> pretty much reuse that code but listen for "read", rather than
> flatten. I expected the "read" to come from the Listener, since the
> Jitter 1.62 docs, when discussing the Listener in Tutorial 47, state:
> "…For example, when you read a movie file into jit.qt.movie, the
> object outputs the message read followed by the movie?s filename
> and a status number out its status outlet. "


July 9, 2007 | 6:34 pm

AH! Thanks Jeremy. substituting "asyncread" for "read" in the above script does indeed result in a "read" message coming from the listener.


July 10, 2007 | 4:02 am

Can you stand another one? I hope so, cuz I seem to surfing the edges of Max scheduling, and not understanding it.
This simple, but complete, patch and javascript are an attempt to read a folder of movies and output a sample frame from each, using a Task and JitterListener. The big mystery to me is why when I use the mov.matrixcalc() method in function thecallback(), it doesn’t actually output a matrix. The simple example of "readit", when called from the outside does what I want to do, so I know I’m using the correct code to output a matrix from a jit.qt.movie in js. I presume it has to do with the asyncread, which the JitterListener seems to say is all finished, but it is apparently not, since the matrixcalc results in nothing!

Is there a way to get this working??

Thanks,

Peter.

#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 394 301 127 196617 for the sake of testing , store up to 72 images for easy recall;
#P window linecount 4;
#P comment 389 86 127 196617 read , rather than asyncread each movie in the folder , and a frame is output after each read;
#P window linecount 1;
#P message 21 151 22 196617 set;
#P window linecount 4;
#P comment 141 94 139 196617 should output the 30th frame from each movie read….but it doesn’t , i guess becuase of the "asyncread";
#P comment 324 47 48 196617 bang out the last movie’s matrix;
#P window linecount 1;
#P comment 185 254 38 196617 count:;
#P number 218 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 185 235 35 196617 total:;
#P number 218 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 422 230 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 422 254 82 196617 outputmatrix $1;
#P newex 343 253 72 196617 prepend index;
#P user jit.pwindow 310 306 82 62 0 1 0 0 1 0;
#P newex 311 231 27 196617 t l b;
#N counter;
#X flags 0 0;
#P newobj 343 231 66 196617 counter;
#P newex 371 210 21 196617 t 0;
#P newex 311 281 158 196617 jit.matrixset 72 4 char 320 240;
#P button 131 232 15 0;
#P number 381 46 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 381 68 52 196617 readit $1;
#P button 309 46 15 0;
#P newex 45 129 62 196617 prepend set;
#P window linecount 0;
#P message 45 150 244 196617;
#P user jit.pwindow 46 232 82 62 0 1 0 0 1 0;
#P window linecount 1;
#P newex 131 173 91 196617 prepend drawtiles;
#P newex 131 206 115 196617 js draw_tiles_async.js;
#P comment 149 55 127 196617 drag a folder of clips here;
#P user dropfile 131 36 298 90 1;
#P fasten 18 0 17 0 427 249 427 249;
#P connect 9 0 8 0;
#P connect 12 0 13 2;
#P connect 3 0 2 0;
#P fasten 3 0 12 0 136 200 376 200;
#P connect 13 0 16 0;
#P connect 14 1 13 0;
#P connect 11 0 15 0;
#P connect 14 0 11 0;
#P fasten 17 0 11 0 427 275 316 275;
#P fasten 16 0 11 0 348 275 316 275;
#P fasten 2 0 4 0 136 228 52 228;
#P connect 2 0 10 0;
#P fasten 2 0 14 0 136 226 316 226;
#P hidden connect 2 2 21 0;
#P fasten 2 1 19 0 188 224 223 224;
#P fasten 7 0 2 0 314 194 136 194;
#P fasten 8 0 2 0 386 197 136 197;
#P fasten 5 0 3 0 50 170 136 170;
#P fasten 0 0 6 0 136 109 50 109;
#P connect 0 0 3 0;
#P connect 6 0 5 0;
#P connect 25 0 5 0;
#P window clipboard copycount 28;

//—–begin draw_tiles_async.js

/*
takes a folder of movies and tries to asynchronously grab "thumbnails" from each. However, even though the JitterListener reports a "read", it doesn’t seem to be able to immediately output a matrix.

*/

autowatch = 1;
outlets = 3;
mov = new JitterObject("jit.qt.movie");
mov.autostart = 0;
mov.adapt = 1;
var movlisten = new JitterListener(mov.getregisteredname(), thecallback);

var movepath;
var counter = 0;
var total = 0;
var TASK_INTERVAL = 1;
var DRAWIT = new Task(readtask,this);
var clips = new Array();
var tmpmatrix = new JitterObject("jit.matrix");

function drawtiles(topath){
counter = 0;
var g = new Folder(topath);
g.typelist = ["MooV","mpg4","dvc!","MPEG","MPGa","MPGv","MPGx","SWFL","SWF","JPEG","GIF","GIFf","PNG","PNGf","8BPS","TIFF","TGA","PICT","SWF","BMPf","BMP","qtif","SGI","TPIC","PNTG","qdgx","PFix","PICS","MP3","MPG3","AIFF","WAVE","Mp3 ","????"];
total=g.count;
outlet(1,total);
if(g.count){
for (var i=0;i< g.count;i++) {
g.next();
var thefile = g.pathname+"/"+g.filename;
clips[i] = thefile;
post("filling array: ",i,thefile,"n");
}
g.close();
}

movepath = topath;
if (!DRAWIT.running){
DRAWIT.execute();
}
}

function readtask(){
mov.asyncread(clips[counter]);
}
readtask.immediate = 1;

function thecallback(event)
{
if (event) post("nlisten",event.eventname);
if (event.eventname=="read"){
mov.frame(30);
mov.matrixcalc(tmpmatrix,tmpmatrix);
outlet(0,"jit_matrix",tmpmatrix.name);
outlet(2,counter);
counter++;

if (counter
}
}

function bang(){
mov.matrixcalc(tmpmatrix,tmpmatrix);
outlet(0,"jit_matrix",tmpmatrix.name);
}

function readit(v){
mov.read(clips[v]);
mov.frame(30);
mov.matrixcalc(tmpmatrix,tmpmatrix);
outlet(0,"jit_matrix",tmpmatrix.name);
}

//end draw_tiles_async.js


July 24, 2007 | 11:02 am

Hi Peter

Just got around to taking a look at this. It appears that, yes, there
is a "sync" problem with asyncread and the JitterListener. I don’t
know precisely when this will get fixed, but it will get fixed.

jb

Am 10.07.2007 um 06:02 schrieb pnyboer:

>
> Is there a way to get this working??


July 25, 2007 | 3:56 am

ok, thanks for the confirmation. i thought it was further evidence of not knowing what the hell I’m really doing! Looking forward to a fix!


July 25, 2007 | 6:31 pm

i’m not so sure it’s just a javascript problem, as I encounter a similar difficulty with regular old max patching. This patch, when used with a library of DV clips, demonstrates that the "read" message from an asyncread isn’t actually reported after the movie is "readable" by qt.movie. I would expect that, in this patch, asyncread and read would give similar results.

#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 267 368 187 196617 even with high values of delay , async still doesn’t cooperate;
#P comment 191 143 187 196617 i can reproduce this problem best with DV movies on my MacBookPro 2.33.;
#P number 233 370 35 9 0 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 197 372 32 196617 del 0;
#B color 5;
#P toggle 191 95 15 0;
#P newex 182 219 27 196617 + 1;
#P user jit.pwindow 103 73 82 62 0 1 0 0 1 0;
#P newex 180 281 94 196617 prepend asyncread;
#P newex 218 263 68 196617 prepend read;
#P newex 182 241 47 196617 gate 2 1;
#B color 5;
#P window setfont Arial 9.;
#P newex 100 202 69 131137545 prepend prefix;
#P window setfont Arial 12.;
#P user ubumenu 190 74 157 131137548 0 1 1 0;
#X add "Clip 01_2024_699.dv";
#X add "Clip 01_2045_719.dv";
#X add "Clip 01_2057_948.dv";
#X add "Clip 01_2068_530.dv";
#X add "Clip 02_2017_643.dv";
#X add "Clip 02_2025_628.dv";
#X add "Clip 02_2026_469.dv";
#X add "Clip 02_2044_681.dv";
#X add "Clip 02_2050_904.dv";
#X add "Clip 02_2052_368.dv";
#X add "Clip 02_2064_182.dv";
#X add "Clip 02_2072_432.dv";
#X add "Clip 03_2018_99.dv";
#X add "Clip 03_2025_171.dv";
#X add "Clip 03_2035_426.dv";
#X add "Clip 03_2059_660.dv";
#X add "Clip 03_2067_639.dv";
#X add "Clip 03_2071_350.dv";
#X add "Clip 04_2017_18.dv";
#X add "Clip 04_2019_222.dv";
#X add "Clip 04_2021_545.dv";
#X add "Clip 04_2022_523.dv";
#X add "Clip 04_2024_622.dv";
#X add "Clip 04_2027_423.dv";
#X add "Clip 04_2032_762.dv";
#X add "Clip 04_2039_979.dv";
#X add "Clip 04_2040_444.dv";
#X add "Clip 04_2041_780.dv";
#X add "Clip 04_2044_794.dv";
#X add "Clip 04_2048_874.dv";
#X add "Clip 04_2052_456.dv";
#X add "Clip 04_2053_614.dv";
#X add "Clip 04_2054_276.dv";
#X add "Clip 04_2055_793.dv";
#X add "Clip 04_2057_648.dv";
#X add "Clip 04_2061_255.dv";
#X add "Clip 04_2063_964.dv";
#X add "Clip 04_2064_960.dv";
#X add "Clip 04_2066_170.dv";
#X types MooV "JPG " JPEG TIFF MooV "JPG " JPEG TIFF;
#X prefix_set 0 1 "LosMochis:/Analog synth/Edits01/" 0;
#X pattrmode 1;
#P window setfont "Sans Serif" 9.;
#P newex 197 349 23 196617 t b;
#B color 5;
#P message 197 395 79 196617 frame 35 , bang;
#P newex 197 326 57 196617 route read;
#B color 5;
#P newex 180 305 201 196617 jit.qt.movie 320 240 @autostart 0 @vol 0;
#B color 5;
#P comment 206 96 142 196617 async (0) or regular (1) read;
#P window linecount 2;
#P comment 189 114 187 196617 aync doesn’t consistently produce an image in the pwindow , but regular does;
#P user dropfile 100 63 419 197 1;
#P hidden connect 7 1 9 1;
#P connect 9 1 10 0;
#P connect 15 0 5 0;
#P connect 6 0 15 0;
#P connect 16 0 15 0;
#P connect 4 0 6 0;
#P fasten 3 1 4 0 376 324 202 324;
#P hidden connect 8 0 7 0;
#P connect 13 0 9 0;
#P hidden connect 14 0 13 0;
#P connect 5 0 3 0;
#P connect 11 0 3 0;
#P connect 10 0 3 0;
#P connect 9 0 11 0;
#P fasten 3 0 12 0 185 388 83 388 83 68 109 68;
#P connect 0 0 8 0;
#P window clipboard copycount 19;


Viewing 11 posts - 1 through 11 (of 11 total)