How to get a .txt or .xml file listing the pixel RGB values of any given video
I’d like to learn how to make a patch where I can input a video file Jitter can read and have its output RGB values listed in a text file ready for consumption by another program not looking for video, but ready to take the values as they come…
So the text file might look like this:
102, 45, 56
107, 50, 60
and so on …
each line being one pixel … I guess starting from the top left and working to the right until the line/row is complete then going to the far left of the next row down (like a progressive CMOS sensor). For instance with a 100×100 spatial res on the 10,001th line you’d be inputting the top left pixel of the 2nd frame and so on…
There would be verticalRes*horizontalRes*frameNumber lines of comma delimited RGB values
I’m not a programmer (yet) – so any tips on the best way to make data easier for other programs to digest would be appreciated… maybe the lot could be simply be comma delimited rather than line and comma delimited ? (although this makes it easier for *me* to get my head around the data)
It is in its essence I guess just video data stored in a very clunky uncompressed fashion. But going about it this way means less work on the input side of the other program in teaching it (and myself) how to read movie files.
Any help appreciated
This is a start, it only does a single frame but could be modified. It’s locked to 320 x 240 resolution, but you can change that too. For a single frame, writing to a [text] object, it takes my computer about 2 seconds, and the [text] window is a bit slow to load, but hey, that’s 76800 lines… so we can give it a break :)
Commas are a little funky in Max, so I used tabs to separate the values instead. Probably any other program you use for the data, if it takes comma-separated values, you could use tab-separated ones instead. If you do need the comma, generally you have to use the escape character before them, so in the [triggers] at the bottom, you’d have
t , i
which sends the int value (R G or B), then a comma. However, I got extra spaces in the text file when I tried this, so I went with tab instead. Also I dropped all the alpha values.
The text file, after I saved it, was 1.2 MB for a 320×240 frame. So yes, it’s big, but it would also .zip quite well I imagine.
I’m sure there are better ways to do this, maybe a way to use jit.matrixset somehow, which would be a lot faster. But this works, and demonstrates some fun objects like [uzi] and of course, jit.matrix…
----------begin_max5_patcher---------- 1320.3oc2ZtziaaCDG+rCP9NPHzitF7odTfdn8RO0KA8VQPfrDWuJQObjnhs SP+tWIR+Pdq8J50TjFcWrVdkDHG9i+mQyPpe792MyaY0VdiG3W.+MX1rezcl Yxy0elYGNwLuh3sI4wMxazKopnfWJ7lu+hB9Vg7B+YbYabd9NPbZJXgXq.r4 YdIXWUKXSclf2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cTDx9pwpN+Vyn3PgltnD1v2qFUTM6tD.I47XCsBIn HiuBIvP6fmdet0axJSq1bKqdVzqmbzfA8x3jurptpsL8L5cwEulcZSZIXUza pUcXjuoYFZqPBLulPIInmVhe65w70Vd8NyPGenwoiev.7bydLpayS9pb8h2n QYm0egW.slp15jCF8gRF.3ScXJuQjUJ2w4A2U+anDXfY8bVZJu7r8hsHKccU Whi6sDvGu9bo1FWOwG1sW13jCA6abLsLNparsfGYvgzQx0WehCLNLQGxIGBN x3FmbL2XbZo4vtYZEo2zJzMFGSaiCYciip0rpua.W3CbXt9DreXMNrVRNbf6 hjfFkbQtw370w3HNwWkvdjkbZANpaBAS0KYN2jF7K61GpoUJTK+Al6LtQSXh hbmwQF03bSBSjG4RuHZo4bkCARGxQbTbN5ibnD5i7zpVUPPcS89TesLNGEDl 8.WBgdFG89y0r+DcG9WvMJi0D -----------end_max5_patcher-----------
also take a look at jit.iter, jit.spill, jit.textfile and the jit.str.* objects.
firstly seejayjames – ok, I see what is happening there although I dont get how jit.matrix or jit.qt.movie work to be able to change it to do frame by frame – I was hoping the ‘getcell’ input to jit.matrix would simply work by adding another ‘position’ input (col, row, *frame*), maybe it does, but I cant figure out how ? If it did in a similar fashion I’d add another uzi into the pack and so on …
Either that or simply do one frames worth of action then moving through time (+1 frame), starting the process again but just appending onto the text file – I dunno some sort of modulo maybe on x*y = 16 mod 16 = 0 means advance one frame – or maybe with the text query = 26 mod 26 or ???
By the way just for testing at this stage I am working with 5 frames of 5×5 res images (125 pixels total) running at 5fps (200ms period) – attached if it is of interest
But how do you get jit.qt.movie to move forward one frame only ? This doesn’t need to be real time, maybe that is causing the issue ?
I played around with jit.iter and got it to output a frames worth of pixels tab delimited (alpha incl. which shouldn’t be an issue) but there were no line breaks per pixel – I used the ‘done’ output of jit.iter right outlet so I could at least see the end of the frame in the output (but I guess this isn’t necessary for the final version).
Again, I dont know how jit.qt.movie or jit.matrix work (or anything really!) – I thought it would be simple but how can I get jit.qt.movie to just move forward one frame then send a bang to jit.matrix to do the text output ? I thought as the right output of jit.iter was sending ‘done’ when it was done this would be the perfect message to advance a frame and go again … (how to stop on the last frame though ?)
I’m not getting my head around jit.qt.movie basically – metro, stop start and rate are confusing the heck outta me, I get random results that I cant reverse engineer so far to figure out what is going on – is there just a ‘play at the .mov files frame rate’ option ? or ‘step 1 frame’ option ?
here is my mess of a patch:
----------begin_max5_patcher---------- 944.3oc0XssiaBCD84juBDpOlFguEf9T62Q0pUNf2Duk.TvrIcWs+6EFmrgM ERfDCJUQBhMf0YNyLmYrea5D6kI6D41Vey5mVSl71zISfoplXx9wSr2v2EDw ygWydYgRkDaOS+n3hMx3HgBdFZ+jobUvZY7pGyDAJ8Z64N2Yl0Bb0UrygqVO bbYRJTmtN5oT+IUnWD6k73U1e7QxP.PIKe9qKrql58oSqtLqiVRrXa42dvRT hc.VsKdUZwNL6SIwpb4q..Pn4LeFxysIaG2ts6xprWeT0U5hKX6jyZ6yNdWF qZjJ9Dzi4afu29GYRdz0PRaD447Uh+gkRREwMRRUt39wOXJDPPP9U2Xv.jW+ iNZjNPdiCeDDI3YlhPzwJDj6.PHjwgO1lIUBCwGHeZs.DJxn7Ay0rDRKpJve 5qnxYDTQK7.NYg+sIqzEIErYYnqqBBErW2gpBB5Zrjmkp4OklupPZTWKDsyv P1umVaj0pohOmmsYSkNNR.4JdlxjERQLfYPDs7HwrEJ7GKVII0njBFRIPXPH ffmyLHofcFEwwzrRoGqWJWSClFsOJwAtwPWPwvogJkiowGHhLp06wzVOjjny a5o0iFEquRBcCWkI2YQsBVyyrXk+9tZcVgkiQCG.l.uu6AF4BLRqxpk.9QMf aUfkbWTvDo886adZ.JYRHWaMyzsx3vjsGrnk7fesJKoHNrNP5W4RhuVFbgta 4qwy1t+jZ5zcy1tfNV128XUwdlpyFsT8xMEjYzrZnpG10oViAWaavs6+WXV9 4onjRXYzX.sbuO43FFulLfRfwUerifFohysaoCN7LYd.OBdhybeC16TFWIr9 BxnsO4WOzg5Z18ZORG9PlfGZRRQGMgHfjJgZVNwv8YqRVsJRz2hiv9kc8usJ isseYJxfplaDprDKiFyCFOp9wsYz9Bn3QqbxuKadL4EonpoQSpmpYHWPSPmL LPsJR63wwAeqcjL9zCqG.e07el.ySJxBNfiCNEqiVPnHWIi4JYYek0dIxmdo 0xvPQb8lF1HCSSJC6yOrgbX2l5i0u1.qGZzM2Yrh5BVw8Cq2Hl5BjXiJhp5J wBeAHMtjDoCjzH617t6fT0ANemAIHT5+PHUcBMiIl5hF5I.evwTWx4H8z2gP vwHhIPcP5wA2pv9f.VntCFQpg0pAiBVoiqZl+PTDeAAJbybqUEuZvMBVryP. 1x8oMDfkLDLqOcXvp2PPr99CCX6R0tSrnAWyj1ALgn2ecyQtkNLKG79z+dem wTC -----------end_max5_patcher-----------
here is one way of many to print out successive frames of a quicktime movie.
each frame’s data is stored on a single line in the text object.
basically, a successful read notification triggers the qt.movie to output frame 0, which starts the process. the "done" message from the jit.iter triggers the next frame. notice the "deferlow" object which ensures that the next frame won’t be output until the previous frame has finished writing to the text object.
you should study the relevant tutorials if the quicktime object is not making sense to you.
----------begin_max5_patcher---------- 722.3oc2XFsbhBCEF9Z7oHCyd255PBDE5CxdyNc5DgnltRvRhac2N8ceIIP0 1tFBKHNiWHXRvve93+bNDeYhm+xhCTgO3NvO.dduLwyS2kpCu51d94jCoaIB 8k4mSEBxZp+TyXR5Aot+RJICjwDanhY4E+pY7cDY5FFe8CkzTo49fBBlELEr PeLITcDtXV.395eBKSOgEKe7avEMyypBtjSxo5g9NsLivIMiw2mWrWtkJ0JD V2qoK4u2QM2Ve+2tCpISv9id.nRFuMOLdyzfT885jIpCScjMb5yUp9SnIith Vts3YKLAZnQHReBafRxYfB9pAE3+ATNmgYUYkxAeANErjvWagMImXWhisZWh tErKeE.akF3Z6xLrEeBZ.oAiKuZ.IsXOWRKaEJgFih8fGX2gRjMnLsxoT+oy LBObLRBVBRKcHCyoIeOKjB5NjPmCRln6pmhkW9bMmANkUhhBxJ3z1ADJVeZN 1FfRFP9ncOWKxn+RqwUyMtk.qll3tyjPaLow2z4npguHUPq0nflbOHnoJEzV Upah2oQP2ZsLUMPf0NnHaNG7EHayUCL646Ho+DH.LGniIkybjM5DMv4ZFk3I qIhUaUvA3XdGm4VKmGdqjH9QlbFykWxAYvRRhMrfF3bwWcz7jTsoRFEfA3VQ DD4R8J3.Zcpj3C4DYI6P+Hk9G5ukw+3dx0qUU+uGehh8koMhnYCyfiK2LpPx 3DIqfe5E8tqYCKKipGtQd4rrcEUoIDM6WOQuMifjZiWSCv8+yGxNqUrKZsih EtPquvHbcxiO1.EbbUn9deWDAtrHvcaQzWMEM7lf9JIjKRJZb0DzEMgFWMor SvVzTbGieqpmphBvviNecidp0DWvWvnhOWbYwithPsnnjw0h4.iFWS+EnlEL zjfObt9e6.8oFP3I0AzM54hvkhYKFUrF4PpjwsvTnCLJZzCFZiQg8PQUMdcx ecjyOSG -----------end_max5_patcher-----------
hi – if you dont mind check out this mess of a patch:
----------begin_max5_patcher---------- 1699.3oc0a00aiZDE8YmeESspz9RRDym.UpRsuz9TU+ArZ0JLL1lTavKLdSZ Ws+267AXSRFaiML.qh1Plw1368vcN2y8Ny9s6lMeQ9K7x4feA7QvrYe6tYyz SolXV03Yy2F8R7lnR8aadb91s7Lw76Mulf+hPOeAujK.KKh1xAQYI.0K.Vlt gW+NSSzuu7EO8.DVO4x7LQl7ineoeuHMZS8qjseaZ1FtP+sBONY9dQ8rdMtI ko+m9l.gORCov.+pWaWjHdcZ1pOWviEF+jQgO5cO.6ou.odpKH4uAeR8Y99c 2o908sDOVrWHxyr3jgWgmTOqYJw+tiaL04KhxVMG7oy3LXjwYP0dQG7EoQsf WXwWn8xyKTKdd8NDHUEq0Bf.Cq.Bh5B0Q.QvzGHHj.su6S6AfXKurLZE+cq1 UVM3mgVPH+qDgPmcAwUgPmGV70vBzWupm3qGDbivR4lzDqwGr54pMZUzXk4V jJ4MiDoR1hWGYbyrCWHNHT+nu5BT6wH1M5wm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lYGUz+5naoZMc0Arogqo8EuF6Ai9xgOk8nljRwE+9rlh57R YBLG8H+2aM8LaiMbeT66N1uISSGaE6YXZjx3rpqkMtJWZMchoaaPLzIZVT6u iMzYpJYoZuupyNSbgTWUTyWjonx+ZJWkZx1I1.+CQJInmoUsli9U.0ZHj9Fn 2jt2bpu02P07uFBKy2WDWaLUGqYvQRvDdoHM6vgZ7iGJirw6YcZRBOqI4w1z jc4pMt17YNwiy9zhT6Hy.ZRz1XRgCpIoNhZWzlT6QC.NX1j9q6hASvAEmvsI bhbkQ3DLUUYA12zUbH6vnthftvZgtxZUkA1+XqO1QXqpYx8u454HqE0Bikcs QBgDk8gBP06NZ8nttJqMrQXuqyZU88QZeTy45DivGFMDVK5lLVloi2HRvgQc knG2FnkbkABl.UhoNWh+gAChwhtMi07exiJfVOpqVaqHDFVoFDzzKGJj4.hS pGyQYkbQNTLB5FqE2+TQXelanhXXGfrUYgbPFz1nFEMr01fHsU09.ZSXGnzn JpCED7JkFAce0M9UkzzOYX5pM0FN62Ph5bNaXadr9VMwt2pPs1pFv5VcQcLP eWUYPfCRYf7bSJCpuCjZ6ibiwhak1qgccL1EJpQgHiheVSE0TV+TYE5RVKcX QPXKrIzvxC1pJOFVY.sYgJa3evMsLo1THTPGrH4fue2+CBWm5PA -----------end_max5_patcher-----------
I’ve had to resort to using a metro and a trigger at the top to sort out the ordering of the function – attempts at other ways around it ended up with the initial frames RGB values being written to the text file 5 times …
Things I know can be improved = my understanding of how jit.qt.movie and the metros work – I get odd things happening which I’m finding hard to reverse engineer, why does jit.qt.movie need a metro if I just want to jump through frames ?? etc…
Things I’d like control over and to learn how to do:
- – Stop the dicking about when I load the movie (hitting stop, then reseting the frame #)
- – learn how to make the UI easier – I know how to hide all the gumph but not how to set the initial values for jit.qt.movie and jit.matrix (5 and 5 in this case) without going into the thingies thmeselves – I did however manage to make the frame numbers an inputtable field (go me!)
- – Find out how to add line breaks per pixel if need be
- – Find out about what the metro going into jiy.qt.movie is actually doing and why changing the number going into its right inout from 0.5 to 1 made my little patch work better with *much* smaller periods on the metro going to the trigger
- – Find out how to make this work ‘offline’ so to speak – so it runs in order as fast as it can without clashing timewise – no more metros maybe, and instead ‘just go as fast as you can without stuffing up’ (possible?)
- – Find out how to remove the Alpha values if need be
– understand what I’ve done here !
I am yet to try it with larger files – but in the meantime have been using a little 5x5res x 5frame file – each frame has a white number on it for ID and the black is actually dark grey with its RGB values set to the frame number (easy to see in checking the .txt output)
did you look at the patch i provided? you should not need to use a metro at all.
bangs simply tell a jitter object to output it’s current matrix. this information is all in the documentation and tutorials. in the patch i’ve provided, it first tells the qt.movie which frame to go to, then it bangs that frame out.
check out @autostart attribute to qt.movie.
the rest of what you ask can be achieved with simple modifications to either of the patches posted.
Forums > Jitter