Skip to content
codeanticode edited this page May 28, 2019 · 12 revisions

In order to develop the video library using the Eclipse IDE, we need to import the processing-core and processing-video projects into Eclipse, copy the GStreamer libraries into the processing-video project, and finally create a debug project.

Importing Processing projects into Eclipse

I - Setting up Processing

Since we only require processing as a dependency, perform a shallow clone of the processing repo and build it by running ant in the processing/build folder, as detailed in the build instructions for Processing:

git clone https://github.com/processing/processing.git --depth 1

II - Import processing-core project into Eclipse

  1. Import the Processing repo into Eclipse: Import > Projects from Git > Existing local repository > Select Processing folder > Import existing eclipse project
  2. Select processing-core

III - Import processing-video project into Eclipse

Import the processing-video repo into Eclipse, following the same procedure explained in the previous step to import processing-core.

IV - Copy GStreamer libraries

The video library needs the GStreamer libraries in order to run. On Linux, GStreamer is available by default in most distributions, but Windows and MacOS need separate installs, so GStreamer is directly bundled with the video library. Download the appropriate package for your system from this file release, either Windows 32 bit, Windows 64 bit, or MacOS (64 bit only), uncompress and copy the folder into processing-video/library.

Create debug Processing sketch in Eclipse

Once we have processing-core and processing-video imported in Eclipse and the GStreamer libraries copied into processing-video in the case we are developing either on Windows or Mac, we need to create an Eclipse project that allows to run a Processing sketch using the video's classes. This tutorial on Processing in Eclipse is useful, but we need to do a different configuration:

I - Create Eclipse project

First of all, we start creating a new empty Eclipse project as indicated in the tutorial, and then add a main class to it, named for example Test inside some package path such as video_test. But then, because processing-core and processing-video should be already imported into the Eclipse environment, we can simply include them in the Java Build Path of our project:

image

II - Implement Processing and video methods in Test class

We can import the core and video packages into our Test project because we added them to the Build path in the previous step. This will allow us to add all the functionality needed to to video operations in Processing, from our Eclipse project. For example, to test movie playback:

package video_test;

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

public class Test extends PApplet {
  Movie movie;
	
  public void settings() {
    size(560, 406);
  }

  public void setup() {	  
	background(0);
	// Load and play the video in a loop
	movie = new Movie(this, "launch2.mp4");
	movie.loop();
  }

  public void draw() {
    image(movie, 0, 0, width, height);
  }	
	
  public void movieEvent(Movie m) {
	m.read();
  }  
  
  public static void main(String[] args) {
    PApplet.main("video_test.Test");
  }

}

It is important to add a video file to the Eclipse project, in this case it is called launch2.mp4, and should be located in a data folder created in the root of the project. Also, remember to set all methods, particularly movieEvent, as public. Otherwise, playback will not work.

III - Add Gstreamer paths to VM arguments

When running the video library from Eclipse, we need to explicitly tell Java where to find the GStreamer base libraries and plugins (this is required only for Windows and Mac). Since the base libs should be located in <processing-video path>/library/<system> (where system is macosx64, windows64, or windows32), and the plugins in <processing-video path>/library/<system>/gstreamer-1.0, we set them using the gstreamer.library.path and gstreamer.plugin.path, which are set in the Run Configurations of the Eclipse project:

image

under the Arguments tab:

image

After doing all of this, the project should run and play the video file:

image

Clone this wiki locally