mp4ring

package module
v0.0.0-...-bdf91a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 5 Imported by: 0

README

Go Report Card License

Description

Cyclic buffer for fragmented mp4 stream in order to save memory when pre-recording an event. Does not use FFmpeg, suitable for embedded systems.

scc

───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Go                           2       364       45        24      295         36
License                      1       674      121         0      553          0
Markdown                     1        33        5         0       28          0
gitignore                    1         2        0         0        2          0
───────────────────────────────────────────────────────────────────────────────
Total                        5      1073      171        24      878         36
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $23,564
Estimated Schedule Effort (organic) 3.31 months
Estimated People Required (organic) 0.63
───────────────────────────────────────────────────────────────────────────────
Processed 47143 bytes, 0.047 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

Packages

Use Go Modules.

License

Please read the LICENSE file.

Contribute

The project is used to publish an article, but I am always happy to receive any help.

Documentation

Overview

Cyclic buffer for fragmented mp4 stream in order to save memory when pre-recording an event

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrSize - size must be positive
	ErrSize = errors.New("size must be positive")

	// ErrBufClose - ring buffer is closed
	ErrBufClose = errors.New("buffer is closed")

	// ErrBufNil - ring buffer is nil
	ErrBufNil = errors.New("buffer is nil")
)

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer implements a cyclic buffer. Has a fixed size, and the new data overwrites the old, so that for a buffer of size N, for any number of write operations, only the last N mp4 atoms are saved. At the same time, the ftyp and moov headers are stored separately.

func New

func New(size int) (*Buffer, error)

New creates a new buffer of the specified size. The size must be greater than 0

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes provides all recorded mp4 headers and atoms

func (*Buffer) Close

func (b *Buffer) Close() error

Close closing the buffer

func (*Buffer) Size

func (b *Buffer) Size() string

Size provides the size of all recorded data in kilobytes

func (*Buffer) Write

func (b *Buffer) Write(buf []byte) (int, error)

Write writes headers and up to N atoms to the inner ring, overwriting older data if necessary

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL