We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I wonder if instead of the gif file, you play a movie type of object. You should be able to convert the gif into a movie by retrieving the PImage array and using VideoExport by hamoid. This should be done in a separate sketch.
However I am not sure if it is going to work. I am assuming playing a movie would be more efficient and you are not been limited by the computing power of your machine. Plus I usually handle movies with smaller image dimensions. A quick test would be to get a few movies with that image size and play them together. If it works, then Movie would be the way to go. Please take my comment with a grain of salt as I am not an expert in this topic.
And I didn't test your code... I can't atm.
I intend to make the 1B to run after the 1A
Related to this comment: Based on your code scene 1A and 1B are shown together. Not sure what you mean 1B run after 1A then.
Kf
This relates to the Video Export library.
I was just told that when you export a sketch as executable, it fails to run. It seems to happen at least with Mac and Linux.
This is the error when running the Basic Example:
java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Wincon
at basic.setup(basic.java:36)
at processing.core.PApplet.handleDraw(PApplet.java:2412)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1557)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.platform.win32.Wincon
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
The example runs fine inside the Processing IDE. With the exported app, it seems to fail before the constructor is called, as I tried printing strings inside setup but nothing is shown in the console.
If you see the error mentions win32, even if this is on Linux or Mac. I make use of JNA in Windows to find out the ffmpeg.exe process and send it a ctrl+c to close it gracefully.
Any ideas for what I could try?
the Capture class is for getting images from cameras - this is not what you want
there is a video-export library for making movies. https://www.funprogramming.org/VideoExport-for-Processing/
or you can just save the frames to disk and create a video from them later.
Maybe videoExport = new VideoExport(this, "/something/like/this.mp4");
?
Please check the provided examples, which you can access from the Processing IDE after you install the library. The VideoExport lib is probably what you are looking for.
Kf
@nikos_nt -- It sounds like you want the Video Export Library by @hamoid so that you can do it right from your sketch:
If not, check out previous MovieMaker posts -- some recent ones discuss the source code and documentation, so there might be something there:
Hi! What if I added an example to the VideoExport library that used your library to analyze the sound? So step 1 would be using your library and step 2 using VideoExport. Is that close to what you want to achieve?
You should check the VideoExport lib. More precisely the withAudioViz example as @hamoid makes some comments that are relevant to your post. I will paste the comment below for you to consider.
Kf
/* Example to visualize sound frequencies from an audio file. Producing a file with audio and video in sync is tricky. It gets easily out of sync. One approach, used in this example, is: Pass 1. Analyze the sound in a Processing sketch and output a text file including the FFT analysis data. Pass 2. Load the data from pass 1 and use it to output frames for a video file, including the right frames to match the sound precisely at any given time. Using this technique it does not matter how fast or slow your second program is, and you know that no frames will be dropped (as may happen when recording live). The difficulty of recording live graphics with sound is that the frame rate is not always stable. We may request 60 frames per second, but once in a while a frame is not ready on time. So the "speed of frames" (the frameRate) is not constant while frames are produced, but they are probably constant when played back. The "speed of audio", on the other hand, is often constant. If audio is constant but video is not, they get out of sync. */
@darinb If you want to but you don't have to. Take three movies and name them m1, m2, m3 with mp4 extension. Place them in your data folder of your brand new recently created sketch and add the code below there.
This only loads three movies and play them in the same sketch. Press the key 'q' to exit the sketch and save the movie. This new generated movie contains the three previous movies with offsets. For transparency, this might or might not work.
Kf
import com.hamoid.*;
VideoExport videoExport;
import processing.video.*;
final int NMOV=3;
String[] names = {"m1.mp4", "m2.mp4", "m3.mp4"};
Movie m[]=new Movie[NMOV];
// Press 'q' to finish saving the movie and exit.
// In some systems, if you close your sketch by pressing ESC,
// by closing the window, or by pressing STOP, the resulting
// movie might be corrupted. If that happens to you, use
// videoExport.endMovie() like you see in this example.
// In some systems pressing ESC produces correct movies
// and .endMovie() is not necessary.
void setup() {
size(600, 600);
for (int i=0; i<NMOV; i++) {
m[i] = new Movie(this, names[i]);
m[i].loop();
}
videoExport = new VideoExport(this);
videoExport.startMovie();
}
void draw() {
background(0);
image(m[0], 0, 0, width/2, height/2);
image(m[1], width/2, 0, width, height/2);
image(m[2], width/4, height/2, 3*width/4.0, height);
videoExport.saveFrame();
}
void movieEvent(Movie m) {
m.read();
}
void keyPressed() {
if (key == 'q') {
videoExport.endMovie();
exit();
}
}
Keyword: multiple-movies
I'm sorry, kfrajer, I don'r understand. I don't see how to overlay video clips with VideoExport...do I have to learn ffmpeg?
Check https://forum.processing.org/two/search?Search=videoexport
You can install the VideoExport library through the library manager in the Processing IDE. Check the provided examples, which you can access via Filles>>Examples and then under Contributed Libraries folder.
Kf
That would be nice ;) If you use a relative path, which you do in the VideoExport constructor, it should allow me to point to a subfolder in the data folder directly
Yeah, just tried it and there's no problem with Movie Maker, must be a bug I guess. VideoExport works great though, thanks.
Could you check that you don't have the same problem using P3.3.4? An alternative to MovieMaker is VideoExport by @hamoid:
https://www.funprogramming.org/VideoExport-for-Processing/
https://forum.processing.org/two/discussion/9195/video-export-library
Kf
Thank you Hamoid for your answer.
Of course mp4 is a container, this is a commun mistake we make :-/ ffmpeg is a little bit beyond my skills (better saying it’s a mess for me) … but I will so learn further. In case not, h264 should match.
I think I must specify any 2nd argument to reach the 3rd one which is the variable of the choosen camera (otherwise a wrong camera will run). Anyway something magical happened : this works today perfectly fine (some fairy godmother ? maybe I am a sleepworker ?)
This too works fine today (maybe my computer doesn’t like mondays ?) In case, yes, I will write a line to ignore the 1st frame.
So begins my draw :
void draw() {
if (camichel.available()) {
camichel.read();
}
background(bgcolor);
// Here we don't save what we see on the display,
// but the webcam input.
if (recording) {
text("Enregistrement en cours", 300, 300);
videoExport.saveFrame();
}
}
Thank you again !
You're welcome, Michel.
mp4 is not a codec but a container. The library uses h264 by default. You could try a different codec by modifying the executed ffmpeg command in settings.json. Note the -vcodec h264
part. I don't know which codecs are available, please check the ffmpeg reference.
You can do videoExport = new VideoExport(this);
There should be no initial black frame. Is maybe the webcam not ready when trying to save the first frame? You could maybe ignore the first frame? Are you saving the frame first and then drawing on the screen?
Cheers!
Hello everybody and thanks a lot Hamoid for this very useful lib', which I really needed to sample video flows to my Millumin app, through Syphon. Thanks too to Jeremy who drived me on the forum to this work and that page.
Could someone indicate me the way to choose a better codec than mp4 ? (Pro Res, Hap, Photo Jpeg, H.264, Apple ProRes-4444 ...).
Silly writing question : how could I avoid a first unuseful "Camera" clip called in the setup by : videoExport = new VideoExport(this, "camera.mp4", camichel); ... when I further call in the draw : videoExport.setMovieFileName(frameCount + ".mp4"); ?
How to simply avoid a first black frame in each created clip ?
Thank you for any answer !
Thank you very much Jeremy, had'nt found this VideoExport lib, which is what I was seeking for (staying in the code and avoid the pop up). This works fine, the only difficulty for me was to first install ffmpeg, what I managed thx to Homebrew : https://brew.sh/ For some further questions I now logically go to the video export forum page that you mention : https://forum.processing.org/two/discussion/22139/video-export-library-0-1-9 :-)
@MichelNimes --
Are trying to pop up the Movie Maker wizard UI form while your sketch is running?
Or are you trying to automatically start and stop screen recording to a video file as a background operation while your sketch is running?
If the second, you probably don't want to use the want the MovieMaker Tool -- instead you want the Video Export Library by @hamoid :
The latest version is at https://www.funprogramming.org/VideoExport-for-Processing/
For now it can only be installed manually, until the URL is used by the IDE library manager.
I fixed a small bug: in Ubuntu (maybe others) the examples with audio would fail, because the AAC audio codec is experimental. I added -strict -2
to the ffmpeg command to enable AAC.
And I added a geeky advanced "feature": the ffmpeg commands that the library executes can now be tweaked by the user (you). They are found in the settings.json file in the library folder after running the library once. What does this mean? Well, ffmpeg allows all kinds of crazy filters. If you tweak the command that gets executed by the library, you could apply blur, vignetting, color tints, adjust the contrast and brightness, fade your logo in and out on top of the video, etc. Warning: those commands are not so easy to get right. If it stops working just delete settings.json and it will be created again.
I'll post an example so you get an idea.