
I’ve been trying to find a dependable method for exporting HD video from Processing sketches that contain dynamic data and movement as well as complex 3-dimensional shapes rendered using OpenGL. QuickTime’s screen recording option hogs memory and causes frames to skip, as does does ScreenFlow, my usual go-to for screen recording. The best way I have found so far is to export actual resolution PNG files using “save()” and create an HD video using FFmpeg.
FFmpeg is a very fast video and audio converter that can also grab from a live audio/video sources or create and compress video from multiple still images. It is used from the command line and gives one control of bitrates, codecs, formats, resolution, quality, metadata, and many more options for working with video.
To install FFmpeg with Macports
sudo port install ffmpeg
# view help
ffmpeg -h
# list encoders
ffmpeg -encoders
# list codecs
ffmpeg -codecs
# use format
ffmpeg [global_options] {[input_options] -i ‘input_file’} ... {[output_options] ‘output_file’} ...
# make a movie from matching .png files, write over original, codec = libx264 (H.264), framerate = 30, 1 pass, resolution = 1920×1080, video bitrate = 6Mbits, format = mp4
ffmpeg -y -pattern_type glob -i 'p_*.png' -vcodec libx264 -r 30 -q 100 -pass 1 -s 1920x1080 -vb 6M -threads 0 -f mp4 file.mp4
# convert the video file to Apple ProRes codec for use in Final Cut
ffmpeg -y -i file.mp4 -vcodec prores -vb 6M -r 30 -s 1920x1080 -f mov file.mov
# here’s another example conversion command. this one has a much higher bitrate
ffmpeg -y -i file_01.mp4 -b:v 40M -vcodec libx264 -pass 1 file_02.mp4
For example, using this Processing sketch, you generate the PNG files, and then run the code above on the command line to make this file:
Also see this video for a more detailed example
References
- FFmpeg on Wikipedia
- FFmpeg Documentation
- High Quality h264 MP4 Videos with FFmpeg
- Video/Audio Encoding Cheat Sheet
- 19 FFmpeg commands for all needs
- Choosing the Best Video Codec by Larry Jordan
- I later found this page by Jeffrey Thompson which combines the steps above into a single Processing sketch.