Frameaccess.java - time of presentation of each frame

i've found frameaccess, which introduces a plugin in transcoding phase of processing.my question are, (i'm a newbie of jmf) it's possibile to modify in the code below the processor to have in shell display,time of presentation of each frame?another question is :it's possible to modify framerate and bit x pixel of output?
thanks
////////////code
* @(#)FrameAccess.java     1.5 01/03/13
* Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
import java.awt.*;
import javax.media.*;
import javax.media.control.TrackControl;
import javax.media.Format;
import javax.media.format.*;
* Sample program to access individual video frames by using a
* "pass-thru" codec. The codec is inserted into the data flow
* path. As data pass through this codec, a callback is invoked
* for each frame of video data.
public class FrameAccess extends Frame implements ControllerListener {
Processor p;
Object waitSync = new Object();
boolean stateTransitionOK = true;
* Given a media locator, create a processor and use that processor
* as a player to playback the media.
* During the processor's Configured state, two "pass-thru" codecs,
* PreAccessCodec and PostAccessCodec, are set on the video track.
* These codecs are used to get access to individual video frames
* of the media.
* Much of the code is just standard code to present media in JMF.
public boolean open(MediaLocator ml) {
     try {
     p = Manager.createProcessor(ml);
     } catch (Exception e) {
     System.err.println("Failed to create a processor from the given url: " + e);
     return false;
     p.addControllerListener(this);
     // Put the Processor into configured state.
     p.configure();
     if (!waitForState(p.Configured)) {
     System.err.println("Failed to configure the processor.");
     return false;
     // So I can use it as a player.
     p.setContentDescriptor(null);
     // Obtain the track controls.
     TrackControl tc[] = p.getTrackControls();
     if (tc == null) {
     System.err.println("Failed to obtain track controls from the processor.");
     return false;
     // Search for the track control for the video track.
     TrackControl videoTrack = null;
     for (int i = 0; i < tc.length; i++) {
     if (tc.getFormat() instanceof VideoFormat) {
          videoTrack = tc[i];
          break;
     if (videoTrack == null) {
     System.err.println("The input media does not contain a video track.");
     return false;
     System.err.println("Video format: " + videoTrack.getFormat());
     // Instantiate and set the frame access codec to the data flow path.
     try {
     Codec codec[] = { new PreAccessCodec(),
                    new PostAccessCodec()};
     videoTrack.setCodecChain(codec);
     } catch (UnsupportedPlugInException e) {
     System.err.println("The process does not support effects.");
     // Realize the processor.
     p.prefetch();
     if (!waitForState(p.Prefetched)) {
     System.err.println("Failed to realize the processor.");
     return false;
     // Display the visual & control component if there's one.
     setLayout(new BorderLayout());
     Component cc;
     Component vc;
     if ((vc = p.getVisualComponent()) != null) {
     add("Center", vc);
     if ((cc = p.getControlPanelComponent()) != null) {
     add("South", cc);
     // Start the processor.
     p.start();
     setVisible(true);
     return true;
public void addNotify() {
     super.addNotify();
     pack();
* Block until the processor has transitioned to the given state.
* Return false if the transition failed.
boolean waitForState(int state) {
     synchronized (waitSync) {
     try {
          while (p.getState() != state && stateTransitionOK)
          waitSync.wait();
     } catch (Exception e) {}
     return stateTransitionOK;
* Controller Listener.
public void controllerUpdate(ControllerEvent evt) {
     if (evt instanceof ConfigureCompleteEvent ||
     evt instanceof RealizeCompleteEvent ||
     evt instanceof PrefetchCompleteEvent) {
     synchronized (waitSync) {
          stateTransitionOK = true;
          waitSync.notifyAll();
     } else if (evt instanceof ResourceUnavailableEvent) {
     synchronized (waitSync) {
          stateTransitionOK = false;
          waitSync.notifyAll();
     } else if (evt instanceof EndOfMediaEvent) {
     p.close();
     System.exit(0);
* Main program
public static void main(String [] args) {
     if (args.length == 0) {
     prUsage();
     System.exit(0);
     String url = args[0];
     if (url.indexOf(":") < 0) {
     prUsage();
     System.exit(0);
     MediaLocator ml;
     if ((ml = new MediaLocator(url)) == null) {
     System.err.println("Cannot build media locator from: " + url);
     System.exit(0);
     FrameAccess fa = new FrameAccess();
     if (!fa.open(ml))
     System.exit(0);
static void prUsage() {
     System.err.println("Usage: java FrameAccess <url>");
* Inner class.
* A pass-through codec to access to individual frames.
public class PreAccessCodec implements Codec {
* Callback to access individual video frames.
     void accessFrame(Buffer frame) {
     // For demo, we'll just print out the frame #, time &
     // data length.
     long t = (long)(frame.getTimeStamp()/10000000f);
     System.err.println("Pre: frame #: " + frame.getSequenceNumber() +
               ", time: " + ((float)t)/100f +
               ", len: " + frame.getLength());
     * The code for a pass through codec.
     // We'll advertize as supporting all video formats.
     protected Format supportedIns[] = new Format [] {
     new VideoFormat(null)
     // We'll advertize as supporting all video formats.
     protected Format supportedOuts[] = new Format [] {
     new VideoFormat(null)
     Format input = null, output = null;
     public String getName() {
     return "Pre-Access Codec";
     // No op.
public void open() {
     // No op.
     public void close() {
     // No op.
     public void reset() {
     public Format [] getSupportedInputFormats() {
     return supportedIns;
     public Format [] getSupportedOutputFormats(Format in) {
     if (in == null)
          return supportedOuts;
     else {
          // If an input format is given, we use that input format
          // as the output since we are not modifying the bit stream
          // at all.
          Format outs[] = new Format[1];
          outs[0] = in;
          return outs;
     public Format setInputFormat(Format format) {
     input = format;
     return input;
     public Format setOutputFormat(Format format) {
     output = format;
     return output;
     public int process(Buffer in, Buffer out) {
     // This is the "Callback" to access individual frames.
     accessFrame(in);
     // Swap the data between the input & output.
     Object data = in.getData();
     in.setData(out.getData());
     out.setData(data);
     // Copy the input attributes to the output
     out.setFormat(in.getFormat());
     out.setLength(in.getLength());
     out.setOffset(in.getOffset());
     return BUFFER_PROCESSED_OK;
     public Object[] getControls() {
     return new Object[0];
     public Object getControl(String type) {
     return null;
public class PostAccessCodec extends PreAccessCodec {
     // We'll advertize as supporting all video formats.
     public PostAccessCodec() {
     supportedIns = new Format [] {
          new RGBFormat()
* Callback to access individual video frames.
     void accessFrame(Buffer frame) {
     // For demo, we'll just print out the frame #, time &
     // data length.
     long t = (long)(frame.getTimeStamp()/10000000f);
     System.err.println("Post: frame #: " + frame.getSequenceNumber() +
               ", time: " + ((float)t)/100f +
               ", len: " + frame.getLength());
     public String getName() {
     return "Post-Access Codec";

Alternatives to iPhoto's slideshow include:
PhotoToMovie  $49.95
PulpMotion  $129
FotoMagico $99
Final Cut Pro X $299
It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Pro X is the most capable app of them all. You get what you pay for.

Similar Messages

  • Non-interactive FrameAccess.java and frame conversion woes

    Hello all,
    I am searching for a way to convert a webcam-acquired AVI file into a sequence of numbered TIFF images (one for each movie frame). While searching the 'net, I ran into the well-known sample called FrameAccess.java. Although it looks like a good starting point, I got stuck by a number of problems:
    1) I'm not interested in visualizing the frames as they get processed: I've got tons of players I can check the movie with before feeding it in to my extractor. A simple non-interactive application would be better. However, when I comment out the AWT-related portions of FrameAccess, it hangs after processing two or three frames.
    2) Which way is better to process the single frame with: PreAccess or PostAccess?
    2.1) In PreAccess it looks like the frame is still in raw YUV420 format, whereas in PostAccess it seems to have undergone some conversion since the buffer size is equal to the number of pixels. But the buffer data is returned as short[] when I would expect it to be of type byte[]. What am I missing here?
    3) Although it is a priori known that the AVI files were acquired in B/W mode, it looks like the AVI is made of 8-bit RGB frames. How can I possibly convert them into 8-bit or 16-bit grayscale images and save them as TIFF images? (*)
    Any ideas/hints/suggestions whatsoever that might help me tackle the above problems will be highly valued.
    Thanks in advance,
    Emmanuele
    (*) I am aware that this question could be partly off-topic since it may fall more appropriately into the Java2D/JAI realm. However, for the moment I'd like not to open too many threads.

    Hello all,
    I am searching for a way to convert a webcam-acquired AVI file into a sequence of numbered TIFF images (one for each movie frame). While searching the 'net, I ran into the well-known sample called FrameAccess.java. Although it looks like a good starting point, I got stuck by a number of problems:
    1) I'm not interested in visualizing the frames as they get processed: I've got tons of players I can check the movie with before feeding it in to my extractor. A simple non-interactive application would be better. However, when I comment out the AWT-related portions of FrameAccess, it hangs after processing two or three frames.
    2) Which way is better to process the single frame with: PreAccess or PostAccess?
    2.1) In PreAccess it looks like the frame is still in raw YUV420 format, whereas in PostAccess it seems to have undergone some conversion since the buffer size is equal to the number of pixels. But the buffer data is returned as short[] when I would expect it to be of type byte[]. What am I missing here?
    3) Although it is a priori known that the AVI files were acquired in B/W mode, it looks like the AVI is made of 8-bit RGB frames. How can I possibly convert them into 8-bit or 16-bit grayscale images and save them as TIFF images? (*)
    Any ideas/hints/suggestions whatsoever that might help me tackle the above problems will be highly valued.
    Thanks in advance,
    Emmanuele
    (*) I am aware that this question could be partly off-topic since it may fall more appropriately into the Java2D/JAI realm. However, for the moment I'd like not to open too many threads.

  • FrameAccess.java: Modifying frame rate capture ?

    I'm currently supposed to capture the keyframes in a video and I've managed to find FrameAccess.java that has allowed me to capture all the frames in the video.
    However, I do not need to capture every single frame; just need to capture frames maybe every 20 seconds or so.
    -> Therefore, how do I go about doing it?
    Also, when I ran FrameAccess.java, it seems that when it has reached the end of the video, it will keep trying to capture the last frame and it won't end until I manually end it.
    -> How do I rectify this error?
    I really hope someone can help. Thanks in advanced.
    Edited by: silentvisual on Mar 4, 2009 1:08 AM

    However, I do not need to capture every single frame; just need to capture frames maybe every 20 seconds or so. You can grab the frames using FrameGrabbingControl. Then why use FrameAccess.java??
    If you use FrameGrabbingControl, then using Timer you can grab frames at whatever interval you want, e.g. try the following code:
    [http://forums.sun.com/thread.jspa?messageID=10595229#10595229]
    It uses a timer to grab frames at 30ms (you can make it 1000ms or anything by changing this line : " timer = new Timer(30, this);" ).
    Now, I don't know what you want to do after capturing images, do you want to save images only or do you want to make a video from this, if this is the case then you can search for "Jpeg to Movie" JMF program example on this site.
    Also, when I ran FrameAccess.java, it seems that when it has reached the end of the video, it will keep trying to capture the last frame and it won't end until I manually end it. For me, there is no such problem. The program ends when the end of video file is reached.
    Thanks!

  • I have multiple songs I would like to include in my slideshow.  Can I change the rate of presentation for each song?  For instance, upbeat song with a 2 secong presenation time and slower song with a 3 second presentation time?

    I have multiple songs I would like to include in my slideshow.  Can I change the rate of presentation for each song?  For instance, upbeat song with a 2 secong presenation time and slower song with a 3 second presentation time

    Alternatives to iPhoto's slideshow include:
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $99
    Final Cut Pro X $299
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Pro X is the most capable app of them all. You get what you pay for.

  • We are just about to purchase an iphoto book but received the message that we had one or more empty photo frames. We have gone over each page several times and found no empty frames. We cannot purchase the book because we cannot get beyond this message.

    We are just about to purchase an iphoto book but received the message that we had one or more empty photo frames. We have gone over each page several times and found no empty frames. We cannot purchase the book because we cannot get beyond this message. Any ideas on how to rectify this situation?

    So far every time this erros has occured it has been correct - the most difficult one to find is a full page photo layout behind a full page photo - this is hard to find - click here for a discussion on how to find it
    LN

  • Each time I create a Text Frame it appears colored with black?

    Every time I create a Text Frame with the Type tool in InDesing CS5.5 in a document named "02_End.indd", (this happen only for this file) the it appears filled with black color. On the other documents this does not happen (the text frames are with no fill).
    Can anyone tell me how can I change the default color of the Text frames?
    Please help me?

    Make sure you don't have anything selected. Then look in the swatches palette. If you see the default fill is black, set it to [None].
    If not, it may be your default object style, or possibly a document corruption -- if you suspect the latter, you could try to Remove Document Corruption as per the instructions at the top of this forum.

  • How to do implement the FrameAccess.java code in my project

    Iam doing an project in java for inserting the videos into oracle9i and searching the inserted videos using the frames of the videos inserted.I have done the project to insert and search the videos.But i have been asked to put an EXTRACT button to extract all the frames of the video being inserted.Please help me to implement the FrameAccess.java coding in my existing coding.I have pasted my coding(VideoInsert.java) and FrameAccess.java(used to extract frames) coding.
    The VideoInsert.java when executed will contain browse button to choose the video file(only .mpg files) to be inserted into the database.After selecting the file and when we press open button in the Open dialog box,the video will be played in jmf player in a separate window and the filepath of the video will be included in the textbox.Now what i need is,an extract button should be placed and when it is clicked,the frames of the corresponding selected video has to be extracted in the location where the project files are stored i.e.,the FrameAccess.java coding has to be executed.
    Please help me if anyone knows how to implement the above concept.
    VideoInsert.java
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.BLOB ;
    import symantec.itools.multimedia.ImageViewer;
    public class VideoInsert extends javax.swing.JFrame {
        private Connection con;
        private Statement st=null;
        private OracleResultSet rs=null;
        int count=0;
        int count1=0;
        ImageViewer displaywindow = new ImageViewer();
        /** Creates new form VideoInsert */
        public VideoInsert() {
            initComponents();
            imgpane.add(displaywindow);
            try {
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                con = DriverManager.getConnection("jdbc:oracle:oci:@","scott","tiger");
                  //con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:FIRST","scott","tiger");
                con.setAutoCommit(false);
                st =con.createStatement();
                rs=(OracleResultSet)st.executeQuery("select max(vid) from browsevideo");
                while (rs.next()) {
                    count = (rs.getInt(1) + 1);
                rs.close();
                st =con.createStatement();
                rs=(OracleResultSet)st.executeQuery("select max(imageno) from browseimage");
                while (rs.next()) {
                    count1 = (rs.getInt(1) + 1);
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            txtvid.setText(String.valueOf(count));
             VideoTypeComboBox.addItem("All");
            VideoTypeComboBox.addItem("Entertainment");
            VideoTypeComboBox.addItem("Sports");
            VideoTypeComboBox.addItem("Animation");
            VideoTypeComboBox.addItem("News");
             VideoTypeComboBox.addItem("Others");
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {//GEN-BEGIN:initComponents
            jLabel1 = new javax.swing.JLabel();
            txtvid = new javax.swing.JTextField();
            jLabel2 = new javax.swing.JLabel();
            txtvidfile = new javax.swing.JTextField();
            jLabel3 = new javax.swing.JLabel();
            txtvidinfo = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            txtimgfile = new javax.swing.JTextField();
            vidbrowse = new javax.swing.JButton();
            imgbrowse = new javax.swing.JButton();
            jLabel5 = new javax.swing.JLabel();
            txtimgcont = new javax.swing.JTextField();
            insert = new javax.swing.JButton();
            imgpane = new javax.swing.JPanel();
            jLabel6 = new javax.swing.JLabel();
            VideoTypeComboBox = new javax.swing.JComboBox();
            getContentPane().setLayout(null);
            setTitle("VideoInsert");
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            jLabel1.setText("Video ID");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(30, 80, 90, 16);
            txtvid.setEditable(false);
            getContentPane().add(txtvid);
            txtvid.setBounds(130, 80, 130, 20);
            jLabel2.setText("VideoFile");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(30, 130, 70, 16);
            getContentPane().add(txtvidfile);
            txtvidfile.setBounds(130, 130, 130, 20);
            jLabel3.setText("VideoInfo");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(30, 180, 80, 16);
            getContentPane().add(txtvidinfo);
            txtvidinfo.setBounds(130, 180, 130, 20);
            jLabel4.setText("TopImage");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(30, 230, 70, 16);
            getContentPane().add(txtimgfile);
            txtimgfile.setBounds(130, 230, 130, 20);
            vidbrowse.setText("Browse");
            vidbrowse.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    vidbrowseActionPerformed(evt);
            getContentPane().add(vidbrowse);
            vidbrowse.setBounds(280, 130, 78, 26);
            imgbrowse.setText("Browse");
            imgbrowse.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    imgbrowseActionPerformed(evt);
            getContentPane().add(imgbrowse);
            imgbrowse.setBounds(280, 230, 78, 26);
            jLabel5.setText("ImageContent");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(30, 280, 80, 16);
            getContentPane().add(txtimgcont);
            txtimgcont.setBounds(130, 280, 130, 20);
            insert.setText("Insert");
            insert.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    insertActionPerformed(evt);
            getContentPane().add(insert);
            insert.setBounds(150, 400, 81, 26);
            imgpane.setLayout(new java.awt.BorderLayout());
            getContentPane().add(imgpane);
            imgpane.setBounds(410, 120, 350, 260);
            jLabel6.setText("Video Type");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(30, 340, 80, 16);
            getContentPane().add(VideoTypeComboBox);
            VideoTypeComboBox.setBounds(130, 340, 130, 25);
            pack();
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setSize(new java.awt.Dimension(800, 600));
            setLocation((screenSize.width-800)/2,(screenSize.height-600)/2);
        }//GEN-END:initComponents
        private void insertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertActionPerformed
            BLOB blb= null;
            PreparedStatement stmt = null;
            OutputStream fout=null;
            File f=null;
            FileInputStream fin=null;
            int bufferSize;
            byte[] buffer=null;
            int bytesRead = -1;
            String sfile1 = txtvidfile.getText();
            String sfile2 = txtimgfile.getText();
            String format=null;
            String format1=null;
            String videoinfo=txtvidinfo.getText();
            String imgcontent=txtimgcont.getText();
            String videoType=(String)VideoTypeComboBox.getSelectedItem();
            if(sfile1.endsWith("avi")) {
                format="avi";
            }else if(sfile1.endsWith("mpg")) {
                format="mpg";
            }else {
                format="mpg";
            if(sfile2.endsWith("jpg")) {
                format1="jpg";
            }else if(sfile2.endsWith("gif")) {
                format1="gif";
            }else {
                format1="jpg";
            if((sfile1.length()>0) && (sfile2.length()>0)) {
                try {
                    stmt=con.prepareStatement(" insert into browsevideo values (?,EMPTY_BLOB(),?,?,?)");
                    stmt.setInt(1,count);
                    stmt.setString(2,format);
                    stmt.setString(3,videoinfo);
                     stmt.setString(4,videoType);
                    stmt.executeUpdate();
                    stmt.close();
                    con.commit();
                }catch(Exception e) {
                    e.printStackTrace();
                try {
                    stmt = con.prepareStatement("Select video FROM browsevideo WHERE vid = ? for update of video");
                    stmt.setInt(1,count);
                    rs = (OracleResultSet)stmt.executeQuery();
                    rs.next();
                    blb = rs.getBLOB("video");
                    fout = blb.getBinaryOutputStream();
                    f = new File(sfile1);
                    fin = new FileInputStream(f);
                    bufferSize = blb.getBufferSize();
                    buffer = new byte[bufferSize];
                    while((bytesRead = fin.read(buffer)) != -1) {
                        fout.write(buffer, 0, bytesRead);
                    fout.flush();
                    fout.close();
                    con.commit();
                    rs.close();
                    stmt.close();
                }catch(Exception e) {
                    e.printStackTrace();
                try {
                    stmt=con.prepareStatement(" insert into browseimage values (?,?,?,EMPTY_BLOB(),?,?,?)");
                    stmt.setInt(1,count);
                    stmt.setInt(2,count1);
                    stmt.setInt(3,count1);
                    stmt.setString(4,imgcontent);
                    stmt.setString(5,format1);
                    stmt.setString(6,videoType);
                    stmt.executeUpdate();
                    stmt.close();
                    con.commit();
                }catch(Exception e) {
                    e.printStackTrace();
                try {
                    stmt = con.prepareStatement("Select image FROM browseimage WHERE imageno = ? for update of image");
                    stmt.setInt(1,count1);
                    rs = (OracleResultSet)stmt.executeQuery();
                    if(rs.next()) {
                        blb = rs.getBLOB("image");
                        fout = blb.getBinaryOutputStream();
                        f = new File(sfile2);
                        fin = new FileInputStream(f);
                        bufferSize = blb.getBufferSize();
                        buffer = new byte[bufferSize];
                        while((bytesRead = fin.read(buffer)) != -1) {
                            fout.write(buffer, 0, bytesRead);
                        fout.flush();
                        fout.close();
                        con.commit();
                        rs.close();
                    stmt.close();
                    count++;
                    count1++;
                    txtimgfile.setText("");
                    txtvidfile.setText("");
                    txtimgcont.setText("");
                    txtvidinfo.setText("");
                    txtvid.setText(String.valueOf(count));
                    JOptionPane.showMessageDialog(this,"Successfuly Completed");
                }catch(Exception e) {
                    e.printStackTrace();
        }//GEN-LAST:event_insertActionPerformed
        private void imgbrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imgbrowseActionPerformed
            ExampleFileFilter filter1 = new ExampleFileFilter();
            JFileChooser chooser = new JFileChooser();
            filter1.addExtension("jpg");
            filter1.addExtension("gif");
            filter1.setDescription("JPG,GIF Images");
            chooser.setFileFilter(filter1);
            int returnVal = chooser.showOpenDialog(this);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                txtimgfile.setText(chooser.getSelectedFile().getAbsolutePath());
                try{
                        displaywindow.setImageURL(new java.net.URL("file:"+txtimgfile.getText()));
                        displaywindow.setStyle(ImageViewer.IMAGE_SCALED_TO_FIT);
                    }catch(Exception e){
                        e.printStackTrace();
        }//GEN-LAST:event_imgbrowseActionPerformed
        private void vidbrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vidbrowseActionPerformed
           ExampleFileFilter filter2 = new ExampleFileFilter();
           JFileChooser chooser = new JFileChooser();
           filter2.addExtension("avi");
            filter2.addExtension("mpg");
            filter2.setDescription("AVI & MPG Video");
            chooser.setFileFilter(filter2);
            int returnVal = chooser.showOpenDialog(this);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                txtvidfile.setText(chooser.getSelectedFile().getAbsolutePath());
                VideoAudioPlayer vap=new VideoAudioPlayer(txtvidfile.getText());
        }//GEN-LAST:event_vidbrowseActionPerformed
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
            setVisible(false);
            dispose();
        }//GEN-LAST:event_exitForm
         * @param args the command line arguments
        /*public static void main(String args[]) {
            new VideoInsert().show();
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton imgbrowse;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JTextField txtvid;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JTextField txtimgcont;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JPanel imgpane;
        private javax.swing.JButton insert;
        private javax.swing.JComboBox VideoTypeComboBox;
        private javax.swing.JButton vidbrowse;
        private javax.swing.JTextField txtvidfile;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JTextField txtimgfile;
        private javax.swing.JTextField txtvidinfo;
        // End of variables declaration//GEN-END:variables
    FrameAccess.java
    import java.awt.*;
    import javax.media.*;
    import javax.media.control.TrackControl;
    import javax.media.Format;
    import javax.media.format.*;
    import java.io.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.*;
    import java.util.*;
    import javax.media.util.*;
    * Sample program to access individual video frames by using a
    * "pass-thru" codec. The codec is inserted into the data flow
    * path. As data pass through this codec, a callback is invoked
    * for each frame of video data.
    public class FrameAccess implements ControllerListener {
         Processor p;
         Object waitSync = new Object();
         boolean stateTransitionOK = true;
         public boolean alreadyPrnt = false;
         * Given a media locator, create a processor and use that processor
         * as a player to playback the media.
         * During the processor's Configured state, two "pass-thru" codecs,
         * PreAccessCodec and PostAccessCodec, are set on the video track.
         * These codecs are used to get access to individual video frames
         * of the media.
         * Much of the code is just standard code to present media in JMF.
         public boolean open(MediaLocator ml) {
              try {
                   p = Manager.createProcessor(ml);
                                } catch (Exception e) {
                   System.err.println(
                        "Failed to create a processor from the given url: " + e);
                   return false;
              p.addControllerListener(this);
              // Put the Processor into configured state.
              p.configure();
              if (!waitForState(Processor.Configured)) {
                   System.err.println("Failed to configure the processor.");
                   return false;
              // So I can use it as a player.
              p.setContentDescriptor(null);
              // Obtain the track controls.
              TrackControl tc[] = p.getTrackControls();
              if (tc == null) {
                   System.err.println(
                        "Failed to obtain track controls from the processor.");
                   return false;
              // Search for the track control for the video track.
              TrackControl videoTrack = null;
              for (int i = 0; i < tc.length; i++) {
                   if (tc.getFormat() instanceof VideoFormat) videoTrack = tc[i];
                   else     tc[i].setEnabled(false);
              if (videoTrack == null) {
                   System.err.println("The input media does not contain a video track.");
                   return false;
              String videoFormat = videoTrack.getFormat().toString();
              Dimension videoSize = parseVideoSize(videoFormat);
              System.err.println("Video format: " + videoFormat);
              // Instantiate and set the frame access codec to the data flow path.
              try {
                   Codec codec[] = { new PostAccessCodec(videoSize)};
                   videoTrack.setCodecChain(codec);
              } catch (UnsupportedPlugInException e) {
                   System.err.println("The process does not support effects.");
              // Realize the processor.
              p.prefetch();
              if (!waitForState(Processor.Prefetched)) {
                   System.err.println("Failed to realise the processor.");
                   return false;
              p.start();
              return true;
         /**parse the size of the video from the string videoformat*/
         public Dimension parseVideoSize(String videoSize){
              int x=300, y=200;
              StringTokenizer strtok = new StringTokenizer(videoSize, ", ");
              strtok.nextToken();
              String size = strtok.nextToken();
              StringTokenizer sizeStrtok = new StringTokenizer(size, "x");
              try{
                   x = Integer.parseInt(sizeStrtok.nextToken());
                   y = Integer.parseInt(sizeStrtok.nextToken());
              } catch (NumberFormatException e){
                   System.out.println("unable to find video size, assuming default of 300x200");
              System.out.println("Image width = " + String.valueOf(x) +"\nImage height = "+ String.valueOf(y));
              return new Dimension(x, y);
         * Block until the processor has transitioned to the given state.
         * Return false if the transition failed.
         boolean waitForState(int state) {
              synchronized (waitSync) {
                   try {
                        while (p.getState() != state && stateTransitionOK)
                             waitSync.wait();
                   } catch (Exception e) {
              return stateTransitionOK;
         * Controller Listener.
         public void controllerUpdate(ControllerEvent evt) {
              if (evt instanceof ConfigureCompleteEvent
                   || evt instanceof RealizeCompleteEvent
                   || evt instanceof PrefetchCompleteEvent) {
                   synchronized (waitSync) {
                        stateTransitionOK = true;
                        waitSync.notifyAll();
              } else if (evt instanceof ResourceUnavailableEvent) {
                   synchronized (waitSync) {
                        stateTransitionOK = false;
                        waitSync.notifyAll();
              } else if (evt instanceof EndOfMediaEvent) {
                   p.close();
                   System.exit(0);
         * Main program
         public static void main(String[] args) {
    //          if (args.length == 0) {
    //               prUsage();
    //               System.exit(0);
    // System.out.print("masoud");
    String url = new String("file:F:\\AVSEQ01.mpg");
              if (url.indexOf(":") < 0) {
                   prUsage();
                   System.exit(0);
              MediaLocator ml;
              if ((ml = new MediaLocator(url)) == null) {
                   System.err.println("Cannot build media locator from: " + url);
                   System.exit(0);
              FrameAccess fa = new FrameAccess();
              if (!fa.open(ml))
                   System.exit(0);
         static void prUsage() {
              System.err.println("Usage: java FrameAccess <url>");
         * Inner class.
         * A pass-through codec to access to individual frames.
         public class PreAccessCodec implements Codec {
              * Callback to access individual video frames.
              void accessFrame(Buffer frame) {
                   // For demo, we'll just print out the frame #, time &
                   // data length.
                   long t = (long) (frame.getTimeStamp() / 10000000f);
                   System.err.println(
                        "Pre: frame #: "
                             + frame.getSequenceNumber()
                             + ", time: "
                             + ((float) t) / 100f
                             + ", len: "
                             + frame.getLength());
              * The code for a pass through codec.
              // We'll advertize as supporting all video formats.
              protected Format supportedIns[] = new Format[] { new VideoFormat(null)};
              // We'll advertize as supporting all video formats.
              protected Format supportedOuts[] = new Format[] { new VideoFormat(null)};
              Format input = null, output = null;
              public String getName() {
                   return "Pre-Access Codec";
              //these dont do anything
              public void open() {}
              public void close() {}
              public void reset() {}
              public Format[] getSupportedInputFormats() {
                   return supportedIns;
              public Format[] getSupportedOutputFormats(Format in) {
                   if (in == null)
                        return supportedOuts;
                   else {
                        // If an input format is given, we use that input format
                        // as the output since we are not modifying the bit stream
                        // at all.
                        Format outs[] = new Format[1];
                        outs[0] = in;
                        return outs;
              public Format setInputFormat(Format format) {
                   input = format;
                   return input;
              public Format setOutputFormat(Format format) {
                   output = format;
                   return output;
              public int process(Buffer in, Buffer out) {
                   // This is the "Callback" to access individual frames.
                   accessFrame(in);
                   // Swap the data between the input & output.
                   Object data = in.getData();
                   in.setData(out.getData());
                   out.setData(data);
                   // Copy the input attributes to the output
                   out.setFlags(Buffer.FLAG_NO_SYNC);
                   out.setFormat(in.getFormat());
                   out.setLength(in.getLength());
                   out.setOffset(in.getOffset());
                   return BUFFER_PROCESSED_OK;
              public Object[] getControls() {
                   return new Object[0];
              public Object getControl(String type) {
                   return null;
         public class PostAccessCodec extends PreAccessCodec {
              // We'll advertize as supporting all video formats.
              public PostAccessCodec(Dimension size) {
                   supportedIns = new Format[] { new RGBFormat()};
                   this.size = size;
              * Callback to access individual video frames.
              void accessFrame(Buffer frame) {
                   // For demo, we'll just print out the frame #, time &
                   // data length.
                   if (!alreadyPrnt) {
                        BufferToImage stopBuffer = new BufferToImage((VideoFormat) frame.getFormat());
                        Image stopImage = stopBuffer.createImage(frame);
                        try {
                             BufferedImage outImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
                             Graphics og = outImage.getGraphics();
                             og.drawImage(stopImage, 0, 0, size.width, size.height, null);
                             //prepareImage(outImage,rheight,rheight, null);
                             Iterator writers = ImageIO.getImageWritersByFormatName("jpg");
                             ImageWriter writer = (ImageWriter) writers.next();
                             //Once an ImageWriter has been obtained, its destination must be set to an ImageOutputStream:
                             File f = new File(frame.getSequenceNumber() + ".jpg");
                             ImageOutputStream ios = ImageIO.createImageOutputStream(f);
                             writer.setOutput(ios);
                             //Finally, the image may be written to the output stream:
                             //BufferedImage bi;
                             //writer.write(imagebi);
                             writer.write(outImage);
                             ios.close();
                        } catch (IOException e) {
                             System.out.println("Error :" + e);
                   //alreadyPrnt = true;
                   long t = (long) (frame.getTimeStamp() / 10000000f);
                   System.err.println(
                        "Post: frame #: "
                             + frame.getSequenceNumber()
                             + ", time: "
                             + ((float) t) / 100f
                             + ", len: "
                             + frame.getLength());
              public String getName() {
                   return "Post-Access Codec";
              private Dimension size;

    check out the java.lang.Runtime and java.lang.Process classes

  • How do I apply a filter to a video clip? (Without having to do it individually to each frame)

    How do I apply a filter to a video clip? (Without having to do it individually to each frame)

    put levels on which you want to apply the filter, you will see them in the time line as a group ten apply filter, you can also adgust them all in time line...
    sam

  • AHH!  FLOATING AUDIO METER FAILS TO REGISTER EACH FRAME'S LEVEL!

    I have a problem regarding the floating audio meter - ie, the small 2 track meter that usually sits next to the tools strip in the standard window setup. For some reason, when I scroll along clips in my timeline (using the left/right arrow keys) it doesnt show the levels of each individual frame, nor does it produce the sound that should be heard from that specific frame. This is a huge problem for me, as I am trying hard to sync up clips to music, and I am now stuck with just guessing where I should cut it based on intuition. Also, along with the floating audio meter, the actual audio mixer doesn't register the levels either when trying to move frame by frame. I must make it clear that when in preview(play) mode, the audio does register and can be seen moving along with the sounds produced, but when i press space(stop) it(the level of audio) simply stays put, and does NOT change from the time that I last stopped playing the sequence.
    If I am being to confusing, I am trying to be able to (while moving frame by frame with the arrow keys) see and literally hear each individual frame in efforts to make synchronizing a **** of a lot easier and more practical.
    This has never been a problem before, and has just recently burdened me. I have tried restarting the settings/preferences, starting new projects, looking in the manual, etc. No dice. Can someone please help me restore FCP's ability to hear each frames audible material, as well as witness each specific decibel level of the individual frames as I arrow across?

    Well...
    if you make sure scrubbing is on, that would help.
    You can also turn on the waveforms in the timeline tracks.
    That should help too.

  • Java Timer problem

    hi,
    i am finding some problem using java timer.
    I have a server program that regularly needs to save its data. i want to do it using java Timer.
    i got the following sample code as an example. it works perfectly but how can i send new data each time to save?
    import java.util.Timer;
    import java.util.TimerTask;
    import Core.General;
    public class test_timer {
    public static void main(final String args[]) {
    final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new ttask(), 3000, 3000);
    class ttask extends TimerTask
    public void run() {
    System.out.println("hello ");
    As an example i would like to send current time to the timer task and print it. how is it possible?
    regards
    tom

    For the current time you can just go ahead and do the following call:
    System.currentTimeMillis();
    This will get you the current time in milleseconds.
    When timer is called, get the crrent time and print it.
    Hope this helps.
    hi,
    i am finding some problem using java timer.
    I have a server program that regularly needs to save
    its data. i want to do it using java Timer.
    i got the following sample code as an example. it
    works perfectly but how can i send new data each time
    to save?
    import java.util.Timer;
    import java.util.TimerTask;
    import Core.General;
    public class test_timer {
    public static void main(final String args[]) {
    final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new ttask(), 3000,
    000, 3000);
    class ttask extends TimerTask
    public void run() {
    System.out.println("hello ");
    As an example i would like to send current time to the
    timer task and print it. how is it possible?
    regards
    tom

  • Java 8: Pb with new java.time api

    Hello,
    I'm trying to use the new java.time api that comes with Java 8 (I already know joda-time).
    I'm using the latest build B124.
    I've a String "01/08/2012_00:00:01", I know that the time ref. is UTC, and I want to convert it to an 'Instant';
    I tried:
    DateTimeFormatter FORMAT_DT = DateTimeFormatter.ofPattern("dd/MM/yyyy_HH:mm:ss").withZone(ZoneOffset.UTC);
    Instant instant = Instant.from(FORMAT_DT.parse("01/08/2012_00:00:01"));
    But it fails with following error:
    java.time.DateTimeException: Unable to obtain Instant from TemporalAccessor: {},ISO resolved to 2012-08-01T00:00:01 of type java.time.format.Parsed
         at java.time.Instant.from(Unknown Source)
    I don't understand what's wrong with my code, and I can't figure out how I should proceed to convert the String to an Instant ...
    Any suggestion welcome,
    Best regards,
    Bernard.

    Originally you stated this:
    I don't understand what's wrong with my code,
    So naturally we focused on how to "understand what's wrong' with your code.
    You will never learn to troubleshoot problems if you just throw your hands up in the air and ask for help just because a complex series of steps doesn't complete successfully. 
    Break the process into its individual steps and check the results of each step to identify which step is FIRST producing an error.
    When a complex or multi-step process has an error you start checking the individual steps of the process to see how far it gets successfully.
    I would expect that converting a String to an Instant should be a basic/simple need, so it should be possible to do it in two lines of code; for the time being, the only way I found is to use a LocalDateTime intermediate variable, which seems quite verbose, and I'm wondering if someone knows a better way to do it, and would be willing to share it here.
    Just a technical distinction: your latest example using a LocalDateTime intermediate variable CAN be done in one line of code by just using dot-notation to avoid creating an explicit intermediate variable. But that variable will still be created implicitly behind the scenes.
    Converting a String to an Instant might be considered a basic/simple need but the set of functionality related to dealing with times, dates, calendars, etc is extremely complex. It makes much more sense to develop the requisite functionality in modules.
    Especially when introducing new functionality such as the 'Instant' class are related package elements introduced in 1.8. That functionality builds on what came before and parsers already existing that know how to deal with all of the possible String variants and formatting options and so on.
    Since that work CAN BE done on-the-fly using dot notation and anonymous implicit intermediate classes there isn't much need to reinvent that functionality in the new classes. If certain uses become standard new methods can always be added (e.g. to the Instant class) that will 'appear' to do things in one step.
    And, being an early adopter release, you can always file a 'bug' or enhancement request from the 1.8 download page. That page has links for 'Report Bugs' and 'Feedback forum' that you can use.
    In this current forum no one can give you an 'official' answer as to why something was implemented a particular way and/or whether that implementation is a 'bug' or was designed to work that way. Only Oracle can do that.

  • Execute Javascript on each frame

    Hello,
    I would like to know if it's possible to stop my animation on each frame, execute an javascript (html2canvas) and restart my animation ?
    Can we do it without add my js on each frame ?
    Thanks for your help

    Hum, frame and time are different. Animate uses time. I guess you could have a stop at each increment of a certain elapse of time by a certain amount and loop it until completion. Probably a do while loop.
    But If you need to make screenshots of your animation, another solution would be to use a screenrecorder and then get each frame from the video.

  • How do I continually loop frames with a 20 second pause in each frame from the same scene without going to the next scene?

    How do I continually loop frames with a 20 second pause in each frame from the same scene without going to the next scene? There are buttons for the other scenes in these frames. The below works well until I am at the last frame in scene one, then it goes to the next scene and plays. How can I make scene one a continually loop.
    stop();
    var timer:Timer = new Timer(20000,0);//<--
    timer.addEventListener(TimerEvent.TIMER, timerHandler);
    timer.start();
    function timerHandler(event:TimerEvent):void {
        this.nextFrame();
        //or if you want to jump e.g 5 frames
        this.gotoAndStop(this.currentFrame+5);
    Thank you for any help.

    For this code to work, you need to empty the first frame and place all the photos a frame ahead. Then, place this code on the first frame. DONE!
    If you need more help, I'll try to answer it the fastest I can.
    Oh, and I could actualy make your photos fade out and fade in as they rotate from frame to frame, it would be awesome. Just tell me if you want me to do it. Good luck
    import flash.display.Scene;
    import flash.events.TimerEvent;
    stop();
    var timer:Timer = new Timer(2000,0);
    timer.addEventListener(TimerEvent.TIMER, timerHandler);
    timer.start();
    function timerHandler(event:TimerEvent):void {
    if (this.currentScene.name == "Scene 1") {
      if (this.currentFrame != this.currentScene.numFrames) {
       this.nextFrame();
      } else {
       this.gotoAndStop(2);
    nextFrame();

  • How can I automate the threshold for a moving object whose light intensity changes for each frame.

    I'm using the PCI-1408 and I have this video where an object's shape and color intensity changes for each frame. I want to do a pixel count of that object verses the background (the background also changes color) for each frame. I'm guessing that I need an automatic threshold, but I really have no idea of how to implement this. Any ideas, anyone?

    Hopefully there is a clear distinction between the background and the object.
    You can use IMAQ AutoBThreshold to determine the threshold level for an image. You can select from a variety of methods for determining a binary threshold level. Route the "Threshold Data" output along with your image to IMAQ MultiThreshold, which will quickly apply the threshold to your image. Display the results using WindDraw and the Binary palette (from IMAQ GetPalette).
    This should run close to real-time. Binary thresholding is a fairly fast operation. You will probably end up processing every other image, which is close enough for most projects.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Calculating how long each frame should be on screen?

    I'm going to bring a lot of still frames into FCP, say 1000 and I want the Sequence to be 24 FPS. How do I calculate the amount of time that each frame should be on screen?
    Thanks.

    Thanks, I guess what I should have asked was how to enter that into the duration field for the frame. If 1 / 24 = 0.0416666667 how does that translate to 00:00:00:00
    Pardon my ignorance.
    Thanks.

Maybe you are looking for