audioduration

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

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

Go to latest
Published: Oct 28, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

README

Audio Duration

A naive go module to get a audio file's duration in second.

Usage

import github.com/hcl/audioduration

For an audio file (eg. mp3 format)

f, _ := os.Open("audio.mp3")
defer f.Close()
d, err := audioduration.Mp3(f)
if err != nil {
	// handling error
}

Or alternatively

f, _ := os.Open("audio.mp3")
defer f.Close()
d, err := audioduration.Duration(f, audioduration.TypeMp3)
if err != nil {
	// handling error
}

License

The code is licensed under GPLv3.

    audioduration - audio duration calculation library in go
    Copyright (C) 2021  hcl

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Credits

The audio samples (files under samples) for package test are from following source:

Documentation

Index

Constants

View Source
const (
	TypeFlac int = 0
	TypeMp4  int = 1
	TypeMp3  int = 2
	TypeOgg  int = 3
	TypeDsd  int = 4
)

File Type Constant

Variables

This section is empty.

Functions

func DSD

func DSD(r io.ReadSeeker) (float64, error)

DSD Calculate dsd files duration.

func Duration

func Duration(file *os.File, filetype int) (float64, error)

Duration Get duration of specific music file type.

func FLAC

func FLAC(r io.ReadSeeker) (float64, error)

FLAC Calculate flac files duration.

func Mp3

func Mp3(r *os.File) (float64, error)

Mp3 Calculate mp3 files duration.

func Mp4

func Mp4(r io.ReadSeeker) (float64, error)

Mp4 Calculate mp4 files duration.

func Ogg

func Ogg(r io.ReadSeeker) (float64, error)

Ogg Calculate ogg files duration.

Types

type VBRI

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

VBRI VBRI Header

type Xing

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

Xing Xing Header

Jump to

Keyboard shortcuts

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