Accessing cues using [position] to <jit.movie> weirdness

chapelier fou's icon

Disclaimer : video is not my usual domain, so I might lack some basic knowledge.

But still,
I'm working on a project where I need no be able to cut video loops into 16 equal slices and access to these slices with accuracy.
So I made a video loop displaying numbers from 0 to 16, equally spread in time to work it out.
In my example, it displays numbers from 1 to 14, then pauses for 2 ticks. Why is this happening ?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

Your video example has 63 frames, this is frames and what they show :
in coll format, index is frame number, data is the number shown.
0, 1;
1, 1;
2, 1;
3, 1;
4, 2;
5, 2;
6, 2;
7, 2;
8, 3;
9, 3;
10, 3;
11, 3;
12, 4;
13, 4;
14, 4;
15, 4;
16, 5;
17, 5;
18, 5;
19, 5;
20, 6;
21, 6;
22, 6;
23, 6;
24, 7;
25, 7;
26, 7;
27, 7;
28, 8;
29, 8;
30, 8;
31, 8;
32, 9;
33, 9;
34, 9;
35, 10;
36, 10;
37, 10;
38, 10;
39, 11;
40, 11;
41, 11;
42, 11;
43, 12;
44, 12;
45, 12;
46, 12;
47, 13;
48, 13;
49, 13;
50, 13;
51, 14;
52, 14;
53, 14;
54, 14;
55, 15;
56, 15;
57, 15;
58, 15;
59, 16;
60, 16;
61, 16;
62, 16;
63, 16; (last frame light red color)
-------
You were better off with 16 frames and counter
recalling frame by frame.
your position float makes no sense at all.

But , that is advice for this specific case, where you display
pictures and not really video....
If you really were up to slice larger video into 16 equal slices,
then it is another story.

Rob Ramirez's icon

unfortunately viddll engine still has some issues with h264 files, especially accessing the final frames. The easy workaround, especially for your case usecase of accessing frames on demand, is to make sure that playback is stopped when accessing these frames. So add the argument @autostart 0 to your jit.movie object. Doing that allowed me to access all the frames using your technique.

chapelier fou's icon

Thanks.

At first, I don't think you're right, as [position] is a between 0. 1., normalized to the whole file length. It makes perfect sense to me (and works).

Then, yes, I plan to make this on video, with variable playing rates. Following patch appears to work quite nicely :

Max Patch
Copy patch and select New From Clipboard in Max.

Rob Ramirez's icon

cool, yes avf player doesn't seem to suffer the same h264 issues as viddll. another workaround for viddll is to load the last second or so into memory with loadram -1 message (ensuring you have enough cache to do that via the cache_size attribute)

chapelier fou's icon

Thanks @RobRamirez
Good to know that it's a known issue. To be honest I have no idea why I should use viddll or avf, I don't even know what it is. I firstly tried viddll as as was working with .gif files, but I think that making .mov files instead of .gif files with a rate of 0 is perfectly viable for my use.
Does loadram (not available with avl) really make a difference on a macbook pro with an SSD, with reading files less than 10MB ?

Julien Bayle's icon

You can probably find some references post related to my project FRGMENTS:
https://julienbayle.net/works/frgments/

Example: (actually not the best one as there are massive glitches, but we had a total control on retrieving THAT frame if we wanted that)
https://vimeo.com//242240872

We had shot videos of people rotating in the studio
We wanted to be able to retrieve EACH frame precisely.
Combination of loadram, hap etc gives us that.

chapelier fou's icon

Thanks Julien.
Still a few things to figure out. For instance, [frame $1] works really really bad ([frame_true $1] on the other hand is accurate).
What do you mean by "some references post related to my project FRGMENTS" ?

chapelier fou's icon

Hi there,
I'm getting back to this project and was able to isolate a problem I'm encountering.
Here's a patch demonstrating an issue where I can't recall the same position after stopping playback. Does anybody have an idea why ?

Jit position prob.maxpat
Max Patch

chapelier fou's icon

Well, can't find any decent solution.
I'm only reason I'm clearing the matrix is to get plain black, so I'll do this another way. I wish I could find a reliable way to call position cues, though.

Source Audio's icon

what is the problem ?

what are all this delys, randoms etc supposed to do ?
you wipe the window using stop and clear.
to start from any position, use valid frame number, like
frame_true 100, start


chapelier fou's icon

The problem is :
if I recall cue x, then clear jit.move, then call back the same cue x, it doesn't recall it.
Unless the cur changes :
recall cue x, then clear jit.move, then call back cue y, then it works.

The issue is when I stop the movie and clear the matrix, jit.movie ignore the position (or frame) message if it's the same as the previous one, even if if between, jit.movie is stopped of cleared.

In the exemple here, 1 will output the correct frame, 2 will erase, 3 will not work, but 4 will.

Source Audio's icon

not in my max, by the way I use max 8.1.11 with gl2 - old stuff,
but it works as it should.

I don't see start message in your screenshot

chapelier fou's icon

Yeah, I didn't use the start message as I am not really "playing" a video, I'm just displaying cues as fixed images. So I tried adding it. it worked...with chickens.mp4.
So there's another problem.
the attached patch works with chickens.mp4, but not with the attached .mp4 file (toggle has to be toggled twice)... any idea why ?
EDIT : I thought it was an issue with H.264 but I found at least one file encoded in H.264 that works.
EDIT2 : bball.mov, from the stock videos, is buggy as well, the pattern is super weird.

jit.movie accessing frames issue.maxpat
Max Patch

Source Audio's icon

can you not copy compress your patches.

I don't want to download any patches ...

I have no issues with any kind of videos.

try this, maybe it works better in your environment....

Max Patch
Copy patch and select New From Clipboard in Max.


then - why don't you use still images if you don't play any videos ?


chapelier fou's icon

"can you not copy compress your patches" ok, sorry, here, I can download it as a ready-to-use maxpat. Thought it was more convenient than text format.

"then - why don't you use still images if you don't play any videos ?"
good question, of course. The truth is I want to choose if I play the video with a rate different from 0, or with only stepped, fixed images, so with a rate of 0.

I just posted a video on YT to illustrate what happens here. That's super weird.
https://youtu.be/h3gF04wv86M

Source Audio's icon

I tried that patch on newer max with gl3,
i does not even clear video screen.
gl2 / viddll works way better.

But honestly, I don't care much about video playback in max.
So can't reallly be of help to you.

But in my experience - simpler - the better.

You never take patch that I post the way it is.

rate 0. is not the same as rate 0.000001

with rate 0., nothing happens.
with rate 0.000001 set frame gets displayed.
sending stop after some delay works too in case you leave that frame hang for long time.

maybe you need to trigger frame number twice ?

chapelier fou's icon

Yeah I'm a quick modifier, I know. I did test before changing stuff, I swear !
rate 0.0000001, I could see movement, it's highly not precise.
Triggering the frame twice doesn't work, it has to change.
I reported to c74, as it looks buggy to me.
Meanwhile, it's maybe a good first project for TouchDesigner.
Thanks for the help !

Rob Ramirez's icon

I would just use a jit.xfade for the black frames:

Max Patch
Copy patch and select New From Clipboard in Max.

chapelier fou's icon

Awesome thanks !
What's the texture equivalent ?

Rob Ramirez's icon

jit.gl.pix @gen xfade

chapelier fou's icon

Yes, thanks, was about to edit my post. Thanks for the help !

chapelier fou's icon

Hi there, I'm keeping posting here even if the subject is changing a little. Hope you don't mind.

Is it possible that [jit.movie] always reports 1 frame more than the actual frame count when sending it a "getframecount" message ?

In my case, frame 0 always outputs the same as frame 1.

I can deal with it, no probs, but I'd like to know if there is an error, and if this error comes from

  • Max

  • my patch

  • the way my friend renders the videos he sends me

Thanks !

chapelier fou's icon

A little update.

I need to access precise frames in videos that are made by a friend of mine.

But there are differences between what happens on his computer (windows) and mine (mac).

I've made this little utility to check the video frame by frame.

Max Patch
Copy patch and select New From Clipboard in Max.

with the attached video, we have different results :

  • On my side :

I get 385 frames

frame 0 displays "00001", frame 1 displays "00001", then frame x displays "x".

  • On his side :

He gets 384 frames

frame 0 displays "00001", frame 1 displays "00002", and so on... (frame x displays x+1)

each frame above 368 displays 369.

Any idea what could be happening ?

Compteur_24fps.mp4