audiovalidate

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package audiovalidate provides lightweight audio-file integrity checks that run before expensive transcription or disk-write operations.

The checks are intentionally minimal: they guard against obviously-corrupt files (e.g. 4096-byte all-zero uploads) rather than full format validation. False-negatives (corrupt files that pass) are handled downstream; these guards exist to short-circuit the infinite-retry loop caused by files that will never successfully decode.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotM4A = errors.New("audio file missing ftyp box at offset 4 (not a valid m4a/mp4)")

ErrNotM4A is returned when the data does not carry the ISO Base Media File Format "ftyp" box at offset 4, which is required for m4a/mp4 audio.

View Source
var ErrTooShort = errors.New("audio file too short to be a valid container")

ErrTooShort is returned when the provided data is shorter than minAudioBytes.

Functions

func CheckAudioBytes

func CheckAudioBytes(data []byte) error

CheckAudioBytes enforces the minimum-length guard only, without any container-format check. Use this for non-m4a audio formats (mp3, wav, etc.) where byte[4:8] does not carry a known magic value.

Returns ErrTooShort when len(data) < 8, nil otherwise.

func CheckM4A

func CheckM4A(data []byte) error

CheckM4A validates the leading bytes of an m4a/mp4 audio payload.

Checks performed (in order):

  1. Minimum length: len(data) >= 8. Shorter data is rejected with ErrTooShort.
  2. ftyp magic: bytes[4:8] == "ftyp". Files that lack this box are rejected with ErrNotM4A.

All other file formats (mp3, wav, etc.) should use CheckAudioBytes instead, which only enforces the minimum-length guard.

Returns nil when the data passes both checks.

Types

This section is empty.

Jump to

Keyboard shortcuts

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