Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8213177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:01:20+00:00 2026-06-07T11:01:20+00:00

I just installed almost all libraries of openimaj instruction wise from the site: http://sourceforge.net/p/openimaj/wiki/OpenIMAJ%20From%20Source/

  • 0

I just installed almost all libraries of openimaj instruction wise from the site: http://sourceforge.net/p/openimaj/wiki/OpenIMAJ%20From%20Source/ libraries are installed and working. I just need a sample code to capture video from webcam and save it to hard disk. For example:

This is the code to turn on the camera and show you video:


import org.openimaj.image.MBFImage;
import org.openimaj.video.VideoDisplay;
import org.openimaj.video.VideoDisplayListener;
import org.openimaj.video.capture.VideoCapture;

public class VideoDemo {
    ...
    VideoCapture vc = new VideoCapture( 320, 240 );
    VideoDisplay<MBFImage> vd = VideoDisplay.createVideoDisplay( vc );
    ...
}

How do I save [vd] on disk?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:01:21+00:00Added an answer on June 7, 2026 at 11:01 am

    You need to use the XuggleVideoWriter class. The following code displays the video content on the screen and writes the content to a file until the escape key is pressed. The format of the video is controlled by the name of the file (i.e. “video.flv” creates an FLV format video).

    package org.openimaj.demos.sandbox;
    
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.io.IOException;
    
    import javax.swing.SwingUtilities;
    
    import org.openimaj.image.MBFImage;
    import org.openimaj.video.Video;
    import org.openimaj.video.VideoDisplay;
    import org.openimaj.video.VideoDisplayListener;
    import org.openimaj.video.capture.VideoCapture;
    import org.openimaj.video.xuggle.XuggleVideoWriter;
    
    /**
     * Record the webcam to a file.
     * 
     * @author Jonathon Hare (jsh2@ecs.soton.ac.uk)
     */
    public class VideoRecorder extends KeyAdapter implements VideoDisplayListener<MBFImage> {
        private Video<MBFImage> video;
        private VideoDisplay<MBFImage> display;
        private XuggleVideoWriter writer;
        private boolean close = false;
    
        /**
         * Default constructor
         * @throws IOException
         */
        public VideoRecorder() throws IOException {
            //open webcam
            video = new VideoCapture(320, 240);
    
            //open display
            display = VideoDisplay.createVideoDisplay(video);
    
            //open a writer
            writer = new XuggleVideoWriter("video.flv", video.getWidth(), video.getHeight(), 30);
    
            //set this class to listen to video display events
            display.addVideoListener(this);
    
            //set this class to listen to keyboard events
            SwingUtilities.getRoot(display.getScreen()).addKeyListener(this);
        }
    
        @Override
        public void afterUpdate(VideoDisplay<MBFImage> display) {
            //Do nothing
        }
    
        @Override
        public void beforeUpdate(MBFImage frame) {
            //write a frame 
            if (!close) {
                writer.addFrame(frame);
            }
        }
    
        @Override
        public void keyPressed(KeyEvent key) {
            //wait for the escape key to be pressed
            close = key.getKeyCode() == KeyEvent.VK_ESCAPE;
        }
    
        /**
         * Main method
         * @param args ignored
         * @throws IOException 
         */
        public static void main(String[] args) throws IOException {
            new VideoRecorder();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just installed iOs5, and almost all went surprisingly fluent - but now I
Just installed and migrated a 2008 solution on Vista ultimate 64 and .net 4.0.
I have just installed dexterity into our office's intranet site so that I can
Just installed a clean version of mongodb on Fedora 17 64-bit, but the Mongo
Just installed Python 2.7.3 on a Windows7 machine. How do I get .py files
Just installed Jenkins in Ubuntu 12.04 and I wanted to create a simple build
Just installed the SDK and ADK. while updating, it gives the following error: unexpected
Just installed EE everything seems clear however I can't seem to find a solution
I just installed FuzzyFinder for gvim, though for some reason it's using an ultra
I just installed Fedora in a virtual machine, and when I open vim, my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.