public class VideoExport
extends java.lang.Object
import com.hamoid.*; VideoExport videoExport; // 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 other systems pressing ESC produces correct movies // and .endMovie() is not necessary. void setup() { size(600, 600); videoExport = new VideoExport(this); videoExport.startMovie(); } void draw() { background(#224488); rect(frameCount * frameCount % width, 0, 40, height); videoExport.saveFrame(); } void keyPressed() { if (key == 'q') { videoExport.endMovie(); exit(); } }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
VERSION |
Constructor and Description |
---|
VideoExport(PApplet parent)
Constructor, usually called in the setup() method in your sketch to
initialize and start the library.
|
VideoExport(PApplet parent,
java.lang.String outputFileName)
Constructor that allows specifying a movie file name.
|
VideoExport(PApplet parent,
java.lang.String outputFileName,
PImage img)
Constructor that allows to set a PImage to export as video (advanced)
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Called automatically by Processing to clean up before shut down
|
void |
endMovie()
Called to end exporting a movie before exiting our program, or before
exporting a new movie.
|
void |
forgetFfmpegPath()
Makes the library forget about where the ffmpeg binary was located.
|
int |
getCurrentFrame()
Call this function to figure out how many frames your movie has so far.
|
float |
getCurrentTime()
You could use the returned value to display a time counter, a progress
bar or to create periodic motion, for instance by feeding
the returned value into the sin() function, and using the result to drive
the position of an object.
|
java.lang.String |
getFfmpegPath()
Call this if you need to figure out the path to the ffmpeg program
(advanced).
|
void |
onFfmpegSelected(java.io.File selection)
Called internally by the file selector when the user chooses
the location of ffmpeg on the disk.
|
void |
saveFrame()
Adds one frame to the video file.
|
void |
setAudioFileName(java.lang.String audioFileName) |
void |
setDebugging(boolean saveDebugFile)
Call this method to specify if you want a debug text file saved
together with the video file.
|
void |
setFfmpegAudioSettings(java.lang.String[] newSettings)
Advanced.
|
void |
setFfmpegPath(java.lang.String path)
Call this method if you know the path to ffmpeg on your computer
(advanced).
|
void |
setFfmpegVideoSettings(java.lang.String[] newSettings)
Advanced.
|
void |
setFrameRate(float frameRate)
Set the frame rate of the produced video file.
|
void |
setGraphics(PImage img)
Set the PImage element.
|
void |
setLoadPixels(boolean doLoadPixels)
You can tell VideoExport not to call loadPixels() internally.
|
void |
setMovieFileName(java.lang.String newMovieFileName)
Allow setting a new movie name, in case we want to export several movies,
one after the other.
|
void |
setQuality(int crf,
int audioBitRate)
Set the quality of the produced video file.
|
void |
startMovie() |
static java.lang.String |
version()
Return the version of the library.
|
public static final java.lang.String VERSION
public VideoExport(PApplet parent)
Using a default movie file name (processing-movie.mp4).
parent
- Pass "this" when constructing a VideoExport instancepublic VideoExport(PApplet parent, java.lang.String outputFileName)
parent
- Parent PApplet, normally "this" when called from setup()outputFileName
- The name of the video file to produce, for instance
"beauty.mp4"import com.hamoid.*; VideoExport videoExport; // 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 other systems pressing ESC produces correct movies // and .endMovie() is not necessary. void setup() { size(600, 600); videoExport = new VideoExport(this); videoExport.startMovie(); } void draw() { background(#224488); rect(frameCount * frameCount % width, 0, 40, height); videoExport.saveFrame(); } void keyPressed() { if (key == 'q') { videoExport.endMovie(); exit(); } }
public VideoExport(PApplet parent, java.lang.String outputFileName, PImage img)
parent
- Parent PApplet, normally "this" when called from setup()outputFileName
- The name of the video file to produce, for instance
"beauty.mp4"img
- PImage object to export as video (can be a PGraphics, Movie,
Capture...)import com.hamoid.*; VideoExport videoExport; PGraphics pg; void setup() { size(600, 600); pg = createGraphics(640, 480); videoExport = new VideoExport(this, "pgraphics.mp4", pg); videoExport.startMovie(); } void draw() { background(0); text("exporting video " + frameCount, 50, 50); pg.beginDraw(); pg.background(#224488); pg.rect(pg.width * noise(frameCount * 0.01), 0, 40, pg.height); pg.endDraw(); videoExport.saveFrame(); } void keyPressed() { if (key == 'q') { videoExport.endMovie(); exit(); } }
public static java.lang.String version()
public void setMovieFileName(java.lang.String newMovieFileName)
newMovieFileName
- String with file name of the new movie to createpublic void setAudioFileName(java.lang.String audioFileName)
public void setGraphics(PImage img)
img
- A PImage object. Probably used for off-screen exporting..public void setQuality(int crf, int audioBitRate)
crf
- Video quality. A value between 0 (high compression) and 100
(high quality, lossless). Default is 70.audioBitRate
- Audio quality (bit rate in kbps).
128 is the default. 192 is very good.
More than 256 does not make sense.
Higher numbers produce heavier files.public void setFrameRate(float frameRate)
frameRate
- The frame rate at which the resulting video file should be
played. The default is 30, which is the recommended for online
video.public void setLoadPixels(boolean doLoadPixels)
doLoadPixels
- Set to false to disable the internal loadPixels() call.public void setDebugging(boolean saveDebugFile)
saveDebugFile
- Set to false to disable saving the ffmpeg output in a text
filepublic void setFfmpegVideoSettings(java.lang.String[] newSettings)
newSettings
- An array with all the command line
arguments to call to produce a video.public void setFfmpegAudioSettings(java.lang.String[] newSettings)
newSettings
- An array with all the command line
arguments to call to produce a video.public void saveFrame()
public int getCurrentFrame()
public float getCurrentTime()
public java.lang.String getFfmpegPath()
public void setFfmpegPath(java.lang.String path)
path
- public void forgetFfmpegPath()
public void onFfmpegSelected(java.io.File selection)
selection
- (internal)public void startMovie()
public void endMovie()
public void dispose()
Processing Library VideoExport by Abe Pazos. (c) 2017