<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with duration() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=duration%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:46:53 +0000</pubDate>
         <description>Tagged with duration() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedduration%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Multiple videos smoothness - threaded playback</title>
      <link>https://forum.processing.org/two/discussion/28057/multiple-videos-smoothness-threaded-playback</link>
      <pubDate>Fri, 15 Jun 2018 20:57:02 +0000</pubDate>
      <dc:creator>grumo</dc:creator>
      <guid isPermaLink="false">28057@/two/discussions</guid>
      <description><![CDATA[<p>Hello!
This script only requires a bunch of .mp4s in the data folder. You'll see a collage of 9 videos (or duplicates) in different positions and transparencies. The thing runs ok but even pre-loading the videos at the beginning every time there's a change/swap in one of the videos (around every 4 seconds) the whole thing freezes for a sec, sometimes (try to use mp4s of different sizes).</p>

<p>I tried to use the thread() command in the switching of the videos but nothing happened. I put a println to see the thread but alway show the main thread, I really don't know if I'm doing this ok..</p>

<p>Thanks a LOT for any help!</p>

<pre><code>import processing.video.*;

File path; 
String[] files;
int numfiles = 0;
int timer = -5000;
int tcontrol= 2000;
int numVideos=9;

VideoM[] v = new VideoM[numVideos];
Movie[] vv;

void setup(){
  size(1920, 1080, P2D);
  frameRate(60);
  files = files(); 
  numfiles = files.length;
  if (numfiles&gt;11) numfiles=11;
  loadvideos();

  for(int i = 0;i &lt; numVideos;i++){
     v[i] = new VideoM();
  }
}


void draw() {

  background(0);
  for(int i = 0; i &lt;numVideos; i++){
     v[i].display();
  }

  if ((millis() - timer) &gt; tcontrol)  {
    thread("newvideo");   
    timer = millis();
    tcontrol= int(random(2,6))*1000; 
}
}


void loadvideos(){

 String video;
 vv = new Movie[numfiles];

 for (int i=0; i&lt;numfiles; i++){
   video= files[int(random(numfiles))];
   vv[i] = new Movie(this, video);
   println ("Loading ", video);
 }
}

class VideoM {

 Movie m;
 String video;

 int x;
 int y;
 int w;
 int h;
 int alpha;
 int alphai;
 int fadeout=0;

 VideoM() {
  genera();
  println(numfiles);
  m = vv[int(random(numfiles)) ];
  m.loop();
  // m.volume(random(0.4,0.6));
  // m.speed(random(0.6,1.0));
  m.jump(random(m.duration()));  
  //m.play(); 
 }

 void genera(){
    x=int(random(50, width/2+width/4)); 
    y=int(random(50, height/2+height/4)); 
    w=int(random(280,820));
    h=int(w/1.88);
    alpha=int(random(100,255)); 
    alphai=0; 
 }

 void display(){
   tint(255, alphai);
   if (fadeout==0) {
     alphai++; if (alphai&gt;alpha) alphai=alpha;
   } else {  alphai--; if (alphai&lt;0) {alphai=0;fadeout=0;this.newvid();}
     }

   if (frameCount &gt; 1) { image(m, x, y, w, h); }
 } 

 void cambiavid(){
   fadeout=1;
 }

void newvid() {  
   m=null;
   int j=int(random(numfiles));
   println("cambio: ", j);
   m = vv[j];
   m.loop();
   genera();
   m.jump(random(m.duration())); 
   println(Thread.currentThread());
 }
}  

void newset(){
  for(int i = 0;i &lt; numVideos;i++){
    println(i);
    v[i].newvid();
  }
}

void newvideo(){
  int i = int(random(numVideos));
  //v[i].nuevovid(this);
  v[i].cambiavid();
}

void movieEvent(Movie m) {
  m.read();
}

boolean bStop,bColor=true;
boolean bSave=false,bVidO=false;
void keyPressed()
{
  int k = keyCode;

  // reset all videos
  if (key == 'n' || key == 'N') {
    newset();
    }

}  


// load files in data

String[] files(){
// The data path of the folder to look in (write your own)
java.io.File folder = new java.io.File(dataPath(""));

// let's set a filter (which returns true if file's extension is .jpg)
java.io.FilenameFilter pngFilter = new java.io.FilenameFilter() {
  public boolean accept(File dir, String name) {
    return name.toLowerCase().endsWith(".mp4");
  }
};

// list all the folders inside the main directory
String[] listFolders = folder.list(new java.io.FilenameFilter() {
  public boolean accept(File current, String name) {
    return new File(current, name).isDirectory();
  }
});

// list the files in the data folder, passing the filter as parameter
String[] filenames = folder.list(pngFilter);

return(filenames);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I tell if a GLMovie is done playing?</title>
      <link>https://forum.processing.org/two/discussion/27565/how-do-i-tell-if-a-glmovie-is-done-playing</link>
      <pubDate>Sat, 31 Mar 2018 01:33:17 +0000</pubDate>
      <dc:creator>TheodoreMichels</dc:creator>
      <guid isPermaLink="false">27565@/two/discussions</guid>
      <description><![CDATA[<p>I'm having a hard time figuring out when a GLMovie is done playing.</p>

<p>Here's my code, a very slightly modified version of the "SingleVideo" example from the GL Video library:</p>

<pre><code>import gohai.glvideo.*;
GLMovie video;

void setup() {
  size(560, 406, P2D);
  video = new GLMovie(this, "launch1.mp4");

  video.play();
}

void draw() {
  background(0);
  if (video.available()) {
    video.read();
    println(video.time() + " of " + video.duration());
    // e.g. 14.951508 of 14.981999 when done
    if(video.time() &gt;= video.duration()){
      println("Done playing."); // This never happens.
    }
  }
  image(video, 0, 0, width, height);
}
</code></pre>

<p>So the video time never actually reaches the duration - and anyway it would be nice to attach to some kind of event, rather than checking manually every frame.</p>

<p>I tried the solution posted here:
<a rel="nofollow" href="https://forum.processing.org/two/discussion/14990/movie-begin-and-end-events#Item_1">https://forum.processing.org/two/discussion/14990/movie-begin-and-end-events#Item_1</a></p>

<p>But apparently the eosEvent function doesn't exist in the GL Video library.</p>

<p>Anyone know of an equivalent? Or maybe another solution to this problem?</p>

<p>Thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>Movie.duration() always returns 0.0, framerate() and speed() do not seem to affect playback</title>
      <link>https://forum.processing.org/two/discussion/26225/movie-duration-always-returns-0-0-framerate-and-speed-do-not-seem-to-affect-playback</link>
      <pubDate>Sat, 03 Feb 2018 07:06:49 +0000</pubDate>
      <dc:creator>ajohnsonlaird</dc:creator>
      <guid isPermaLink="false">26225@/two/discussions</guid>
      <description><![CDATA[<p>I've just started to experiment with the Movie library and I've run into some basic questions.</p>

<p>Here's the testbed code:</p>

<pre><code>import processing.video.*;
Movie myMovie;
int screenSizeX = 800;
int screenSizeY = 600;
float duration = 0;

void settings()
{
  size(screenSizeX, screenSizeY);
}
void setup() {

  myMovie = new Movie(this, "20180201103135_20180201103155_01_M.dav");
  myMovie.frameRate(25);
  myMovie.speed(0.01);
  duration = myMovie.duration();
  println("setup duration =" + duration);
  duration = myMovie.playbin.queryDuration().toSeconds();
  println("setup playbin.queryDuration() duration =" + duration);
  myMovie.loop();
}

void draw() {
  image(myMovie, 0, 0);
  println("Duration=" + myMovie.duration());
}

// Called every time a new frame is available to read
void movieEvent(Movie m) {
  m.read();
  duration = myMovie.duration();
  println("movieEvent duration =" + duration);
}
</code></pre>

<p>When I run it, duration always appear to return 0.0 regardless of when I test it -- including if I call playbin directly (mimicking the library code at line 270 here: <a rel="nofollow" href="https://github.com/processing/processing-video/blob/master/src/processing/video/Movie.java">https://github.com/processing/processing-video/blob/master/src/processing/video/Movie.java</a> ).</p>

<p>The console output is:<br />
    setup duration =0.0<br />
    setup playbin.queryDuration() duration =0.0<br />
    movieEvent duration =0.0<br />
    Duration=0.0<br />
    Duration=0.0<br />
    movieEvent duration =0.0<br />
    Duration=0.0<br />
    :<br /></p>

<p>What I was really trying to do (apart from experimenting with playback at various speeds) was figure out how to detect when a Movie has finished playing? I've seen some example code that did this:</p>

<pre><code>if (myMovie.time() &gt;= myMovie.duration()) // Test if the playhead is at the end
{
   // end of Movie
}
</code></pre>

<p>Of course that's destined to fail if .duration() always returns zero. So that raises the question, how do you tell when a movie has finished?? I supposed I could check when .time() stops changing, but that squawks a dreaded red text error on the console when the code runs "off the end" of the Movie.</p>

<p>Anyone got any ideas how you test for when a Movie has finished playing? I need to work my way through a directory with hundreds of different movie files and extract individual frames -- I've figured out what I thought would be the hard part only to screech to a halt on this "simple" problem. :(</p>

<p>Oh....and anyone got any ideas why myMovie.frameRate() and .speed() don't appear to do anything?</p>

<p>Thanks in advance
Andy</p>
]]></description>
   </item>
   <item>
      <title>Sound gets distorted when runned in processing</title>
      <link>https://forum.processing.org/two/discussion/25905/sound-gets-distorted-when-runned-in-processing</link>
      <pubDate>Wed, 10 Jan 2018 21:02:54 +0000</pubDate>
      <dc:creator>Faffie</dc:creator>
      <guid isPermaLink="false">25905@/two/discussions</guid>
      <description><![CDATA[<p>Hello World, I have written a processing code and have implemented a sound file. When I play it on a common player, a cleat woman voice comes out. If I run my code processing is distorting her voice into a slow man version... I am runnin processing on a MacBook Pro with the latest Java version.</p>

<pre><code>import processing.serial.*;
import processing.sound.*;


int S1_WAITING_FOR_PEOPLE  = 1;
int S2_PEOPLE_ENTERED      = 2;
int S3_LIGHT_FADE_OUT      = 3;
int S4_DARK                = 4;
int S5_MUSIC               = 5;
int S6_LIGHT_FADE_IN       = 6;
// make sure this is the last!!!!
int TERMINATE              = 7;

int mode = S1_WAITING_FOR_PEOPLE;




int no_one_when_distance_greater_then = 160; // cm
int time_before_dim = 5000; // ms

SoundFile file;
boolean is_playing = false;

Serial myPort;  

int dist;

boolean someone_present = false;
int someone_present_since_time;


int music_playing_since;
int music_duration;

int in_mode_since_ms;

void setup() {
  size(640, 360);

  printArray(Serial.list()); // "/dev/cu.usbmodem1411" cu.usb!!!

  myPort = new Serial(this, Serial.list()[1], 9600);
  //myPort.readStringUntil('\n');
  myPort.bufferUntil('\n');

  // Load a soundfile from the data folder of the sketch and play it back in a loop
  file = new SoundFile(this, "03.mp3");
  //file.loop();
  music_duration = (int) file.duration() * 1000;
  music_duration += 2000;

}      

void draw() {
  background(0);
  fill(255);
  text("frameCount: "+frameCount, 50, 25);
  text("dist: "+dist, 50, 50);
  text("mode: "+mode, 50, 75);


  if (frameCount == 180) {
    turn_on();
  } else if (frameCount &gt; 180) {

    if ( mode == S1_WAITING_FOR_PEOPLE) {

      if (someone_present == false) {
        if (dist &lt; no_one_when_distance_greater_then) {
          someone_present = true;
          someone_present_since_time = millis();
          change_mode(mode + 1);
        }
      }
    } else if (mode == S2_PEOPLE_ENTERED) {
      text("millis: "+millis(), 50, 100);
      text("someone_present_since_time: "+someone_present_since_time, 50, 125);
      text("time_before_dim: "+time_before_dim, 50, 150);
      if (millis() - someone_present_since_time &gt; time_before_dim) {
        change_mode(mode + 1);
      }
    } else if (mode == S3_LIGHT_FADE_OUT) {
      turn_off();
      change_mode(mode + 1);
    } else if (mode == S4_DARK) 
    {
      change_mode(mode + 1);
    } else if (mode == S5_MUSIC) 
    {
      if (is_playing == false) {
        file.play();
        is_playing = true;
        music_playing_since = millis();
      }
      if (millis() - music_playing_since &gt; music_duration) {
        is_playing = false;
        file.stop();
        change_mode(mode + 1);
      }
    } else if (mode == S6_LIGHT_FADE_IN) 
    {
      // todo
      if (millis() - in_mode_since_ms &gt; 1000) {
        change_mode(mode + 1);
      }

    } else if (mode == TERMINATE) 
    {
      change_mode(S1_WAITING_FOR_PEOPLE);
      someone_present = false; // reset
      println("turn_on();");
      turn_on();
    }
  }
}


void change_mode(int m) {
  mode = m;
  in_mode_since_ms = millis();
}



void serialEvent(Serial p) { 
  String s = p.readString();
  if (s != null) {
    s = s.replace("\r\n", "");
    if (s.contains("Distance Measured")) {
      String[] tokens = split(s, "=");
      dist = int(tokens[1]);
    }
  }
} 


void turn_on() {
  myPort.write("on");
}

void turn_off() {
  myPort.write("off");
}

void keyPressed() {
  if (key == 'a') {
    turn_on();
  }
  if (key == 's') {
    turn_off();
  }
}
</code></pre>

<p>Thanks for your help!</p>
]]></description>
   </item>
   <item>
      <title>Playing movie clips after after another at volume 0, there's sound for a split second every clip</title>
      <link>https://forum.processing.org/two/discussion/23102/playing-movie-clips-after-after-another-at-volume-0-there-s-sound-for-a-split-second-every-clip</link>
      <pubDate>Sat, 17 Jun 2017 17:19:39 +0000</pubDate>
      <dc:creator>krnkktz</dc:creator>
      <guid isPermaLink="false">23102@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>i'm struggling to completely mute movie clips. Here's the code (I guess the problem lies in the new_movie() function at the bottom):</p>

<pre><code>import processing.video.*;

Movie movie;
String[] filenames;

void setup() {
  size(640, 480);
  java.io.File folder = new java.io.File(dataPath("C:\\Users\\Marin\\Downloads\\clips"));
  filenames = folder.list();
  frameRate(30);
  new_movie();
}

void draw() {
  if (movie.time() &gt;= movie.duration()) {
    new_movie();
  }

  if (movie.available()) {
    movie.read();
    background(0);
    image(movie, 0, 0);
  }
}

void new_movie() {
  int newmovid = int(random(filenames.length));
  movie = new Movie(this, "C:\\Users\\Marin\\Downloads\\clips\\" + filenames[newmovid]);
  movie.play();
  movie.volume(0);
}
</code></pre>

<p>Setting the volume before movie.play() has no effect (the whole clip plays at full volume) and removing the soundtrack from 1000+ mp4 files doesn't sound very optimal.</p>

<p>What should I do?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Processing not reacting properly to arduino via firmata</title>
      <link>https://forum.processing.org/two/discussion/22376/processing-not-reacting-properly-to-arduino-via-firmata</link>
      <pubDate>Thu, 04 May 2017 00:01:46 +0000</pubDate>
      <dc:creator>ailisg</dc:creator>
      <guid isPermaLink="false">22376@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I'm using an arduino uploaded with firmata. I have a potentiometer hooked up and as the user turns the potentiometer, depending on the value they land on, a certain video will play. So if they turn it up more a different video will play etc.
What's happening is I have to turn the potentiometer to a value, and then turn it all the way back to zero and then the corresponding video from the first value will play. In between it's showing the "image" I'm calling as a part of the video, but usually only one of them, not all of them. I'm new to the video library and processing &amp; arduino in general.
Thanks for your help!</p>

<pre><code>import processing.serial.*;

import cc.arduino.*;
import org.firmata.*;


import processing.video.*;

Arduino arduino;

Movie oneDegree, twoDegrees, threeDegrees;


int sensorPin = 0;    // select the input pin for the potentiometer
int val;



void setup() {
  size(960, 540);
  arduino = new Arduino(this, Arduino.list()[3], 57600); //sets up arduino
   val = arduino.analogRead(sensorPin); 
   println(Arduino.list());
   oneDegree = new Movie(this, "comp1.mp4");
   twoDegrees = new Movie(this, "comp2.mp4");
   threeDegrees = new Movie(this, "comp3.mp4");


}

void draw() {
 val = arduino.analogRead(sensorPin); 
 println(val);
 image(oneDegree, 0, 0);
 image(twoDegrees, 0, 0);
 image(threeDegrees, 0, 0);

  if(val &gt; 10 &amp;&amp; val &lt; 348) { 
    oneDegree = new Movie(this, "comp1.mp4");
    oneDegree.play();
  }

  else if(val &gt; 348 &amp;&amp; val &lt; 686) {
  twoDegrees = new Movie(this, "comp2.mp4");
    twoDegrees.play();
  }

  else if(val &gt; 686 &amp;&amp; val &lt; 1024) {
   threeDegrees = new Movie(this, "comp3.mp4");
  threeDegrees.play();
  }

  if (oneDegree.time() == oneDegree.duration()) { //movie must be finished
twoDegrees.play();
  }
if (twoDegrees.time() == twoDegrees.duration()) { //movie must be finished
threeDegrees.play();
}
}

void movieEvent(Movie m) {
  m.read();
  /* if (m == oneDegree) {
    oneDegree.read();
  } 
  else if (m == twoDegrees) {
    twoDegrees.read();
  }
  else if (m == threeDegrees) {
    threeDegrees.read();
  }*/
}



/* void movieEvent(Movie ) {
  if (val &lt;= 348) {
    oneDegree.read();
  } 
  else if (val &gt; 348 &amp;&amp; val &lt;= 686) {
    twoDegrees.read();
  }

  else if (val &gt; 686 &amp;&amp; val &lt;= 1024) {
    threeDegrees.read();
  }
} */
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to swap and play video files using functions</title>
      <link>https://forum.processing.org/two/discussion/22023/how-to-swap-and-play-video-files-using-functions</link>
      <pubDate>Sun, 16 Apr 2017 00:11:50 +0000</pubDate>
      <dc:creator>sheenakhu</dc:creator>
      <guid isPermaLink="false">22023@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys, I'm having some trouble getting this interactive piece to work. I want to hover over the top left of my sketch and have Scene 1 play. Then a minute later, hover over it and have Scene 2 play and around a minute and a half later, have Scene 3 play. However, the mouseX and mouse Y commands are ignored after Scene 1 plays through and when I input a timer, it is also ignored. In my final code, each scene function will contain 7 videos, so that's why I'm using "myMovie" as my base code and swapping different movie files in. For example, I will have myMovie1, myMovie2, myMovie3, myMovie4 etc, and load Scene 1's 7 files, dispose of them, then move onto scene 2's 7 files and eventually Scene 3's.</p>

<p>If anyone has any advice or can test this out it would be greatly appreciated. Thanks everyone!</p>

<pre><code>import processing.video.*; 

Movie myMovie;

boolean mouseInCorrectLocationToPlayVideo;

boolean hasMovieEnded;

float movieEndDuration = 0.1;

int whichSceneIAmCurrentlyOn = 0; 

void setup(){
size(640, 480);
frameRate(30);

loadScene1();

}    

void draw(){
println(millis());

    //Checking if movie has ended.
    //If movie has not yet ended, check mouseX &amp; Y location. 
    // If mouse is in these boundaries, mouseInCorrectLocationToPlayVideo is true.  
   if (hasMovieEnded == false){
      if ((mouseX &lt; 213) &amp;&amp; (mouseY &lt;= 240)){
        if((mouseX &gt; 0) &amp;&amp; (mouseY &gt;= 0)){

            mouseInCorrectLocationToPlayVideo = true;  
         }
       }
     }

    //If mouse X &amp; Y are not in these boundaries, print out.   
     if(mouseInCorrectLocationToPlayVideo == false){
     println("not in boundaries");
   }

   //If mouse X &amp; Y are in these boundaries, play video.
   if (mouseInCorrectLocationToPlayVideo == true) { 
    myMovie.play();
    image(myMovie, 0, 0);
    //println("1:" + frameCount);

    //When movie ends, dispose of movie file from memory. 
    if  ((myMovie.time() + movieEndDuration) &gt;= myMovie.duration()){

      myMovie.dispose();
      unregisterMethod("dispose", myMovie);
      g.removeCache(myMovie);
      println("current movie finished file dumped");

      //Movie has ended. 
      hasMovieEnded = true; 
      //MouseX and Y are not within stated boundaries anymore. 
      mouseInCorrectLocationToPlayVideo = false; 

      //  if (millis() &gt; 10*1000){ //not working
        if (whichSceneIAmCurrentlyOn == 1){
           reset();  
           loadScene2();
         }
      //   }
        else if (whichSceneIAmCurrentlyOn == 2){
          reset();   
          loadScene3();
        }  

    }          
  }  
} //closes draw

void reset(){
 // mouseInCorrectLocationToPlayVideo = false; //not needed
  hasMovieEnded = false;
}

void loadScene1(){

   myMovie = new Movie(this, "tileScene1.mp4");
   whichSceneIAmCurrentlyOn = whichSceneIAmCurrentlyOn + 1;
}

void loadScene2(){

    myMovie = new Movie(this, "tileScene2.mp4");
    whichSceneIAmCurrentlyOn = whichSceneIAmCurrentlyOn + 1;
}

void loadScene3(){

    myMovie = new Movie(this, "tileScene3.mp4");
    whichSceneIAmCurrentlyOn = whichSceneIAmCurrentlyOn + 1;
}


void movieEvent(Movie m) {
   if (m == myMovie) {
    myMovie.read();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to create a basic transition effect between two videos?</title>
      <link>https://forum.processing.org/two/discussion/21999/how-to-create-a-basic-transition-effect-between-two-videos</link>
      <pubDate>Fri, 14 Apr 2017 19:54:21 +0000</pubDate>
      <dc:creator>Proud2be_a_newbie</dc:creator>
      <guid isPermaLink="false">21999@/two/discussions</guid>
      <description><![CDATA[<p>How can I create a basic fade transition effect between two videos?</p>

<p>Let us say we have video1.mov playing and after that is done, play video2.mov right away.</p>

<p>But when video1 is done playing, the last few seconds, the frames fade out and when video2 starts playing, the first few frames fade in.</p>
]]></description>
   </item>
   <item>
      <title>Frame Accurate Interactive Video Playback - a solution for 1.5.x but not working in 3.x</title>
      <link>https://forum.processing.org/two/discussion/21585/frame-accurate-interactive-video-playback-a-solution-for-1-5-x-but-not-working-in-3-x</link>
      <pubDate>Fri, 24 Mar 2017 16:07:35 +0000</pubDate>
      <dc:creator>chrios1001</dc:creator>
      <guid isPermaLink="false">21585@/two/discussions</guid>
      <description><![CDATA[<p>After much hacking I have made a sketch that does frame accurate interactive video playback.
I based this on tips and code from the older processing forums.
BUT - it only works in processing 1.5.1
I had to use various workarounds, and I don't know why they work.
It is something to do with the conversion from time in seconds to an accurate frame number.
A limitation of the jump() command.</p>

<p>I'm posting this code in the hope that it might help others
and maybe to find a solution that works in Processing 3.x</p>

<p>here's the code with lots of comments and link to a reliable test video:</p>

<pre><code>/*
 An example of frame accurate interactive video playback
 Tested working for frame accurate interactive viewing of videos at 25fps and 30fps - any length.
 This only works in processing 1.5.1
 I cannot get it working in newer versions of Processing
 This is probably due to the switch to the gstreamer library

 Easiest way to check it's working is to use a movie file with the
 correct frame number printed on each frame so you can spot skipping frames
 as you use the keys: -/+ to navigate.

 The suitable video for this sketch (with it's numbered frames) can be d/ld here:
 <a href="http://33dd.com/processing/100_Numbered_frames_30fps.mov" target="_blank" rel="nofollow">http://33dd.com/processing/100_Numbered_frames_30fps.mov</a>
 */

import processing.video.*; 
Movie myMovie; 
float movieFps=30.00;//fps of the movie - please set to match your movie file
float advanceLength = 1/(movieFps-0.01);//get length of one frame in seconds - and subtract 0.01 (why -0.01 I don't know??)
//this movie is 30fps - but sketch is only accurate if we declare fps as 29.99fps - why??

void setup()
{ 
  size(640, 320, P2D);//P2D needed for processing 1.5.--
  //size(640, 320);//use this method in processing 2.++ - no more P2D
  background(0); 

  //load a movie with visible framenumbers - makes it easier to check accuracy
  myMovie = new Movie(this, "100_Numbered_frames_30fps.mov"); //see link at top for video source
  myMovie.loop();//play the movie
  myMovie.speed(0);//best way to stop the movie - pause() halts the thread - so we must use speed(0)
} 

void movieEvent(Movie myMovie)
{ 
  myMovie.read();
} 

void draw()
{ 
  image(myMovie, 0, 0, width, height);
} 

void keyPressed()
{ //use - / +  keys to go back and forward one frame
  if (key == '-')
  {
    if (myMovie.time() &lt; advanceLength)//if movie time &lt; 1 frame jump to start of movie (another hack needed to make it work)
    {
      myMovie.jump((myMovie.time() - advanceLength) % 0);
    } else  
    {//for some reason this only works accurately if we jump backwards then forward one frame
      myMovie.jump((myMovie.time() - advanceLength) % myMovie.duration()); 
      myMovie.jump((myMovie.time() + advanceLength) % myMovie.duration());
    }
  }  
  if (key == '=')
  {
    //jump forward by one frame 
    myMovie.jump((myMovie.time() + advanceLength) % myMovie.duration());
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Video 1.0.1 - Read a frame from a paused video?</title>
      <link>https://forum.processing.org/two/discussion/20383/video-1-0-1-read-a-frame-from-a-paused-video</link>
      <pubDate>Fri, 20 Jan 2017 20:37:56 +0000</pubDate>
      <dc:creator>Krystman</dc:creator>
      <guid isPermaLink="false">20383@/two/discussions</guid>
      <description><![CDATA[<p>I'm using Processing to make a small app. I want to display and edit text overlays on top of a video file - similar to subtitles. For that, I want to be able to jump a paused video to a specific timecode and display the video frame at that time. Unfortunately, this doesn't seem to work.</p>

<p>So if I make something like this:</p>

<p><code>movie.pause();
movie.jump(30);
movie.read();</code></p>

<p>The video will NOT show the frame at second 30, but whatever frame was on the screen before the jump. If I jump around in the video the same frame keeps being displayed until I hit play.</p>

<p>Is there a workaround for this?</p>
]]></description>
   </item>
   <item>
      <title>Help add array</title>
      <link>https://forum.processing.org/two/discussion/17713/help-add-array</link>
      <pubDate>Mon, 01 Aug 2016 04:57:36 +0000</pubDate>
      <dc:creator>triple0</dc:creator>
      <guid isPermaLink="false">17713@/two/discussions</guid>
      <description><![CDATA[<p>Can someone help me incorporate a video array of up to 6 videos into this code provided? Including a void mousePressed function to click through to the next video. The way this code is written is so the video doesn't play naturally from start to finish~ so it can't be a timer function that simply plays all the videos after one another. The end result should be a basic video slideshow loop ONLY when clicked to view the next video.</p>

<pre><code>import processing.video.*;

Movie mov;
int newFrame = 0;

void setup() {
  size(640, 360);
  background(0);
  // Load and set the video to play. Setting the video 
  // in play mode is needed so at least one frame is read
  // and we can get duration, size and other information from
  // the video stream. 
  mov = new Movie(this, "transit.mov");  

  // Pausing the video at the first frame. 
  mov.play();
  mov.jump(0);
  mov.pause();
}

void movieEvent(Movie m) {
  m.read();
}

void draw() {
  background(0);
  image(mov, 0, 0, width, height);
  fill(255);
  text(getFrame() + " / " + (getLength() - 1), 10, 30);
  int f=ceil (map(mouseX,0,width,1,getLength()));
  setFrame(f);
}

//void keyPressed() {
//  if (key == CODED) {
//    if (keyCode == LEFT) {
//      if (0 &lt; newFrame) newFrame--; 
//    } else if (keyCode == RIGHT) {
//      if (newFrame &lt; getLength() - 1) newFrame++;
//    }
//  } 
//  setFrame(newFrame);  
//}

int getFrame() {    
  return ceil(mov.time() * 30) - 1;
}

void setFrame(int n) {
  mov.play();

  // The duration of a single frame:
  float frameDuration = 1.0 / mov.frameRate;

  // We move to the middle of the frame by adding 0.5:
  float where = (n + 0.5) * frameDuration; 

  // Taking into account border effects:
  float diff = mov.duration() - where;
  if (diff &lt; 0) {
    where += diff - 0.25 * frameDuration;
  }

  mov.jump(where);
  mov.pause();  
}  

int getLength() {
  return int(mov.duration() * mov.frameRate);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to play a video using keyPressed etc.?</title>
      <link>https://forum.processing.org/two/discussion/16285/how-to-play-a-video-using-keypressed-etc</link>
      <pubDate>Wed, 27 Apr 2016 13:04:56 +0000</pubDate>
      <dc:creator>kk324</dc:creator>
      <guid isPermaLink="false">16285@/two/discussions</guid>
      <description><![CDATA[<p>Hi.
I am very very new to Processing. I am working on a project that involves Makey Makey, and I need to figure out how to make a video play smoothly using keys or a mouse. I am using keyPressed now for this, but the video comes out all twitchy, probably because you have to hold the key for the whole duration of the movie in order for it to play. Is there a better way to do it? I was thinking that mouseClicked or keyReleased or keyTyped would be better for this purpose, but I am not sure how to do it. Anyway, here is my code:</p>

<pre><code>import processing.video.*;
Movie myMovie1, myMovie2, myMovie3;
boolean playMovie1=true;
boolean playMovie2=false;
boolean playMovie3=false;



void setup()
{
  size (displayWidth, displayHeight);
  background (0);


 myMovie1 = new Movie(this, "1.mp4");

 myMovie2 = new Movie(this, "2.mp4");

 myMovie3 = new Movie(this, "3.mp4");

}

void draw(){
background(0);
if(playMovie1==true){

myMovie1.play();
image(myMovie1,0, 0);
if(myMovie1.time()&gt;=myMovie1.duration()){
myMovie1.stop();
playMovie1=false;

playMovie2=true;
}
}




if(playMovie3==true){

myMovie3.play();
image(myMovie3,0,0);
if(myMovie3.time()&gt;=myMovie3.duration()){
myMovie3.stop();
playMovie3=false;
}
}
}


void movieEvent(Movie m){
m.read();
}

void keyPressed()

{

// PRESS LEFT OR RIGHT AFTER FIRST VIDEO
  if ((keyCode == RIGHT) || (keyCode == LEFT))

{
 if(playMovie2==true){

myMovie2.read();
myMovie2.play();
image(myMovie2,0,0);
if(myMovie2.time()&gt;=myMovie2.duration()){
myMovie2.stop();
playMovie2=false;
playMovie3=true;
}}


 }}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Movie's in code</title>
      <link>https://forum.processing.org/two/discussion/15376/movie-s-in-code</link>
      <pubDate>Wed, 09 Mar 2016 11:26:39 +0000</pubDate>
      <dc:creator>Danieuwburg</dc:creator>
      <guid isPermaLink="false">15376@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>In short: My current project involves a arduino Uno and processing, PIR sensor sends a signal when a person walks past the sensor and a movie starts playing. So far so good, the code works perfecly but the problem i'm having is that we want multible movies playing in shufflemode. So when the PIR sensor is triggerd again processing start a differend movie. This is the code so far:</p>

<pre><code>import processing.video.*; 
import processing.serial.*; //importeer Serial library

Movie myMovie;
boolean MoviePause = true;
String Sensor;
Serial port;
String serial;   // nieuwe string 'serial'
int end = 10;    // 10 is ASCII voor linefeed (einde van serial.println)

void setup() {
  fullScreen();
  background(0);
  noStroke();
  fill(102);
  Sensor="0";
  port = new Serial(this, Serial.list()[0], 9600); // baudrate (snelheid) moet hetzelfde zijn als op de Arduino
  port.clear();  // serieele poort schoonmaken zodat er geen zooi in zit
  serial = port.readStringUntil(end); // lees poort totdat er een linefeed zit
  serial = null;
  background(0);
  myMovie = new Movie(this, "F:\\Droombus.mp4"); //hier natuurlijk je eigen verwijzing naar film zetten
  myMovie.loop();  //film in een lus zetten, want stoppen betekent niet meer kunnen starten (althans, zonder hem helemaal opnieuw aan te maken)
}

void draw() {
  background(255);
  image(myMovie, 0, 0);
    while (port.available() &gt; 0) { //zoalng er data op de poort komt, uitlezen en opslaan
    serial = port.readStringUntil(end);
  }
  if (serial != null) {  //data gevonden
      String[] a = split(serial, ',');  //data komt binnen, gescheiden door komma's
      Sensor = (a[0]);
      Sensor = trim(Sensor);
      println(Sensor);
  }

  if (myMovie.time() == myMovie.duration()){  //einde van de film bereikt.
    println("einde filmpje");
    myMovie.pause();    //dan op pauze zetten. Niet stoppen dus!!
    MoviePause=true;    //aangeven dat de film op pauze staat
  }
  if ((Sensor.equals("1") == true) &amp; MoviePause==true){  //als de sensor weer 1 is (dus beweging) EN de film is afgelopen
    println("Sensor check");
    MoviePause=false;
    myMovie.play();                                      //dan opnieuw verder afspelen (want staat in een lus)
  }
}

void movieEvent(Movie m) {
  m.read();
}
</code></pre>

<p>Please can someone help us to fix the code we're kinda stuck on this problem</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Shuffle mode video's</title>
      <link>https://forum.processing.org/two/discussion/15357/shuffle-mode-video-s</link>
      <pubDate>Tue, 08 Mar 2016 11:06:23 +0000</pubDate>
      <dc:creator>Danieuwburg</dc:creator>
      <guid isPermaLink="false">15357@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>In short: My current project involves a arduino Uno and processing, PIR sensor sends a signal when a person walks past the sensor and a movie starts playing. So far so good, the code works perfecly but the problem i'm having is that we want multible movies playing in shufflemode. So when the PIR sensor is triggerd again processing start a differend movie. This is the code so far:
    import processing.video.*;
    import processing.serial.*; //importeer Serial library</p>

<pre><code>Movie myMovie;
boolean MoviePause = true;
String Sensor;
Serial port;
String serial;   // nieuwe string 'serial'
int end = 10;    // 10 is ASCII voor linefeed (einde van serial.println)

void setup() {
  fullScreen();
  background(0);
  noStroke();
  fill(102);
  Sensor="0";
  port = new Serial(this, Serial.list()[0], 9600); // baudrate (snelheid) moet hetzelfde zijn als op de Arduino
  port.clear();  // serieele poort schoonmaken zodat er geen zooi in zit
  serial = port.readStringUntil(end); // lees poort totdat er een linefeed zit
  serial = null;
  background(0);
  myMovie = new Movie(this, "F:\\Droombus.mp4"); //hier natuurlijk je eigen verwijzing naar film zetten
  myMovie.loop();  //film in een lus zetten, want stoppen betekent niet meer kunnen starten (althans, zonder hem helemaal opnieuw aan te maken)
}

void draw() {
  background(255);
  image(myMovie, 0, 0);
    while (port.available() &gt; 0) { //zoalng er data op de poort komt, uitlezen en opslaan
    serial = port.readStringUntil(end);
  }
  if (serial != null) {  //data gevonden
      String[] a = split(serial, ',');  //data komt binnen, gescheiden door komma's
      Sensor = (a[0]);
      Sensor = trim(Sensor);
      println(Sensor);
  }

  if (myMovie.time() == myMovie.duration()){  //einde van de film bereikt.
    println("einde filmpje");
    myMovie.pause();    //dan op pauze zetten. Niet stoppen dus!!
    MoviePause=true;    //aangeven dat de film op pauze staat
  }
  if ((Sensor.equals("1") == true) &amp; MoviePause==true){  //als de sensor weer 1 is (dus beweging) EN de film is afgelopen
    println("Sensor check");
    MoviePause=false;
    myMovie.play();                                      //dan opnieuw verder afspelen (want staat in een lus)
  }
}

void movieEvent(Movie m) {
  m.read();
}
</code></pre>

<p>Please can someone help us to fix the code we're kinda stuck on this problem</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>DOM Video: randomly playing only between buffered frames of a video.</title>
      <link>https://forum.processing.org/two/discussion/15112/dom-video-randomly-playing-only-between-buffered-frames-of-a-video</link>
      <pubDate>Thu, 25 Feb 2016 10:10:23 +0000</pubDate>
      <dc:creator>setupdraw</dc:creator>
      <guid isPermaLink="false">15112@/two/discussions</guid>
      <description><![CDATA[<p>I am having fun exploring the DOM library. Trying to build something with video:
I would like to build a video player where the video playhead jumps around based on certain parameters/user interactions.
But only within the frames that are already (pre)loaded, otherwise I will have blank frames and pauses depending on the user's connection speed.
Now, in terms of references/examples there's not much @ P5jS.org yet. But I have found this nice reference page: <a href="http://www.w3schools.com/tags/ref_av_dom.asp" target="_blank" rel="nofollow">http://www.w3schools.com/tags/ref_av_dom.asp</a> for HTML Audio/Video Properties. But how to use them properly in P5.js is quite obscure to me… for example:</p>

<p>Assumed what I've found here <a href="http://www.w3schools.com/tags/av_prop_duration.asp" target="_blank" rel="nofollow">http://www.w3schools.com/tags/av_prop_duration.asp</a> 
I was expecting the following code to work...</p>

<p>var randomF = floor(random(0, myVideo.duration));</p>

<p>But it doesn't.</p>

<p>While the code below gives me the result I was looking for:</p>

<p>var randomF = floor(random(0, myVideo.duration()));</p>

<p>I don't know why round brackets are needed here, I just discovered by chance this was what was the way to go…
so I also tried the following:</p>

<p>var randomF = floor(random(0, myVideo.buffered.end()));</p>

<p>Assuming this would have worked out as well, but it didn't :((</p>

<p>I started being quite confused about what/how can I successfully use in terms of HTML DOM lingo in P5js.
What are the properties HTML Audio/Video DOM I can use in P5js and how is quite a mystery to me...
Does anybody out there experimenting with p5js Dom library has some advice/suggestion for me?
Is there a general golden Javascript rule I am missing?</p>

<p>Thank a lot for your help!</p>
]]></description>
   </item>
   <item>
      <title>Delay when playing multiple videos at the same time!</title>
      <link>https://forum.processing.org/two/discussion/14159/delay-when-playing-multiple-videos-at-the-same-time</link>
      <pubDate>Sun, 27 Dec 2015 12:26:25 +0000</pubDate>
      <dc:creator>Tiago</dc:creator>
      <guid isPermaLink="false">14159@/two/discussions</guid>
      <description><![CDATA[<p>Hello! In my project I have to play a string of videos randomly and at the same time, the problem is that very time a new video is added the others, which are already playing, freeze for a second! I´ve read that preloading them could fix this problem but i don´t now how to go about it and if it realy works?</p>

<p>I will live the code i´m working on here hope you can help me out!</p>

<pre lang="javascript">
// libs:

import processing.video.\*;

// declarations

int $winW = 1920; // window

int $winH = 1080;

int $margin = 20;

int $celsW = 20; // numero de  celulas horizontal

int $celsH = 15; // numero de  celulas vertical

int $celW, $celH;

int $fps = 25;

int $beat = 10; // tempo entre cada video!

//lista de videos

String[] $videoFiles = {

  "1.mov",

  "2.mov"

};

int $frame = 0;

int $vidMax;

Movie[] $videos;

/\*

 \* Main proggy

 \*/

//

// SETUP:

//

void setup() {

  size(1920, 1080);

  background(0);

  frameRate($fps);

  // defenir o tamanho de cada celula

  $celW =  $winW/$celsW;

  $celH =  $celW;

  /\* Init matrix \*/

  $videos = new Movie[$celsW\*$celsH];

  $vidMax = $videoFiles.length;

}

//

// DRAW:

//

void draw() {

  background(0);

  // show something new?

  if ($frame % $beat == 0) {

    int vid = floor(random(0, $vidMax));

    int pos = floor(random(0, $videos.length));

    while ($videos[pos] != null) {

      pos = floor(random(0, $videos.length));

    }

    $videos[pos] = new Movie(this, $videoFiles[vid]);

    $videos[pos].jump(0);

    $videos[pos].noLoop();

    $videos[pos].play();

    println("loading video " + vid + " at position " + pos);

  }

  // read videos:

  for (int i = 0; i &lt; $videos.length; i++) {

    if ($videos[i] != null) {

      if ($videos[i].time() &lt; $videos[i].duration() - 0.1) {

        $videos[i].read();

        int x = (i % $celsW) \* $celW;

        int y = (i / $celsW) \* ($celH+$celsH/3);

//         int y = (i / ($celsH+$celsH/2)) \* ($celH+$celsH/2);

        image($videos[i], x, y, $celW, $celH);

      } else {

        $videos[i] = null;

      }

    }

  }



  $frame++;
}
</pre>
]]></description>
   </item>
   <item>
      <title>File Length .mp3 or .wav with Minim and Processing</title>
      <link>https://forum.processing.org/two/discussion/13656/file-length-mp3-or-wav-with-minim-and-processing</link>
      <pubDate>Wed, 25 Nov 2015 19:15:19 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">13656@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>Is Possible to know Which time to complete a sound (music) an .mp3 or .wav of a file in Processing, using the Minim library?</p>

<p>For example, I need at the end of a particular sound, perform a certain action, so I need to know when to finished.</p>

<p>This is the code I used as an example, although I'm using is in another project.</p>

<pre><code>import ddf.minim.*;
Minim minim;

AudioPlayer player[] = new AudioPlayer[3];
String filenames[]   = new String[] {"groove.mp3", "jingle.mp3", "Kalimba.mp3"};

void setup(){
  minim = new Minim(this);
  for(int i = 0; i &lt; 3; i++){
    player[i] = minim.loadFile(filenames[i], 2048);
  }
}

void draw(){
  //
}

void keyPressed(){
  int som;

  if (key == 'A' || key == 'a') som = 0;
  else if (key == 'B' || key == 'b') som = 1;
  else som = 2;

  playSom(som);
}

void playSom(int opcSom){
  for (int i = 0; i &lt; 3; i++){
    if (player[i].isPlaying()) 
      player[i].pause();
  }

  player[opcSom].rewind();   
  player[opcSom].play();
  println("Duration: "); //???
}  

void stop(){
  for(int i = 0; i &lt; 3; i++){
    player[i].close();
  }

  minim.stop();
  super.stop();
}
</code></pre>

<p>Thanks for attention.</p>
]]></description>
   </item>
   <item>
      <title>Minim For loop play();</title>
      <link>https://forum.processing.org/two/discussion/13637/minim-for-loop-play</link>
      <pubDate>Wed, 25 Nov 2015 00:03:20 +0000</pubDate>
      <dc:creator>iankookane</dc:creator>
      <guid isPermaLink="false">13637@/two/discussions</guid>
      <description><![CDATA[<p>Hello Everyone,</p>

<p>I have a simple for loop that plays different sounds using minim. However it does not finish an iteration thru the loop until it is done playing the mp3 file.  Is there anyway to do the next iteration while the before mp3 file is still playing? Like go to the next iteration right after the play() function starts?</p>
]]></description>
   </item>
   <item>
      <title>scrolling in a movie through mouseX</title>
      <link>https://forum.processing.org/two/discussion/13599/scrolling-in-a-movie-through-mousex</link>
      <pubDate>Sun, 22 Nov 2015 13:59:12 +0000</pubDate>
      <dc:creator>Tilia</dc:creator>
      <guid isPermaLink="false">13599@/two/discussions</guid>
      <description><![CDATA[<p>Hi people,</p>

<p>im very new to this and im quite sure it should be very easy to do this but i don't know how.
i want to load a video in processing an control the displaying of the frames of the video through the mouseX position.</p>

<p>that is my code:</p>

<pre><code>import processing.video.*;
Movie myMovie;

void setup() {
  frameRate(30);
  size(1244, 700);
  myMovie = new Movie(this, "Komp 1.mov");
  myMovie.play();    
}

void movieEvent(Movie myMovie) {
  myMovie.read();
}

void draw() {
  image(myMovie, 0,0);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>What's the best way of telling when a sound file has finished playing?</title>
      <link>https://forum.processing.org/two/discussion/13494/what-s-the-best-way-of-telling-when-a-sound-file-has-finished-playing</link>
      <pubDate>Thu, 12 Nov 2015 08:54:05 +0000</pubDate>
      <dc:creator>dhmstark</dc:creator>
      <guid isPermaLink="false">13494@/two/discussions</guid>
      <description><![CDATA[<p>I'm putting together an application which plays a series of sound files in sequence; I want to be able to tell when a file has finished.</p>

<p>The obvious ways of doing this (checking for the currentTime() &gt;= duration() and checking for !.isPlaying() &amp;&amp; !.isPaused()) don't work - when a sound file finishes playing, currentTime() returns 0, and the second statement is also true when there's nothing playing at all.</p>

<p>I can probably sort this by tracking the currentTime and watching for a jump down from a non-zero value, but this seems like a hacky way of doing things. Have I missed something obvious or is there a feature that isn't documented that would solve my problem?</p>

<p>Relatedly, it seems like it would be useful for the soundFile to raise some sort of event when it finishes playing, or alternatively for its currentTime to remain equal to its duration rather than resetting to zero.</p>
]]></description>
   </item>
   <item>
      <title>how to make a video: play + jump + play + jump …</title>
      <link>https://forum.processing.org/two/discussion/13095/how-to-make-a-video-play-jump-play-jump</link>
      <pubDate>Sun, 18 Oct 2015 17:46:20 +0000</pubDate>
      <dc:creator>ms68</dc:creator>
      <guid isPermaLink="false">13095@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am also new to processing and would be very thankful if someone could help me with the following issue.</p>

<p>With the help of the video library I am trying to play a video that randomly jumps forwards, plays a limited and random amount of time and jumps randomly forward and plays again randomly until it reaches its end and repeats/loops.</p>

<p>Jumping is random inbetween the parameters of 15 and 30 seconds. Playing between 5 and 13 seconds.
I only got him jumping but not playing inbetween the jumps … althought the code I can give is without jumping so far:</p>

<pre><code>int clip_duration_max = 13;
int clip_duration_min = 5;
int clip_jump_max = 30;
int clip_jump_min = 15;

import processing.video.*;
Movie sequence;

void setup() {
  //size(displayWidth, displayHeight);
  size(640, 480);
  frameRate(25);
  sequence = new Movie(this, "sequence.mp4");
  sequence.loop();
}

void draw() {
  image(sequence, 0, 0);
  sequence.read(); 
  int sequence_duration = int(sequence.duration()); // get sequence duration
  int sequence_time = int(sequence.time());
  int jumper = int(random(clip_jump_min, clip_jump_max));  
  int sequence_length = int(random(clip_duration_min, clip_duration_max));
  int next_jumping_point = sequence_time + jumper + sequence_length;
}
</code></pre>

<p>Can anybody help me guiding to the next steps?</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Audio time</title>
      <link>https://forum.processing.org/two/discussion/12751/audio-time</link>
      <pubDate>Wed, 30 Sep 2015 15:11:28 +0000</pubDate>
      <dc:creator>lviensen</dc:creator>
      <guid isPermaLink="false">12751@/two/discussions</guid>
      <description><![CDATA[<p>Como saber o tempo de duração de um áudio usando a biblioteca minim?</p>

<p>How to know the rhythm of hum Length Audio using a libraryminim?</p>
]]></description>
   </item>
   <item>
      <title>time</title>
      <link>https://forum.processing.org/two/discussion/12684/time</link>
      <pubDate>Fri, 25 Sep 2015 12:59:12 +0000</pubDate>
      <dc:creator>lviensen</dc:creator>
      <guid isPermaLink="false">12684@/two/discussions</guid>
      <description><![CDATA[<p>Como faço para executar uma função de AudioInput  por um tempo determinado?</p>

<p>How do I run paragraph A Function AudioInput For A Determined pace ?</p>
]]></description>
   </item>
   <item>
      <title>Vídeo</title>
      <link>https://forum.processing.org/two/discussion/12525/video</link>
      <pubDate>Tue, 15 Sep 2015 14:51:03 +0000</pubDate>
      <dc:creator>lviensen</dc:creator>
      <guid isPermaLink="false">12525@/two/discussions</guid>
      <description><![CDATA[<p>Como saber que o vídeo está em execução ou não?</p>
]]></description>
   </item>
   <item>
      <title>processing.video.*: # of frames</title>
      <link>https://forum.processing.org/two/discussion/12417/processing-video-of-frames</link>
      <pubDate>Sun, 06 Sep 2015 12:29:59 +0000</pubDate>
      <dc:creator>Leprous</dc:creator>
      <guid isPermaLink="false">12417@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>Is there any easy solution to get total number of frames in a movie before playback?</p>

<p>For this library: <a href="https://github.com/processing/processing-video/" target="_blank" rel="nofollow">https://github.com/processing/processing-video/</a></p>

<p>Cheers!</p>
]]></description>
   </item>
   <item>
      <title>Heap Space Issue</title>
      <link>https://forum.processing.org/two/discussion/3893/heap-space-issue</link>
      <pubDate>Sun, 23 Mar 2014 17:58:20 +0000</pubDate>
      <dc:creator>winuuu</dc:creator>
      <guid isPermaLink="false">3893@/two/discussions</guid>
      <description><![CDATA[<p>I wrote a sketch to pair random strings from a text file with different clips. The program will run for a while but eventually crash due to there not being enough heap space. I don't understand how this is happening if I am resetting 'myMovie' and
'p' at the end of draw(). Any help would be greatly appreciated!</p>

<pre><code>import processing.video.*;

PFont font;

String[] posts; // strings loaded in setup()
String[] videos = {"1a.mov", "2a.mov", "3a.mov", "4a.mov", "5a.mov", "6a.mov",
                    "7a.mov", "8a.mov", "9a.mov"}; // video clips

String post;
Post first; // First post
Post p; // Next iteration of posts

Movie myMovie;
String clip;
int count; // Iteration counter

int a = 0; // image()
float duration = 0; // Movie duration
float time = 0; // Movie time

void setup(){

  size(displayWidth, displayHeight);
  background(0);

  posts = loadStrings("posts.txt"); // load strings from file
  font = loadFont("HelveticaNeue-Bold-48.vlw"); // load font
  post = posts[int(random(posts.length))]; // use random post

  textFont(font); // Set text font 
  textSize(50);
  textAlign(CENTER);
  fill(255, 248, 43); // Yellow fill

  if (frame != null){
    frame.setResizable(true); // resizable window
  }  

  /** Random generation of initial clip and post */
  clip = videos[int(random(videos.length))];
  myMovie = new Movie(this, clip);
  makeTint();
  myMovie.play();
  count++;
  first = new Post(post);
  println("Playing clip: " + clip + " w/ post: " + "\"" + post + "\"");
  println("Iteration: " + count + "\n");
}

/** Will generate random clips and posts after initial clip **/
void draw(){

  if (a == 0){
    image(myMovie, 0, 0);
  }

  image(myMovie, 0, 0);

  duration = myMovie.duration();
  time = myMovie.time();

  /** If clip is at end **/
  if ((duration - time) &lt; 0.1){

    first = null; // Remove first post

    /** Reset clip **/
    clip = null;
    myMovie = null;
    clip = videos[int(random(videos.length))];
    myMovie = new Movie(this, clip);
    count++;

    makeTint();
    myMovie.play();

    /** Reset post **/
    p = null;
    post = posts[int(random(posts.length))];

    println("Playing clip: " + clip + " w/ post: " + "\"" + post + "\"");
    println("Post length: " + post.length());
    println("Iteration: " + count + "\n");

  }
    p = new Post(post);
}

/** Method needed to play clips **/
void movieEvent(Movie m){  
  m.read();  
}

/** Screenshot taken and saved if user mouse-clicks **/
void mousePressed(){  
  int random_number = int(random(1000000));
  save(random_number+".png");  
}

/*******************************************\ 
* Function: Create Tint of random color
*
* Parameter Description:
*-----------------------------------------
* none  
\*******************************************/
void makeTint(){
  tint(int(random(200, 255)), int(random(200, 255)), 
        int(random(200, 255)), 126);
}


/** Class for displaying post **/
class Post{

  /*******************************************\ 
   * Function: Post Object Constructor
   *
   * Parameter Description:
   *-----------------------------------------
   * t, text to display
  \*******************************************/
  Post(String t){
    text(t, width/2, height - 150);    
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Overlaying text from a String array onto changing Video Clips</title>
      <link>https://forum.processing.org/two/discussion/1874/overlaying-text-from-a-string-array-onto-changing-video-clips</link>
      <pubDate>Thu, 05 Dec 2013 17:11:47 +0000</pubDate>
      <dc:creator>lchit</dc:creator>
      <guid isPermaLink="false">1874@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to display text from a String array onto video clips, where it displays as one string per clip; so when the clip changes, the text changes.</p>

<p>What I have so far isn't working, can someone help me with the logic? This is what I have so far:</p>

<pre><code>PFont font;

String[] posts;
String[] videos = {"1.mov", "2.mov", "3.mov", "4.mov", "5.mov", "6.mov",
                    "7.mov", "8.mov", "9.mov"};

Movie myMovie;

int a = 0;
int count = 0;
float duration = 0;
float time = 0;

void setup(){

  size(displayWidth, displayHeight);
  //background(0);

  posts = loadStrings("posts.txt");
  font = loadFont("HelveticaNeue-Bold-48.vlw");


  if (frame != null){
    frame.setResizable(true);
  }

  myMovie = new Movie(this, videos[int(random(videos.length))]);
  myMovie.play();

  text(posts[int(random(posts.length))], 250, displayHeight - 300);
}

void draw(){

  if (a == 0){
    image(myMovie, 0, 0);
  }

  image(myMovie, 0, 0);

  float duration = myMovie.duration();
  float time = myMovie.time();

  if ((duration - time) &lt; 0.1){

    myMovie = null;
    myMovie = new Movie(this, videos[int(random(videos.length))]);
    count++;
    myMovie.play();
    text(posts[int(random(posts.length))], 250, displayHeight - 300);
  }
}

void movieEvent(Movie m){  
  m.read();
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>