APVideoVIew with PGraphics buffer
in
Android Processing
•
2 months ago
Hello Fellow Technartists,
I'm working with Processing in Android mode.
I need to render video in a PGraphics buffer, and then run distortions and transforms to the framebuffer before rendering to the main canvas.
I've been using Matt Patey's "offscreenComplex.pde" as a template guide for how to setup the PGraphics offscreeen buffer. I was successful in doing 3 out of 4 different configurations:
Java Mode:
works: apply transformation matrix to the buffer canvas, render still image to the buffer,then in draw, GET the frame buffer, display using IMAGE with size distortion
works: apply transformation matrix to the buffer canvas, render video to the buffer,then in draw, GET the frame buffer, display using IMAGE with size distortion
Android Mode:
works: apply transformation matrix to the buffer canvas, render still image to the buffer,then in draw, GET the frame buffer, display using IMAGE with size distortion
doesn't work: apply transformation matrix to the buffer canvas, render video to the buffer, [STOP <-- doesn't work]
Of course, in android mode, we can't use the processing.video library that I was able to successfully
use with Java, because it's not compiled for Andriod...(right?? I've never been able to get it to work). So I defaulted to using APWidgets, which I have been able to render in Android mode. I can render video all day long with VideoView,
to the main canvas
, but I'm having trouble figuring out how to draw video to the PGraphics buffer.
Simplified code to show where it stops working:
void setup () {size (displayWidth, displayHeight);imageMode(CENTER);buffer = createGraphics(720, 720, JAVA2D);container = new APWidgetContainer(this);videoView = new APVideoView(false);videoView.setVideoPath("/path/movie.mp4");container.addWidget(videoView);videoView.setLooping(true);}
void draw(){updateBuffer();background(0);image(img, width/2, height/2, 1280, 720);}
void updateBuffer() {renderBuffer(buffer);img = buffer.get(0, 0, 720, 720);}
void renderBuffer(PGraphics buffer) {buffer.beginDraw();buffer.background(0);buffer.noFill();buffer.imageMode(CENTER);videoView.start(); //or whatever...nothing makes sense here, because there's no videoView in the buffer spacebuffer.endDraw();}
If I were using video libraries in Java, (substituting movie methods for the APWidget videoView methods), then the movie would render to the buffer in an image() method, the screen would be captured and brought to the main canvas to be displayed an image() there.
The promblem seems to be that PGraphics doesn't, naturally, have videoView methods included. It does inherit IMAGE from processing.core.PConstants, and the processing video procedures
draw to image so change videoView.start() to:
buffer.image (mov, x,y, width, height)
so we can ask the PGraphics buffer to draw video frames to IMAGE, capture them with a GET, then drop it on the DRAW canvas.
How can I do this with Android? Draw video to a frame buffer, image container, anything..... ??
How can I do this with Android? Draw video to a frame buffer, image container, anything..... ??
Thanks for your thoughts!
1