I capture a video but can't save it .How to halndle the problem via JMF?

Hi everyone, I'm starting to use JMF and faced the problem
The problem is to save captured video in .avi or .mov formats.I managed to capture and play it in a player, but can't save it .On the other hand when I used processor to capture and save the video , I've succeeded .But my task is to combine these two actions. Give a hint please.
All kind of replies will be greatly appreciated.
Edited by: postvard on Feb 25, 2009 12:03 AM

>
You need to get the StreamWriterControl on the DataSink, rather than the Processor.I doesn't seem to work.
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import javax.media.CannotRealizeException;
import javax.media.Control;
import javax.media.DataSink;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoDataSinkException;
import javax.media.NoProcessorException;
import javax.media.Processor;
import javax.media.ProcessorModel;
import javax.media.format.VideoFormat;
import javax.media.protocol.DataSource;
import javax.media.protocol.FileTypeDescriptor;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.media.control.MonitorControl;
import javax.media.control.StreamWriterControl;
public class MyProcessor extends JPanel {
     private MediaLocator locator=null;
     private Processor processor=null;
     private DataSource dataSource=null;
     private DataSink filewriter=null;
     private Format[]formats=new Format[1];
     public MyProcessor() throws NoProcessorException, CannotRealizeException, IOException, InterruptedException {
          setLayout(new BorderLayout());
          FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);
               Format[]format=new Format[1];
               format[0]=new VideoFormat(VideoFormat.YUV);
          locator=new MediaLocator("vfw://0");
          processor=Manager.createRealizedProcessor(new ProcessorModel(locator,format, new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO)));
          Control controls[] = processor.getControls();
          for(Control c:controls){
          if(c instanceof MonitorControl){
          MonitorControl mc = (MonitorControl) c;
          mc.setEnabled(true);
          if (mc.getControlComponent() != null) {
          add("Center", mc.getControlComponent());
          dataSource= processor.getDataOutput();
          MediaLocator dest = new MediaLocator("file:record1.avi");
          try {
          filewriter = Manager.createDataSink(dataSource, dest);
          Control[] dataSink_controls= (Control[])filewriter.getControls();
     for(Control c1:dataSink_controls){
          if(c1 instanceof StreamWriterControl){
               StreamWriterControl stream_size=(StreamWriterControl)c1;
               if(stream_size!=null){
                    stream_size.setStreamSizeLimit(30000);
          filewriter.open();
          } catch (NoDataSinkException e) {
          System.exit(-1);
          } catch (IOException e) {
          System.exit(-1);
          } catch (SecurityException e) {
          System.exit(-1);
          try {
          filewriter.start();
          } catch (IOException e) {
          System.exit(-1);
     processor.start();
     //Thread.currentThread().sleep(20000);
//     processor.stop();
//               processor.close();
//               filewriter.stop();
//               filewriter.close();
     public static void main(String[] args) {
          try {
               MyProcessor processor1=new MyProcessor();
               JFrame frame=new JFrame();
               frame.setSize(300,300);
               frame.add(processor1);
               frame.setVisible(true);
          } catch (NoProcessorException e) {
               e.printStackTrace();
          } catch (CannotRealizeException e) {
               e.printStackTrace();
          } catch (IOException e) {
               e.printStackTrace();
          } catch (InterruptedException e) {
               e.printStackTrace();

Similar Messages

Maybe you are looking for

  • My 13" late 2011 MacBook Pro will not turn on..

    My MacBook Pro only displays one blinking dot on the battery indicator and the MagSafe charger does not display and lights once plugged in and the computer does to respond when pushing the power button Please help

  • Powershell import-spweb fails with "parent does not exist" error.

    So, I have a sp 2010 site at http://myfarm/sites/it/d22 and I want to copy the contents to http://myfarm/sites/bb/d62 . I perform Export-SPWeb -Identity  http://myfarm/sites/it/d22  -Path d:\temp\d22  -IncludeUserSecurity –IncludeVersions All  -NoFil

  • Eastern european edge web font lora

    Hi, I've designed a website using edge web font "Lora" in czech language. It looks good on my Mac, but when viewing on iPhone, iPad or PC (all browsers), there are not international characters like č, ř, š, ě... I know, that this typeface contains al

  • Final Cut Studio on MacBook Pro

    Will all Final Cut Studio 2 programs and features run efficiently on a new MacBook Pro 13"? If not, what MacBook Pro would be the cheapest to run it on?

  • Printing from Elements 8 using Epson Stylus Photo R300

    Help!  I'm really quite useless at all this computer stuff, and my problem is slowly driving me mad!!!  I am trying, unsuccessfully, to print from Elements 8 using an Espon Stylus Photo R300.  However, I dont know what settings to use.  I can get pri