TheCacophonyProject / go-cptv

Go package for creating and reading Cacophony Project Thermal Video (CPTV) files
Apache License 2.0
2 stars 6 forks source link
cptv-files

go-cptv

Build Status

This package implements a Go package for generating and consuming Cacophony Project Thermal Video (CPTV) files. For more details on these files see the specifications:

Example Usage

Writing CPTV Files


import (
    "github.com/TheCacophonyProject/go-cptv"
    "github.com/TheCacophonyProject/go-cptv/cptvframe"
)

type TestCamera struct {
}

func (cam *TestCamera) ResX() int {
    return 200
}

func (cam *TestCamera) ResY() int {
    return 20
}

func writeFrames(frames []*cptvframe.Frame) error {
    camera := new(TestCamera)
    w := cptv.NewFileWriter("out.cptv", camera)
    defer w.Close()
    err := w.WriterHeader("device-name")
    if err != nil {
        return err
    }
    for _, frame := range frames {
        err := w.WriteFrame(frame)
        if err != nil {
            return err
        }
    }
    return nil
}

Reading CPTV Files

See cptvtool for a read example.