node-taglib-sharp icon indicating copy to clipboard operation
node-taglib-sharp copied to clipboard

bitrate will be 0 on some files

Open subframe7536 opened this issue 1 year ago • 22 comments

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 avatar Feb 02 '24 00:02 subframe7536

I'm willing to open a PR for it

subframe7536 avatar Feb 02 '24 00:02 subframe7536

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.

stuartambient avatar Jun 03 '24 01:06 stuartambient