https://github.com/artskydj/bitrate
:chart_with_upwards_trend: Calculates the bitrate given a file's size and duration
https://github.com/artskydj/bitrate
Last synced: 8 months ago
JSON representation
:chart_with_upwards_trend: Calculates the bitrate given a file's size and duration
- Host: GitHub
- URL: https://github.com/artskydj/bitrate
- Owner: ArtskydJ
- Created: 2015-09-11T14:34:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-08T02:40:01.000Z (about 10 years ago)
- Last Synced: 2025-05-09T03:34:53.604Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
bitrate
=========
> Calculates the bitrate given a file's size and duration
[](https://travis-ci.org/ArtskydJ/bitrate)
# example
```js
var bitrate = require('bitrate')
var bytes = 6076940
var seconds = 149
var kilobitsPerSecond = bitrate(bytes, seconds) // => 326.3
var bitsPerSecond = bitrate(bytes, seconds, 'bps') // => 326279
var BytesPerSecond = bitrate(bytes, seconds, 'Bps') // => 40785
```
# api
```js
var bitrate = require('bitrate')
```
## `var rate = bitrate(bytes, seconds, [format])`
- `bytes` is a number of bytes
- `seconds` is a number of the duration in seconds
- `format` is a string of the desired format. Accepts:
- `bps`, `b/s`; bits per second
- `kbps`, `kb/s`; kilobits per second **default**
- `mbps`, `mb/s`; megabits per second
- `Bps`, `B/s`; bytes per second
- `KBps`, `KB/s`; kilobytes per second
- `MBps`, `MB/s`; megabytes per second
- **Returns** `rate` number
# install
With [npm](http://nodejs.org/download) do:
npm install bitrate
# license
[VOL](http://veryopenlicense.com)