Video 通过视频处理录制和播放多个视频
我正在尝试使用处理设置以下内容:Video 通过视频处理录制和播放多个视频,video,processing,webcam,Video,Processing,Webcam,我正在尝试使用处理设置以下内容: 一个人在网络摄像机前按任意键开始和结束录制 当她/他在摄像机前录制时,他/她可以看到前面最后三个人的循环录制 不用担心声音 保存所有的视频会很好,尽管这不是优先事项 到目前为止,我的代码是这样的: import processing.video.*; VideoExport videoExport; boolean recording = false; Capture theCap; Capture cam; void setup() { si
- 一个人在网络摄像机前按任意键开始和结束录制
- 当她/他在摄像机前录制时,他/她可以看到前面最后三个人的循环录制李>
- 不用担心声音
- 保存所有的视频会很好,尽管这不是优先事项
import processing.video.*;
VideoExport videoExport;
boolean recording = false;
Capture theCap;
Capture cam;
void setup() {
size(400, 300);
frameRate(30);
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
// The camera can be initialized directly using an
// element from the array returned by list():
cam = new Capture(this, cameras[3]);
cam.start();
}
println("Press R to toggle recording");
videoExport = new VideoExport(this, "video.mp4");
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(0, 0, cam);
if(recording) {
videoExport.saveFrame();
}
}
void keyPressed() {
if(key == 'r' || key == 'R') {
recording = !recording;
println("Recording is " + (recording ? "ON" : "OFF"));
}
}
导入处理。视频。*;
视频输出视频输出;
布尔记录=假;
捕获cap;
捕捉凸轮;
无效设置(){
尺寸(400300);
帧率(30);
String[]cameras=Capture.list();
if(cameras.length==0){
println(“没有可供拍摄的摄像机”);
退出();
}否则{
println(“可用摄像机:”);
对于(int i=0;i
我尝试了许多不同的方法,如上文所述的
videoExport
。我所尝试的只是通过覆盖上一个文件来保存视频,无法正确更新视频。请告知。多谢各位 您有两个主要问题:
- 你只写过一个视频文件,所以你只需要替换以前存在的任何文件
- 您从未实际检查用户是否按下“A”键,因此您从未增加要保存到的视频
import processing.video.*;
VideoExport videoExport;
boolean recording = false;
Capture theCap;
Capture cam;
int index = 0;
void setup() {
size(400, 300);
frameRate(30);
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
// The camera can be initialized directly using an
// element from the array returned by list():
cam = new Capture(this, cameras[3]);
cam.start();
}
println("Press R to toggle recording");
videoExport = new VideoExport(this, "video" + index + ".mp4");
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(0, 0, cam);
if (recording) {
videoExport.saveFrame();
}
}
void keyPressed() {
if (key == 'r' || key == 'R') {
recording = !recording;
println("Recording is " + (recording ? "ON" : "OFF"));
} else if (key == 'a' || key == 'A') {
index++;
videoExport = new VideoExport(this, "video" + index + ".mp4");
}
}
导入处理。视频。*;
视频输出视频输出;
布尔记录=假;
捕获cap;
捕捉凸轮;
int指数=0;
无效设置(){
尺寸(400300);
帧率(30);
String[]cameras=Capture.list();
if(cameras.length==0){
println(“没有可供拍摄的摄像机”);
退出();
}否则{
println(“可用摄像机:”);
对于(int i=0;i
请注意,我所做的只是添加索引
变量,然后在keyPressed()
函数中增加该变量。然后使用该索引创建一个新的VideoExport
,这样就不会覆盖现有文件
这样做的好处是将每个视频保存到一个单独的文件中,因此如果您还想播放前3个视频,只需播放index-3
、index-2
和index-1