Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting MP3 file duration #97

Closed
duysqubix opened this issue Oct 11, 2023 · 1 comment
Closed

Error getting MP3 file duration #97

duysqubix opened this issue Oct 11, 2023 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@duysqubix
Copy link
Contributor

func Mp3Time(){

byteBody, anyErr := ioutil.ReadFile("./test.mp3")
if anyErr != nil {
	fmt.Printf("ReadFile err:%v\n", anyErr)
	return
}

fmt.Printf("len byteMp3:%v\n", len(string(byteBody)))

streamer, format, anyErr := mp3.Decode(ioutil.NopCloser(bytes.NewBuffer(byteBody)))
if anyErr != nil {
	fmt.Printf("Decode anyErr:%v", anyErr)
	return
}


defer streamer.Close()
fmt.Printf("streamerMp3.Len():%v\n", streamer.Len())

length := format.SampleRate.D(streamer.Len())

nTime := int64(length.Round(time.Millisecond).Seconds() * 1000)

fmt.Printf("time:%v\n", nTime)

}
The result is:
len byteMp3:2219090
streamerMp3.Len():0
time:0

Original issue: faiface/beep#76

@MarkKremer
Copy link
Contributor

Duplicate of #37

@MarkKremer MarkKremer marked this as a duplicate of #37 Oct 11, 2023
@MarkKremer MarkKremer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2023
@MarkKremer MarkKremer added the duplicate This issue or pull request already exists label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants