i have a problem, when i live stream my video ,it will record but when i make it stop . it will make all my program hang and then i need to reset . can anyone of you let me know how i can overcome with this issue and it will not disturbed my other code and work perfectly
here is my code :
// Save video file import processing.video.*; //import org.jcodec.api.awt.AWTSequenceEncoder8Bit;
import org.apache.log4j.BasicConfigurator; import java.awt.image.BufferedImage; import java.io.File;
Capture cam; AWTSequenceEncoder8Bit enc; String videoName; String audioName; boolean recording;
void setup() { size(640, 480); background(0); BasicConfigurator.configure(); cam = new Capture(this, width, height); videoName = "beat.mp4"; recording = false; int fRate = 10; frameRate(fRate); cam.start(); try { enc = AWTSequenceEncoder8Bit.createSequenceEncoder8Bit(new File(dataPath(videoName)), fRate); } catch (IOException e) { e.printStackTrace(); } }
void draw() { image(cam, 0, 0); if (recording) { BufferedImage b = (BufferedImage) cam.getNative(); try { enc.encodeImage(b); } catch (IOException e) { e.printStackTrace(); } } }
void captureEvent(Capture c) { c.read(); }
void mousePressed() { recording = !recording;
}
void keyPressed() {
if (keyCode == 32) {
try {
enc.finish();
}
catch (IOException e) {
e.printStackTrace();
}
}
}