28 lines
548 B
Go
28 lines
548 B
Go
package audio
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mewkiz/flac"
|
|
)
|
|
|
|
func analyzeFLAC(filePath string) (*TrackInfo, error) {
|
|
stream, err := flac.ParseFile(filePath)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("parsing FLAC: %w", err)
|
|
}
|
|
defer stream.Close()
|
|
|
|
info := stream.Info
|
|
durationMs := int(info.NSamples * 1000 / uint64(info.SampleRate))
|
|
|
|
return &TrackInfo{
|
|
Format: "FLAC",
|
|
BitDepth: int(info.BitsPerSample),
|
|
SampleRate: int(info.SampleRate),
|
|
Channels: int(info.NChannels),
|
|
DurationMs: durationMs,
|
|
IsLossless: true,
|
|
}, nil
|
|
}
|