Record video and audio from webcam with GSVideo
in
Share your Work
•
1 year ago
For the last couple of weeks I've been looking for a way to record video and sound from a webcam using Processing. There's no way to record audio using the video library. There might be a way of recording both audio and video using that library along with minim but I just don't know how that could be done.
With the GSVideo library It's possible to use gstreamer pipelines, so using this library it's pretty easy to record a live feed from a webcam.
Here's the code that makes this possible:
- import codeanticode.gsvideo.*;
- GSPipeline pipeline;
- void setup() {
- size(640, 480);
- pipeline = new GSPipeline(this, "v4l2src ! tee name=videoout ! queue ! videorate ! video/x-raw-yuv,width=640,height=480 ! queue ! xvidenc ! queue ! muxout. pulsesrc ! audio/x-raw-int,rate=22000,channels=1,width=16 ! queue ! muxout. avimux name=muxout ! filesink location=video.avi videoout. ! queue ! ffmpegcolorspace");
- pipeline.play();
- }
- void draw() {
- if (pipeline.available()) {
- pipeline.read();
- image(pipeline, 0, 0);
- }
- }
So, here it is, it's possible and really easy to record audio and video from a webcam with processing.