class OpenCVFrameRecorder extends FrameRecorder {
    public static OpenCVFrameRecorder createDefault(File f, int w, int h)   throws Exception { return new OpenCVFrameRecorder(f, w, h); }
    public static OpenCVFrameRecorder createDefault(String f, int w, int h) throws Exception { return new OpenCVFrameRecorder(f, w, h); }

    private static Exception loadingException = null;
    public static void tryLoad() throws Exception {
        if (loadingException != null) {
            throw loadingException;
        } else {
            try {
                Loader.load(org.bytedeco.opencv.global.opencv_highgui.class);
            } catch (Throwable t) {
                throw loadingException = new Exception("Failed to load " + OpenCVFrameRecorder.class, t);
            }
        }
    }

    public OpenCVFrameRecorder(File file, int imageWidth, int imageHeight) {
        this(file.getAbsolutePath(), imageWidth, imageHeight);
    }
    public OpenCVFrameRecorder(String filename, int imageWidth, int imageHeight) {
        this.filename    = filename;
        this.imageWidth  = imageWidth;
        this.imageHeight = imageHeight;

        this.pixelFormat = 1;
//        this.videoCodec  = windows ? CV_FOURCC_PROMPT : CV_FOURCC_DEFAULT;
        this.videoCodec  = windows ? -1 : VideoWriter.fourcc((byte)'I', (byte)'Y', (byte)'U', (byte)'V');
        this.frameRate   = 30;
    }
    public void release() throws Exception {
        if (writer != null) {
            writer.release();
            writer = null;
        }
    }
    @Override protected void finalize() throws Throwable {
        super.finalize();
        release();
    }

    private static final boolean windows = Loader.getPlatform().startsWith("windows");
    private String filename;
    private VideoWriter writer = null;
    private OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();

    public double getOption(int propId) {
        if (writer != null) {
            return writer.get(propId);
        }
        return Double.parseDouble(options.get(Integer.toString(propId)));
    }
    
    /**
     *
     * @param propId Property ID, look at opencv_videoio for possible values
     * @param value
     */
    public void setOption(int propId, double value) {
        options.put(Integer.toString(propId), Double.toString(value));
        if (writer != null) {
            writer.set(propId, value);
        }
    }

    public void start() throws Exception {<FILL_FUNCTION_BODY>}

    /**
     * Pixel format is an int and maps to colour if != 0, greyscale otherwise.
     */
    private boolean isColour() {
        return pixelFormat != 0;
    }

    /**
     * VideoCodec in JavaCV jargon is the same as FourCC code in OpenCV speak
     */
    private int fourCCCodec() {
        return videoCodec;
    }

    public void flush() throws Exception {
    }

    public void stop() throws Exception {
        release();
    }

    public void record(Frame frame) throws Exception {
        Mat mat = converter.convert(frame);
        if (writer != null) {
            writer.write(mat);
        } else {
            throw new Exception("Cannot record: There is no writer (Has start() been called?)");
        }
        frame.keyFrame = true;
    }
}

        writer = new VideoWriter(filename, fourCCCodec(), frameRate, new Size(imageWidth, imageHeight), isColour());

        for (Entry<String, String> e : options.entrySet()) {
            writer.set(Integer.parseInt(e.getKey()), Double.parseDouble(e.getValue()));
        }
    
<methods>public non-sealed void <init>() ,public void close() throws org.bytedeco.javacv.FrameRecorder.Exception,public static org.bytedeco.javacv.FrameRecorder create(Class<? extends org.bytedeco.javacv.FrameRecorder>, Class#RAW, java.lang.Object, int, int) throws org.bytedeco.javacv.FrameRecorder.Exception,public static org.bytedeco.javacv.FrameRecorder create(java.lang.String, java.io.File, int, int) throws org.bytedeco.javacv.FrameRecorder.Exception,public static org.bytedeco.javacv.FrameRecorder create(java.lang.String, java.lang.String, int, int) throws org.bytedeco.javacv.FrameRecorder.Exception,public static org.bytedeco.javacv.FrameRecorder createDefault(java.io.File, int, int) throws org.bytedeco.javacv.FrameRecorder.Exception,public static org.bytedeco.javacv.FrameRecorder createDefault(java.lang.String, int, int) throws org.bytedeco.javacv.FrameRecorder.Exception,public abstract void flush() throws org.bytedeco.javacv.FrameRecorder.Exception,public static Class<? extends org.bytedeco.javacv.FrameRecorder> get(java.lang.String) throws org.bytedeco.javacv.FrameRecorder.Exception,public double getAspectRatio() ,public int getAudioBitrate() ,public int getAudioChannels() ,public int getAudioCodec() ,public java.lang.String getAudioCodecName() ,public Map<java.lang.String,java.lang.String> getAudioMetadata() ,public java.lang.String getAudioMetadata(java.lang.String) ,public java.lang.String getAudioOption(java.lang.String) ,public Map<java.lang.String,java.lang.String> getAudioOptions() ,public double getAudioQuality() ,public Map<java.lang.String,java.nio.Buffer> getAudioSideData() ,public java.nio.Buffer getAudioSideData(java.lang.String) ,public java.nio.charset.Charset getCharset() ,public static Class<? extends org.bytedeco.javacv.FrameRecorder> getDefault() ,public java.lang.String getFormat() ,public int getFrameNumber() ,public double getFrameRate() ,public int getGopSize() ,public int getImageHeight() ,public int getImageScalingFlags() ,public int getImageWidth() ,public int getMaxBFrames() ,public int getMaxDelay() ,public Map<java.lang.String,java.lang.String> getMetadata() ,public java.lang.String getMetadata(java.lang.String) ,public java.lang.String getOption(java.lang.String) ,public Map<java.lang.String,java.lang.String> getOptions() ,public int getPixelFormat() ,public int getSampleFormat() ,public int getSampleRate() ,public long getTimestamp() ,public int getTrellis() ,public int getVideoBitrate() ,public int getVideoCodec() ,public java.lang.String getVideoCodecName() ,public Map<java.lang.String,java.lang.String> getVideoMetadata() ,public java.lang.String getVideoMetadata(java.lang.String) ,public java.lang.String getVideoOption(java.lang.String) ,public Map<java.lang.String,java.lang.String> getVideoOptions() ,public double getVideoQuality() ,public Map<java.lang.String,java.nio.Buffer> getVideoSideData() ,public java.nio.Buffer getVideoSideData(java.lang.String) ,public static void init() ,public boolean isInterleaved() ,public abstract void record(org.bytedeco.javacv.Frame) throws org.bytedeco.javacv.FrameRecorder.Exception,public abstract void release() throws org.bytedeco.javacv.FrameRecorder.Exception,public void setAspectRatio(double) ,public void setAudioBitrate(int) ,public void setAudioChannels(int) ,public void setAudioCodec(int) ,public void setAudioCodecName(java.lang.String) ,public void setAudioMetadata(Map<java.lang.String,java.lang.String>) ,public void setAudioMetadata(java.lang.String, java.lang.String) ,public void setAudioOption(java.lang.String, java.lang.String) ,public void setAudioOptions(Map<java.lang.String,java.lang.String>) ,public void setAudioQuality(double) ,public void setAudioSideData(Map<java.lang.String,java.nio.Buffer>) ,public void setAudioSideData(java.lang.String, java.nio.Buffer) ,public void setCharset(java.nio.charset.Charset) ,public void setFormat(java.lang.String) ,public void setFrameNumber(int) ,public void setFrameRate(double) ,public void setGopSize(int) ,public void setImageHeight(int) ,public void setImageScalingFlags(int) ,public void setImageWidth(int) ,public void setInterleaved(boolean) ,public void setMaxBFrames(int) ,public void setMaxDelay(int) ,public void setMetadata(Map<java.lang.String,java.lang.String>) ,public void setMetadata(java.lang.String, java.lang.String) ,public void setOption(java.lang.String, java.lang.String) ,public void setOptions(Map<java.lang.String,java.lang.String>) ,public void setPixelFormat(int) ,public void setSampleFormat(int) ,public void setSampleRate(int) ,public void setTimestamp(long) ,public void setTrellis(int) ,public void setVideoBitrate(int) ,public void setVideoCodec(int) ,public void setVideoCodecName(java.lang.String) ,public void setVideoMetadata(Map<java.lang.String,java.lang.String>) ,public void setVideoMetadata(java.lang.String, java.lang.String) ,public void setVideoOption(java.lang.String, java.lang.String) ,public void setVideoOptions(Map<java.lang.String,java.lang.String>) ,public void setVideoQuality(double) ,public void setVideoSideData(Map<java.lang.String,java.nio.Buffer>) ,public void setVideoSideData(java.lang.String, java.nio.Buffer) ,public abstract void start() throws org.bytedeco.javacv.FrameRecorder.Exception,public abstract void stop() throws org.bytedeco.javacv.FrameRecorder.Exception<variables>protected double aspectRatio,protected int audioBitrate,protected int audioChannels,protected int audioCodec,protected java.lang.String audioCodecName,protected Map<java.lang.String,java.lang.String> audioMetadata,protected Map<java.lang.String,java.lang.String> audioOptions,protected double audioQuality,protected Map<java.lang.String,java.nio.Buffer> audioSideData,protected java.nio.charset.Charset charset,protected java.lang.String format,protected int frameNumber,protected double frameRate,protected int gopSize,protected int imageHeight,protected int imageScalingFlags,protected int imageWidth,protected boolean interleaved,public static final List<java.lang.String> list,protected int maxBFrames,protected int maxDelay,protected Map<java.lang.String,java.lang.String> metadata,protected Map<java.lang.String,java.lang.String> options,protected int pixelFormat,protected int sampleFormat,protected int sampleRate,protected long timestamp,protected int trellis,protected int videoBitrate,protected int videoCodec,protected java.lang.String videoCodecName,protected Map<java.lang.String,java.lang.String> videoMetadata,protected Map<java.lang.String,java.lang.String> videoOptions,protected double videoQuality,protected Map<java.lang.String,java.nio.Buffer> videoSideData