We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi-
I'm trying to better understand video manipulation, and think that an example in the P5JS Reference Guide can help me visualize what I need. However, this example is throwing an error to the console. i'm getting the JS error:
Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source width is 0.
Can someone help me understand why this code isn't working?
Thanks!
Answers
You should at least mention which are those links? ~:>
::facepalm:: I'm so sorry I omitted that tiny detail. :D Thanks for proofreading!
http://p5js.org/examples/examples/Dom_Video_Pixels.php
createVideo supports a callback that should probably be used in order to ensure the video asset is loaded before trying to do anything with it; but hasn't been in the demo... That could be the issue ("source width is 0" would suggest the file hasn't loaded) though when I try and amend the test page it still throws an error (though the video does appear for an instant).
Video doesn't show up due to
fingers.hide();
, of course. :>I did some tweaks here but no good. Seems very buggy to me: :-&
OK, thanks. Glad to know it's not just me.
It's weird: if you wait for the video to load and
console.info(fingers.width)
it returns the correct width; but runningconsole.info(fingers)
and inspecting the object appears to show conflicting property values (in Chrome):Odd :/
Could be a browser bug; but if the behaviour is consistent on all browsers then maybe not... :(|)
Yeah. I agree it's odd/buggy. I pulled the code down to a local server, and it ran OK in Chrome and FF (with one of my own webm/mp4 videos). Gremlin in the works somewhere.
Possibly the video file then. I'd have to dig out the details, but there's a snippet in video files that includes data on length etc. Some encoders dump this at the end of the file where it's no use to anyone: you have to wait for the full file to load before you can do anything with it...
+1 on this problem. loadPixels errors out every time. i've tried a variety of video formats. wonder how/why it's working on the demo??