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

  • Home
  • SEARCH
  • 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 575497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:56:49+00:00 2026-05-13T13:56:49+00:00

Here is code: import java.awt.*; import java.util.*; import javax.media.*; import javax.media.protocol.*; import javax.media.control.*; import

  • 0

Here is code:

import java.awt.*;
import java.util.*;
import javax.media.*;
import javax.media.protocol.*;
import javax.media.control.*;
import javax.media.format.*;

public class jmfcam05v
{
       DataSource dataSource;
       PushBufferStream pbs;

       Vector camImgSize = new Vector();
       Vector camCapDevice = new Vector();
       Vector camCapFormat = new Vector();

       int camFPS;
       int camImgSel;

       Processor processor = null;
       DataSink datasink = null;

       public static void main(String[] args)
       {
               jmfcam05v jmfcam = new jmfcam05v();
       }

       public jmfcam05v()
       {

               fetchDeviceFormats();
 camFPS = 30;    // framerate


               fetchDeviceDataSource();
               createPBDSource();
               createProcessor(dataSource);
               startCapture();
               try{Thread.sleep(20000);}catch(Exception e){}   // 20 seconds
               stopCapture();
       }

      boolean fetchDeviceFormats()
       {
               Vector deviceList = CaptureDeviceManager.getDeviceList(new VideoFormat(null));
               CaptureDeviceInfo CapDevice = null;
               Format CapFormat = null;
               String type = "N/A";

               CaptureDeviceInfo deviceInfo=null;boolean VideoFormatMatch=false;
               for(int i=0;i<deviceList.size();i++)
               {
                       // search for video device
                       deviceInfo = (CaptureDeviceInfo)deviceList.elementAt(i);
                       if(deviceInfo.getName().indexOf("vfw:")<0)continue;

                       Format deviceFormat[] = deviceInfo.getFormats();
                       for (int f=0;f<deviceFormat.length;f++)
                       {
                               if(deviceFormat[f] instanceof RGBFormat)type="RGB";
                               if(deviceFormat[f] instanceof YUVFormat)type="YUV";
                               if(deviceFormat[f] instanceof JPEGFormat)type="JPG";

                               Dimension size = ((VideoFormat)deviceFormat[f]).getSize();
                               camImgSize.addElement(type+" "+size.width+"x"+size.height);

                               CapDevice = deviceInfo;
                               camCapDevice.addElement(CapDevice);
                               //System.out.println("Video device = " + deviceInfo.getName());

                               CapFormat = (VideoFormat)deviceFormat[f];
                               camCapFormat.addElement(CapFormat);
                               //System.out.println("Video format = " + deviceFormat[f].toString());

                               VideoFormatMatch=true;  // at least one
                       }
               }
               if(VideoFormatMatch==false)
               {
                       if(deviceInfo!=null)System.out.println(deviceInfo);
                       System.out.println("Video Format not found");
                       return false;
               }

               return true;
       }


       void fetchDeviceDataSource()
       {
               CaptureDeviceInfo CapDevice =
(CaptureDeviceInfo)camCapDevice.elementAt(camImgSel);
               System.out.println("Video device = " + CapDevice.getName());
               Format CapFormat = (Format)camCapFormat.elementAt(camImgSel);
               System.out.println("Video format = " + CapFormat.toString());

               MediaLocator loc = CapDevice.getLocator();
               try
               {
                       dataSource = Manager.createDataSource(loc);
               }
               catch(Exception e){}

               try
               {
                       FormatControl formCont=((CaptureDevice)dataSource).getFormatControls()[0];
                       VideoFormat formatVideoNew = new
VideoFormat(null,null,-1,null,(float)camFPS);
                       formCont.setFormat(CapFormat.intersects(formatVideoNew));
               }
               catch(Exception e){}
       }

       void createPBDSource()
       {
               try
               {
                       pbs=((PushBufferDataSource)dataSource).getStreams()[0];
               }
               catch(Exception e){}
       }

       public void createProcessor(DataSource datasource)
       {
               FileTypeDescriptor ftd = new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);
               Format[] formats = new Format[] {new VideoFormat(VideoFormat.INDEO50)};
               ProcessorModel pm = new ProcessorModel(datasource, formats, ftd);
               try
               {
                       processor = Manager.createRealizedProcessor(pm);
               }
               catch(Exception me)
               {
                       System.out.println(me);
                       // Make sure the capture devices are released
                       datasource.disconnect();
                       return;
               }
       }

       private void startCapture()
       {
               // Get the processor's output, create a DataSink and connect the two.
               DataSource outputDS = processor.getDataOutput();
               try
               {
                       MediaLocator ml = new MediaLocator("file:capture.mpg");
                       datasink = Manager.createDataSink(outputDS, ml);
                       datasink.open();
                       datasink.start();
               }catch (Exception e)
               {
                       System.out.println(e);
               }
               processor.start();
               System.out.println("Started saving...");
       }

       private void pauseCapture()
       {
               processor.stop();
       }

       private void resumeCapture()
       {
               processor.start();
       }

       private void stopCapture()
       {
               // Stop the capture and the file writer (DataSink)
               processor.stop();
               processor.close();
               datasink.close();
               processor = null;
               System.out.println("Done saving.");
       }
}

Error:

run:

Video device = vfw:Microsoft WDM Image Capture (Win32):0
Video format = YUV Video Format: Size = java.awt.Dimension[width=640,height=480] MaxDataLength = 614400 DataType = class [B yuvType = 32 StrideY = 1280 StrideUV = 1280 OffsetY = 0 OffsetU = 1 OffsetV = 3

javax.media.CannotRealizeException: Unable to provide all requested tracks
Exception in thread "main" java.lang.NullPointerException
        at jmfcam05v.startCapture(jmfcam05v.java:202)
        at jmfcam05v.(jmfcam05v.java:82)
        at jmfcam05v.main(jmfcam05v.java:64)

please help me with this error.i am using windows vista OS.

can anyone suggest me how to store files in .3gp format?please help

  • 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-05-13T13:56:49+00:00Added an answer on May 13, 2026 at 1:56 pm
    Exception in thread "main" java.lang.NullPointerException
        at jmfcam05v.startCapture(jmfcam05v.java:202)
    

    Some object reference at line 202 of jmfcam05v.java, inside the startCapture() method, is null while the code is trying to access/invoke it using the dot . operator.

    E.g.

    SomeObject someObject = null;
    someObject.doSomething(); // NullPointerException.
    

    The solution is actually easy. Just make sure that it’s not null by either instantiating it:

    if (someObject == null) {
        someObject = new SomeObject();
    }
    someObject.doSomething(); // No NPE more!
    

    … or by simply doing a nullcheck before accessing/invoking:

    if (someObject != null) {
        someObject.doSomething(); // No NPE more!
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 379k
  • Answers 379k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Instead of changing the WHERE clause, change the LIMIT offset:… May 14, 2026 at 9:42 pm
  • Editorial Team
    Editorial Team added an answer IE doesn't let you access table rows using the document.getElementsByName… May 14, 2026 at 9:42 pm
  • Editorial Team
    Editorial Team added an answer To add a custom button, add this to your command… May 14, 2026 at 9:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.