benrr101 / node-taglib-sharp

A node.js port of mono/taglib-sharp
GNU Lesser General Public License v2.1
42 stars 11 forks source link

bitrate will be 0 on some files #102

Open subframe7536 opened 9 months ago

subframe7536 commented 9 months ago

Bitrate can be roughly calculated by (file.fileAbstraction.size - file.tag.sizeOnDisk) * 8 / file.properties.duration. Some files will return 0 when getting its bitrate, and make a fallback value for bitrate is needed IMO.

But that needs a new property on FileAbstraction. Here is my implemention.

export class Stream {
    // ...
    public static getFileSize(path: string): number {
        return fs.statSync(path).size
    }
}

export interface IFileAbstraction {
    // ...
    /**
     * Total size of file
     */
    size: number;
}

export class FileAbstraction {
    // ...
    public get size(): number {
        return Stream.getFileSize(this._name)
    }
}
subframe7536 commented 9 months ago

I'm willing to open a PR for it

stuartambient commented 5 months ago

Anything come of this ? I have a bunch showing 0 yet they are showing up correctly in VLC.

Edit: there are also others with 1.xxxx or 0.xxxx bitrates. The percentage of 'wrong' bitrates was low compared to how many files I tested (all audio) but still would like a way to fix it.

Edit2: Checked some of the file sin ffprobe , bitrate was correct.