node-taglib-sharp
node-taglib-sharp copied to clipboard
bitrate will be 0 on some files
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)
}
}
I'm willing to open a PR for it
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.