Hello, I am working on a program that captures video from a webcam.
The Capture class works fine, but when I try and implement the MovieMaker class, I get this error on startup:
quicktime.std.StdQTException[QTJava:7.7.1g],-2014=invalidDuration,QT.vers:7718000
at quicktime.std.StdQTException.checkError(StdQTException.java:40)
at quicktime.std.movies.Track.insertMedia(Track.java:676)
at processing.video.MovieMaker.finish(MovieMaker.java:313)
at Webcam.draw(Webcam.java:72)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
This happens on both Windows and Mac OS X Lion. Any help is much appreciated :)
Here is my code:
The Capture class works fine, but when I try and implement the MovieMaker class, I get this error on startup:
quicktime.std.StdQTException[QTJava:7.7.1g],-2014=invalidDuration,QT.vers:7718000
at quicktime.std.StdQTException.checkError(StdQTException.java:40)
at quicktime.std.movies.Track.insertMedia(Track.java:676)
at processing.video.MovieMaker.finish(MovieMaker.java:313)
at Webcam.draw(Webcam.java:72)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
This happens on both Windows and Mac OS X Lion. Any help is much appreciated :)
Here is my code:
- import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import processing.video.*;
Capture myCapture;
PImage cview;
CameraView cam1;
MovieMaker mm;
boolean captureBool = false;
void setup()
{
mm = new MovieMaker(this, width, height, "movies/capture.mov", 30, MovieMaker.H263, MovieMaker.HIGH);
setSizes();
createGUI();
myCapture = new Capture(this, 640, 480, 30);
frame.setTitle("Live Webcam Feed (click to capture photo):");
//Camera view thread: refresh time (millis), name;
cam1 = new CameraView(10, "Camera1");
cam1.start();
// To select the camera, replace "Camera Name"
// in the next line with one from Capture.list()
// myCapture = new Capture(this, width, height, "Camera Name", 30);
// This code will try to use the camera used
}
void captureEvent(Capture myCapture) {
myCapture.read();
}
color cp;
void draw() {
cam1.cameraUpdates().loadPixels();
image(cam1.cameraUpdates(), 0, 0, width, height);
frame.setLocation((screen.width / 2) - (width / 2), (screen.height / 2) - (height / 2));
if(captureBool == true) {
mm.addFrame();
} else {
mm.finish();
}
}
int saveIncr;
void mousePressed() {
saveIncr++;
save("capture" + saveIncr + ".jpg");
background(255);
}
void setSizes() {
float cameraWidth = 800;
float cameraHeight = 600;
size((int) cameraWidth, (int) cameraHeight);
}
class CameraView extends Thread {
boolean running;
int wait;
String id;
int count;
CameraView(int w, String s) {
wait = w;
running = false;
id = s;
count = 0;
}
void start() {
running = true;
println("Starting thread (will execute every " + wait + " milliseconds.)" );
super.start();
}
void run() {
while(running) {
cview = myCapture;
try {
sleep((long) (wait));
} catch (Exception e) {
}
}
println(id + " thread is done!");
}
void quit() {
println("Quitting.");
running = false;
interrupt();
}
PImage cameraUpdates() {
return cview;
}
}
void createGUI() {
JFrame outsideFrame = new JFrame("Quit");
JPanel mainPanel = new JPanel();
JPanel buttonPanel = new JPanel();
JPanel capturePanel = new JPanel();
JButton quitButton = new JButton("Exit Program");
final JButton captureButton = new JButton("Capture");
mainPanel.setLayout(new GridLayout(0, 1));
outsideFrame.add(mainPanel);
mainPanel.add(quitButton);
mainPanel.add(captureButton);
quitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exitProgram();
}
});
captureButton.addActionListener(new ActionListener() {
//public boolean captureBool = false;
public void actionPerformed(ActionEvent e) {
println(captureBool);
if(captureBool == true) {
captureBool = false;
captureButton.setText("Capture");
}
else {
captureBool = true;
captureButton.setText("Stop Capture");
}
}
});
outsideFrame.pack();
outsideFrame.setLocation(screen.width - outsideFrame.getWidth(), screen.height - outsideFrame.getHeight());
outsideFrame.setVisible(true);
outsideFrame.setAlwaysOnTop(true);
}
void exitProgram() {
cam1.quit();
println("**** Program is exiting! ****");
System.exit(0);
}
1