Skip to content

Instantly share code, notes, and snippets.

@mfandl
Created February 9, 2018 20:59
Show Gist options
  • Save mfandl/c107672c00ccf4256767783f8a3e31b2 to your computer and use it in GitHub Desktop.
Save mfandl/c107672c00ccf4256767783f8a3e31b2 to your computer and use it in GitHub Desktop.
openFrameworks + ofxVideoRecorder setup to record video with h264
/**
* openFrameworks + ofxVideoRecorder setup to record video with h264
* You will need ffmpeg and libx264 in your system. On mac, you can use homebrew.
* reason for yuv420p:
* 'QuickTime only supports YUV planar color space with 4:2:0 chroma subsampling (use -vf format=yuv420p or -pix_fmt yuv420p) for H.264 video.'
* as mentioned here: https://trac.ffmpeg.org/wiki/Encode/H.264
*/
recorder.setVideoCodec("libx264");
string fileName = ofToDataPath("v" + ofGetTimestampString() + ".mp4");
recorder.setupCustomOutput(fbo.getWidth(), fbo.getHeight(), 60, 44100, 0, "-vf format=yuv420p -preset ultrafast " + fileName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment