# video-to-pixels

> stream raw pixel data from a video, frame by frame

Latest version **0.0.1** (published 2022-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install video-to-pixels
pnpm add video-to-pixels
yarn add video-to-pixels
bun add video-to-pixels
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2022-06-15 |
| First published | 2022-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | stonkpunk |
| Maintainers | stonkpunk |
| Keywords | stream, pixels, ffmpeg, video, frames, rgba |

## Links

- npm: https://www.npmjs.com/package/video-to-pixels
- Homepage: https://github.com/stonkpunk/my-npm-modules/tree/main/video-to-pixels
- npm.io page: https://npm.io/package/video-to-pixels

## Dependencies (5)

- [stream](https://npm.io/package/stream.md) 0.0.2
- [deasync](https://npm.io/package/deasync.md) ^0.1.26
- [image-decode](https://npm.io/package/image-decode.md) ^1.2.2
- [ffmpeg-stream](https://npm.io/package/ffmpeg-stream.md) ^0.7.0
- [get-video-dimensions](https://npm.io/package/get-video-dimensions.md) ^1.0.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2022-06-15

## README

# video-to-pixels

stream raw pixel data from a video, frame by frame

## Installation

```sh
npm i video-to-pixels
```

## Usage 

```javascript
var v2p = require('video-to-pixels');

//https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4
var videoFile = './Big_Buck_Bunny_360_10s_1MB.mp4'

//stream raw unit8 data from video, frame by frame
v2p.videoToPixels(videoFile, function(frameData,width,height){
    //frameData is raw buffer like <Buffer 51 50 37 ff 4e 4d 34 ff 4d 4b 35 ff 4d 4b 35 ff 4e 4c 3 ...
    var rgbaArr = [...frameDataBuffer]; //now it is uint8 array [r,g,b,a,r,g,b,a...]
}, function(){
    console.log('done');
})

//syncronous version
var frameData = v2p.videoToPixelsSync(videoFile);
//^ array of raw buffers, one buffer for each frame


// similar but uses mjpeg vcodec [slower]
// v2p.videoToPixelsJPG(videoFile, function(frameData,width,height){
//     //frameData for mjpg is already uint8 array [r,g,b,a,r,g,b,a...]
// }, function(){
//     console.log('done');
// })
```

## Example - play video in terminal 

```javascript
var v2p = require('video-to-pixels');
var adi = require('ascii-data-image');

//https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4
var videoFile = './Big_Buck_Bunny_360_10s_1MB.mp4'

v2p.videoToPixels(videoFile, function(frameData,width,height){
    //frameData -- <Buffer 51 50 37 ff 4e 4d 34 ff 4d 4b 35 ff 4d 4b 35 ff 4e 4c 3 ...

    //reduce video frame by factor of 16:
    var scaleDown = 16;
    var scaledDownData = v2p.scaleDownByN(scaleDown, frameData, width, height);

    //print to console with ascii-data-image
    var imgStrAscii = adi.buffer2Img(scaledDownData, width/scaleDown);
    adi.writeSelfOverwrite(imgStrAscii);
}, function(){
    console.log('done');
})
```

![terminal video frame](https://i.imgur.com/AdpUg19.png)

## See Also

- [pixels-to-video](https://www.npmjs.com/package/pixels-to-video) - the opposite of this tool, converts raw pixels into videos


<br/><br/>

[![stonks](https://i.imgur.com/UpDxbfe.png)](https://www.npmjs.com/~stonkpunk)

---
_Source: https://npm.io/package/video-to-pixels · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
