title: Set the duration of each frame in a video using Xuggler
body: <p>How to set the duration of each frame in a video using Xuggler?</p>
  
  <p>I want to create a video through my Java application using Xuggler.  What I want is really simple.  I have some JPG files and I want to encode them into a video.  I've done that using some helpful sample code.  My question is how can I set the duration of each frame? </p>
  
  <p>For example if I want each picture to be projected for 10secs. I'll post below the sample code of what I have actually done so far. </p>
  
  <pre><code>        for (int index = 0; index &lt; filenames.size(); index++) {
            if(filenames.get(index).toString().contains("jpg")){
              System.err.println(filenames.get(index).toString());
  
              // take the screen shot
  //            BufferedImage screen = getDesktopScreenshot();
              BufferedImage screen = ImageIO.read(filenames.get(index));
  
              // convert to the right image type
              BufferedImage bgrScreen = convertToType(screen,BufferedImage.TYPE_3BYTE_BGR);
  
              int i=0;
              while(i&lt;FRAME_RATE){
                  writer.encodeVideo(0, bgrScreen, System.nanoTime() - startTime, 
                     TimeUnit.NANOSECONDS);
                  ++i;
              }
  
              // sleep for frame rate milliseconds
              try {
                  Thread.sleep((long) (1000 / FRAME_RATE));
              } 
              catch (InterruptedException e) {
                  // ignore
              }
          }
      }
  </code></pre>