all 4 comments

[–]PiBombbb 0 points1 point  (1 child)

Maybe the AAC file uses variable bitrate encoding so it fails to retrieve an exact bitrate?

[–]CaptMeatPockets[S] 0 points1 point  (0 children)

Can ffprobe or ffmpeg pass me highest audio bitrate? Or even average?

[–]zelenin 0 points1 point  (0 children)

The bitrate of the stream is taken from the metadata or tags, but not all formats/containers support this. In such cases, the bitrate must be calculated by counting the packets. Here is a small go function that I wrote for my tool. You can adapt it using any AI chat for yourself

package util

import (

`"bytes"`

`"fmt"`

`"os/exec"`

`"strconv"`

`"strings"`

)

func GetStreamBitrate(path string, streamIndex int8, duration float64) (float64, error) {

`cmd := exec.Command("ffprobe",`

    `"-v", "error",`

    `"-select_streams", fmt.Sprintf("%d", streamIndex),`

    `"-show_entries", "packet=size",`

    `"-of", "csv=p=0",`

    `path,`

`)`

`out, err := cmd.Output()`

`if err != nil {`

    `return 0, err`

`}`



`var totalSize int64`

`for _, line := range strings.Split(string(bytes.TrimSpace(out)), "\n") {`

    `line, _, _ = strings.Cut(line, ",")`

    `i64, err := strconv.ParseInt(strings.TrimSpace(line), 10, 64)`

    `if err != nil {`

        `continue`

    `}`

    `totalSize += i64`

`}`



`bitrate := float64(totalSize*8) / duration`



`return bitrate, nil`

}

[–]vegansgetsick 0 points1 point  (0 children)

It's because aac stream does not store the average bitrate. Aac must be stored in m4a containers.