The FFmpeg binary to be used can be specified by the optional
constructor parameter ffmpegExecutablePath.
It defaults to ffmpeg; this will trigger the usual lookup procedures
of the system the application runs on.
On POSIX this usually means searching for FFmpeg in the directories
specified by the environment variable PATH.
On Windows it will also look for an executable file with that name in
the current working directory.
The value of the outputFormat parameter of various constructor
overloads is passed to FFmpeg via the -f (“format”) option.
Run ffmpeg -formats to get a list of available formats.
1. Install FFmpeg (the CLI version).
- Debian derivatives (with FFmpeg in their repos): apt install ffmpeg
- Homebew: brew install ffmpeg
- Chocolatey: choco install ffmpeg
- Links to pre-built binaries can be found on <https://ffmpeg.org/download.html>.
2. Determine where you’ve installed FFmpeg to.
Ideally, it’s somewhere within “PATH” so it can be run from the
command-line by just doing ffmpeg.
Otherwise, you’ll need the specific path to the executable to pass it
to the constructor of PixmapRecorder.
importarsd.pixmaprecorder;
importarsd.pixmappaint;
/++
This demo renders a 1280×720 video at 30 FPS
fading from white (#FFF) to blue (#00F).
+/intmain() {
// Instantiate a recorder.autorecorder = newPixmapRecorder(
30, // Video framerate [=FPS]"out.mkv", // Output path to write the video file to.
);
// We will use this framebuffer later on to provide image data// to the encoder.autoframe = Pixmap(1280, 720);
for (intlight = 0xFF; light >= 0; --light) {
autocolor = Color(light, light, 0xFF);
frame.clear(color);
// Record the current frame.// The video resolution to use is derived from the first frame.recorder.put(frame);
}
// End and finalize the recording process.returnrecorder.stopRecording();
}
Pixmap Recorder is an auxiliary library for rendering video files from Pixmap frames by piping them to FFmpeg.
Tips and tricks
It defaults to ffmpeg; this will trigger the usual lookup procedures of the system the application runs on. On POSIX this usually means searching for FFmpeg in the directories specified by the environment variable PATH. On Windows it will also look for an executable file with that name in the current working directory.
Run ffmpeg -formats to get a list of available formats.
$(TIP Combining this module with Pixmap Presenter is really straightforward.
In the most simplistic case, set up a PixmapRecorder before running the presenter. Then call pixmapRecorder.record(presenter.framebuffer)
at the end of the drawing callback in the eventloop.
)
or Pixmap.fromMemoryImage()
respectively.
Examples
Getting started
1. Install FFmpeg (the CLI version). - Debian derivatives (with FFmpeg in their repos): apt install ffmpeg - Homebew: brew install ffmpeg - Chocolatey: choco install ffmpeg - Links to pre-built binaries can be found on <https://ffmpeg.org/download.html>. 2. Determine where you’ve installed FFmpeg to. Ideally, it’s somewhere within “PATH” so it can be run from the command-line by just doing ffmpeg. Otherwise, you’ll need the specific path to the executable to pass it to the constructor of PixmapRecorder.