<?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 speed() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=speed%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:51:52 +0000</pubDate>
         <description>Tagged with speed() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedspeed%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <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>Video error on reverse on video library</title>
      <link>https://forum.processing.org/two/discussion/14733/video-error-on-reverse-on-video-library</link>
      <pubDate>Tue, 02 Feb 2016 23:01:07 +0000</pubDate>
      <dc:creator>Per</dc:creator>
      <guid isPermaLink="false">14733@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>Im made this sketch but as soon as I hit reverse on the videolibrary with help of negative movie.speed it causes a error. Any solution?:</p>

<blockquote class="Quote">
  <p>(Processing core video:475): GStreamer-WARNING **: wrong STREAM_LOCK count 0</p>
  
  <p>(Processing core video:475): GStreamer-CRITICAL **: gst_segment_set_seek: assertion `start &lt;= stop' failed</p>
</blockquote>

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

Movie movie; // Step 1. Declare Movie object

void setup() {
  size(560, 480);
  // Step 2. Initialize Movie object
  movie = new Movie(this, "test1.mov");
  movie.loop();
  movie.jump(5);
  movie.pause();
}
// Step 4. Read new frames from movie
void movieEvent(Movie movie) {
  movie.read();
}
void draw() {
  image(movie, 650, 0);
}

void keyReleased() {
  if (key == 'a') movie.play(); // play
  if (key == 's') movie.pause(); // pause
  if (key == 'd') movie.stop(); // stop
  if (key == 'f') movie.jump(5); // jump
  movie.speed(1.0);
}

void keyPressed() {
  if (key == 'g') movie.speed(5.0); // forward
  if (key == 'h') movie.speed(-5.0); // reverse
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>when i play nine mp4s using video library,the nineth mp4 can't play as other eight mp4.</title>
      <link>https://forum.processing.org/two/discussion/24050/when-i-play-nine-mp4s-using-video-library-the-nineth-mp4-can-t-play-as-other-eight-mp4</link>
      <pubDate>Thu, 07 Sep 2017 05:23:47 +0000</pubDate>
      <dc:creator>Ryan</dc:creator>
      <guid isPermaLink="false">24050@/two/discussions</guid>
      <description><![CDATA[<pre><code>import processing.video.*;  
import processing.serial.*; 
Serial myPort;
int[] valr={1021,1021,1021,1021,1021,1021,1021,1021,1021};
Movie[] endmovie = new Movie[9];
void setup(){  
  fullScreen();
  for(int i = 0;i&lt;9;i++){
endmovie[i] = new Movie(this,"b"+i+".mp4");
  }
  myPort = new Serial(this,Serial.list()[0], 9600);
  myPort.bufferUntil('\n');  //buffer until meet '\n', then call the event listener

}  

void draw(){
  image(endmovie[0],0,0,width/3,height/3);
  image(endmovie[1],width/3,0,width/3,height/3);
  image(endmovie[2],width*2/3,0,width/3,height/3);
  image(endmovie[3],0,height/3,width/3,height/3);
  image(endmovie[4],width/3,height/3,width/3,height/3);
  image(endmovie[5],width*2/3,height/3,width/3,height/3);
  image(endmovie[6],0,height*2/3,width/3,height/3);
  image(endmovie[7],width/3,height*2/3,width/3,height/3);
  image(endmovie[8],width*2/3,height*2/3,width/3,height/3);
for(int i = 0;i&lt;9;i++){
  endmovie[i].play();
   if(valr[i]&gt;500){
endmovie[i].speed(1.0);
   }else{
endmovie[i].speed(-1.0);
   }
 }
}

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

void serialEvent(Serial p) {  
  String inString = p.readString();  
  print(inString);
  if(inString!=null){
   String[] rec= split(inString, ',');
   for(int i=0;i&lt;9;i++){
 valr[i]=int(rec[i]);
   }  
  }  
}  
</code></pre>
]]></description>
   </item>
   <item>
      <title>Trying to improve video performance</title>
      <link>https://forum.processing.org/two/discussion/22250/trying-to-improve-video-performance</link>
      <pubDate>Thu, 27 Apr 2017 17:17:22 +0000</pubDate>
      <dc:creator>laurabrooks</dc:creator>
      <guid isPermaLink="false">22250@/two/discussions</guid>
      <description><![CDATA[<p>I am creating an interactive 360 video sketch (with the help of <a rel="nofollow" href="https://github.com/muimota/p5video360">this shader</a> ) where a user will be able to speed and slow the clip (to make it look like they are moving through the scene) and look side to side by moving the mouse in the y and x directions, respectively. My goal is to display this sketch across three monitors so I would like to use high resolution video, however the sketch's performance worsens as the video quality increases and playback is often shaky. The shader seems to have very high performance but pausing and playing at different speeds sometimes makes the video jump or shake. I'm looking for solutions to make the video more smooth and be able to display it on a large area. I have allotted 1 gigabyte of memory to Processing through Preferences and I don't know if allotting more would solve my problem? Perhaps I just need a more powerful computer ( currently on 64-bit Windows, 4GB RAM)? I have looked into pre-loaded the whole video but haven't found anything promising.</p>

<p>Below is my code, any help is appreciated!</p>

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

float joystick_yaw, joystick_speed;
Movie movie;
PShader shader;
float yaw, pitch, fov;
boolean isPaused = false;

void setup() {
  size(1280, 720, P2D);
  // pitch and yaw set to start video in desired view
  yaw   = 225;
  pitch = 5;
  fov   = 80;
  shader = loadShader("data/video360.glsl");
  shader.set("resolution", float(width/2), float(height/2));
  shader.set("yaw", yaw);
  shader.set("pitch", pitch);
  shader.set("fov", fov);
  movie = new Movie(this, "stitch_high.mp4");
  movie.play();
  movie.volume(0);
  while (movie.height == 0) {
    println("waiting " + second()); 
    delay(10);
  }

  imageMode(CORNERS);
}

void draw() {
  // display video  
  shader(shader);
  image(movie, 0, 0, width, height);

  // display yaw
  joystick_yaw = map(mouseX, 0, 1200, yaw-(fov/3), yaw+(fov/3)); 
  shader.set("yaw", joystick_yaw);

  //choose speed of video
  joystick_speed = map(mouseY, 0, height, 2, -2); 

  if (joystick_speed &gt; 0.2 &amp;&amp; isPaused ) {
    movie.speed(joystick_speed);
    movie.play();
    movie.speed(joystick_speed);
    isPaused = false;
  } else if (joystick_speed &lt; -0.2 &amp;&amp; isPaused) {
    movie.speed(joystick_speed);
    movie.play();
    movie.speed(joystick_speed);
    isPaused = false;
  } else if (joystick_speed &gt;= -0.2 &amp;&amp; joystick_speed &lt;= 0.2) {
    if (!isPaused) {
      movie.pause();
      isPaused = true;
    }
  }
}

// Called every time a new frame is available to read
void movieEvent(Movie m) {
  m.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I use a G4P slider to adjust video speed?</title>
      <link>https://forum.processing.org/two/discussion/22087/how-do-i-use-a-g4p-slider-to-adjust-video-speed</link>
      <pubDate>Wed, 19 Apr 2017 18:02:10 +0000</pubDate>
      <dc:creator>Boyle360</dc:creator>
      <guid isPermaLink="false">22087@/two/discussions</guid>
      <description><![CDATA[<p>As above. For part of a college assignment I have a G4P slider with 3 ticks that set the video speed to 0.5x, 1x and 2x respectively. I'm having trouble figuring out how to actually get the slider to control that.</p>

<p>Somewhat related, the video is very laggy when it plays back. I have it set to a very low bitrate at 240p H264. I just want it to play through smoothly. Thanks in advance.</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 speed control and going backwards</title>
      <link>https://forum.processing.org/two/discussion/19095/video-speed-control-and-going-backwards</link>
      <pubDate>Thu, 17 Nov 2016 16:18:54 +0000</pubDate>
      <dc:creator>smarques</dc:creator>
      <guid isPermaLink="false">19095@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I can not get the Movie.speed() function to control speed or to reverse the direction.
I am running the example from the docs</p>

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

void setup() {
  size(200, 200);
  frameRate(30);
  myMovie = new Movie(this, "totoro.mov");
  myMovie.speed(4.0);
  myMovie.loop();
}

void draw() {
  if (myMovie.available()) {
    myMovie.read();
  }
  image(myMovie, 0, 0);
}
</code></pre>

<p>but the player seems to ignore the call to Movie.speed()
does it have to do with the video format, is there a video format that would work?</p>

<p>Thanks for any help
sergio</p>
]]></description>
   </item>
   <item>
      <title>No image using video library in netbeans</title>
      <link>https://forum.processing.org/two/discussion/18357/no-image-using-video-library-in-netbeans</link>
      <pubDate>Fri, 30 Sep 2016 23:50:35 +0000</pubDate>
      <dc:creator>gordano</dc:creator>
      <guid isPermaLink="false">18357@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to use the processing video library in netbeans. I have added the processing core and video jars as libries in netbeans and can get a sketch running with no errors, but I can only hear the video and don't see anything.</p>

<p>When I print "myMovie.width" I get 0...</p>

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

<pre><code>package processingvideotest;

import processing.core.PApplet;
import processing.video.*;


public class ProcessingVideoTest extends PApplet{

    Movie myMovie;


    public void setup() {
    myMovie = new Movie(this,  "C:/Users/ollie/Documents/NetBeansProjects/ProcessingVideoTest/src/data/Evangelion.mp4");
    myMovie.play();
    myMovie.speed(1);
    myMovie.loop();

    }

    public void settings() {
      size(400, 400);

    }

    public void draw() {
    image(myMovie, 0, 0);
    }

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

    public static void main(String[] args) {
        PApplet.main(new String[] { "processingvideotest.ProcessingVideoTest" });
    }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>analyze sound levels with sound library &amp; random video (warning: 140)</title>
      <link>https://forum.processing.org/two/discussion/14607/analyze-sound-levels-with-sound-library-random-video-warning-140</link>
      <pubDate>Sun, 24 Jan 2016 21:55:58 +0000</pubDate>
      <dc:creator>sRavit</dc:creator>
      <guid isPermaLink="false">14607@/two/discussions</guid>
      <description><![CDATA[<p>hi, i'm new with processing code.
i'm trying to change video footage, with visual effects based on audio in. 
the code works, but after a while (1-3 random video changes) it stuck and the video or the effects stop working, everything freez (including println lines..)</p>

<p>most of time, if the sound level getting higher, that happens.
i get the same warning message everytime:</p>

<p>2016-01-24 23:38:55.263 java[49121:34205664] 23:38:55.263 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.</p>

<p>this is the code so far:</p>

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

AudioIn input;
Amplitude rms;
int scale;
Movie myMovie;

String[] one = {"a.mp4","b.mp4","c.mp4"};

int a = 0;        
float md = 0;
float mt = 0;

void setup()
{
  size(1440 ,900);
  frameRate(25);
  background(0);
  myMovie = new Movie(this, one[int(random(one.length))]);
  myMovie.play();
  input = new AudioIn(this, 0); //Create an Audio input and grab the 1st channel
  input.start(); // start the Audio Input
  rms = new Amplitude(this); // create a new Amplitude analyzer
  rms.input(input); // Patch the input to an volume analyzer
}

void draw()
{
  scale=int(map(rms.analyze(), 0, 0.5, 1, 350));

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

  float md = myMovie.duration();
  float mt = myMovie.time();
  println(md - mt);
  if (Math.abs(md - mt)&lt;0.1){// to find the end of the movie
     myMovie = null;
     myMovie = new Movie(this, one[int(random(one.length))]);
     myMovie.play();
  }
// rms.analyze() return a value between 0 and 1. To adjust the scaling and mapping of an ellipse we scale from 0 to 0.5
    if ((rms.analyze()&gt;0)&amp;&amp;(rms.analyze()&lt;3)) 
    tint (scale*20,scale*4,scale*4);
    myMovie.speed(scale*0.2);

}

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

<p>what am i doing wrong?
any help will be great! 
thanks,
Ravit :)</p>
]]></description>
   </item>
   <item>
      <title>Video library: speed() in conjunction with mouseX is delivering jittery playback, and I can't use -1</title>
      <link>https://forum.processing.org/two/discussion/13557/video-library-speed-in-conjunction-with-mousex-is-delivering-jittery-playback-and-i-can-t-use-1</link>
      <pubDate>Wed, 18 Nov 2015 22:04:29 +0000</pubDate>
      <dc:creator>MobiusCurve</dc:creator>
      <guid isPermaLink="false">13557@/two/discussions</guid>
      <description><![CDATA[<p>I have two questions with the below code:</p>

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

void setup() {
  size(600, 400);
  frameRate(30);
  myMovie = new Movie(this, "1.mp4");
  myMovie.loop();
}

void draw() {
  if (myMovie.available()) {
    myMovie.read();
    float  x1 = map(mouseX, 0, width, 0, 3);
    myMovie.speed(x1);
  }
  image(myMovie, 0, 0);
} 
</code></pre>

<p>1) How can I make the video play backwards? If I write the following code, I get this error message: (Processing core video:14294): GStreamer-CRITICAL **: get_segment_set_seek: assertion 'start &lt;= stop' failed</p>

<pre><code>    float  x1 = map(mouseX, 0, width, -1, 3)
</code></pre>

<p>2) Is there a way to make the playback a little more smooth? There is a lengthy delay between when the mouse is moved and when the video changes playback speeds.</p>
]]></description>
   </item>
   <item>
      <title>Error going from Processing 2 to Processing 3</title>
      <link>https://forum.processing.org/two/discussion/12994/error-going-from-processing-2-to-processing-3</link>
      <pubDate>Tue, 13 Oct 2015 23:09:55 +0000</pubDate>
      <dc:creator>MobiusCurve</dc:creator>
      <guid isPermaLink="false">12994@/two/discussions</guid>
      <description><![CDATA[<p>I'm not sure if this is the right forum for this quesiton. I couldn't find a category dealing with P2 to P3 issues.</p>

<p>I have code that works in Processing 2 but does not work in Processing 3. Here is the code, and below is a photo of the error that I get:</p>

<pre><code>/**
 * Playback Speed 
 * 
 * Move the cursor across the screen to  
 * change the speed of the video playback. 
 * moving the cursor  farther to the left plays the movie
 * faster forward, moving it farther to the right plays it back 
 * faster backwards. Placing the cursor in the middle of the screen
 * pauses the movie.
 */

import jmcvideo.*;
import processing.opengl.*;
JMCMovie myMovie;



void setup() 
{
  size(320, 240, P2D);
  background(0);

  // Load and play the video in a loop
  myMovie = movieFromDataPath("lincoln_01.mov"); 

  //myMovie.play();
  myMovie.loop();
  //myMovie.bounce();

}

JMCMovie movieFromDataPath(String filename)
{
   return new JMCMovie(this, filename, RGB);
}


void draw() 
{

  image(myMovie, 0, 0, myMovie.width, myMovie.height);
  myMovie.setRate (((width/2.0-mouseX)/(width/2.0))*3.0);

}
</code></pre>

<p><img src="http://forum.processing.org/two/uploads/imageupload/402/IGFB44TUB4J1.png" alt="Screen Shot 2015-10-13 at 1.46.33 PM" title="Screen Shot 2015-10-13 at 1.46.33 PM" /></p>
]]></description>
   </item>
   <item>
      <title>How to change video speed with -if key pressed- ?</title>
      <link>https://forum.processing.org/two/discussion/13075/how-to-change-video-speed-with-if-key-pressed</link>
      <pubDate>Sat, 17 Oct 2015 21:59:58 +0000</pubDate>
      <dc:creator>buena_</dc:creator>
      <guid isPermaLink="false">13075@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to make my video change speed (random)  when I press a key... but I can't figure out how</p>
]]></description>
   </item>
   </channel>
</rss>