[gsvideo] Chaining videos
in
Contributed Library Questions
•
2 years ago
Hi all,
I'm trying to display a sequence of videos (like hundreds so an array is not a option), with no interruption between the last frame of a video and the first frame of the next one. I'm using gsvideo 0.9 with processing 1.5 on a linux computer. Gstreamer is fairly recent (0.10 and so).
Here is a reduced sample code of what I want to do. At first the video is looping, just to show it's a loop. Then the program switches between two files. This shows a glitch. For that example, the two files are the same loop so we can clearly see the problem.
Maybe I'm doing something wrong, should I use something like Offscreen buffers ? If so how ?
You can also find the sketch with the loop video here :
http://charles.goyard.free.fr/forums/chaining_videos.zip
Here's the code :
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import codeanticode.gsvideo.*;
- GSMovie clips[];
- GLTexture tex;
- int current;
- boolean looping = true;
- void setup() {
- size(640, 480, GLConstants.GLGRAPHICS);
- frameRate(25);
- clips = new GSMovie[2];
- tex = new GLTexture(this);
- current = 0;
- clips[current] = new GSMovie(this, "loop.mp4");
- clips[other()] = new GSMovie(this, "loop.mp4");
- clips[current].setPixelDest(tex);
- clips[current].loop();
- println("looping oh so smooth");
- }
- int other() {
- return current == 1 ? 0 : 1;
- }
- void movieEvent(GSMovie m) {
- m.read();
- }
- void draw() {
- next_movie_loader next_movie;
- if (looping && millis() > 12000) {
- println("will now chain movies - see the glitches ?");
- clips[current].noLoop();
- looping = false;
- }
- if (tex.putPixelsIntoTexture()) {
- image(tex, 0, 0);
- }
- if (! clips[current].isPlaying()) {
- current = other();
- clips[current].setPixelDest(tex);
- clips[current].play();
- next_movie = new next_movie_loader(this, "loop.mp4");
- next_movie.start();
- }
- }
- // creates the gsmovie object out of the main thread
- class next_movie_loader extends Thread {
- String m;
- processing.core.PApplet p;
- next_movie_loader(processing.core.PApplet parent, String moviefile) {
- p = parent;
- m = moviefile;
- }
- void run() {
- if (clips[other()] != null) {
- clips[other()].delete();
- }
- clips[other()] = new GSMovie(p, m);
- }
- }
Thanks,
Charles
1