npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libqrv

v0.1.0

Published

Library For QR Encoding Information in an Video Stream

Downloads

4

Readme

libqrv

libqrv is a node module that is used to encode data into video streams. Specifically it does this by transforming data into QR codes, and stitching the multiple frames together into a single video file.

Example

By running the yarn.lock file in the examples directory through convertFile, the video below is produced.

yarn.lock example qr code video

Installation

$ yarn install libqrv

Basic Usage

convertFile

convertFile( existingFile [, newFilePath] , cb )

Converts a file into a mp4 video stream of QR codes that contain the base64 encoded data. If newFilePath is not specified .mp4 is added to the file path passed in.

const { convertFile } = require( "libqrv" );

convertFile( "./some/file.txt", "./another/location/output.mp4", ( err ) => {

	// err is null unless there is an error
	if( err ){
		return console.log( "Couldn't convert the file.. " + err );
	}

	// "./another/location/output.mp4" exists
} );
const { convertFile } = require( "libqrv" );

convertFile( "./some/file.txt", ( err ) => {

	if( err ){
		return console.log( "Couldn't convert the file.. " + err );
	}

	// if err is not null, and no newFIlePath has been specified
	// existingFile + ".mp4" is assumed.

	// "./some/file.txt.mp4" exists
	
} );

Directly Using the Library

The LibQRV library itself provides some customization. There are a lot of opportunities that exist to expose more configuration, and functionality.

Usage

const { LibQRV } = require( "libqrv" );

const config = {
	debug: true
};

new LibQRV( config, ( err, libqrv ) => {

	// libqrv can be used here

	libqrv.on( "readableStreamComplete", ( details ) => {
		/*
		details = {
			filename: "yarn.lock",
			outputPath: "/var/folders/qr/z123...../T/tmp-..../yarn.lock.mp4"
		}
		*/


		// Let's ensure that we clean up any resources
		libqrv.destroy( ( err ) => {
			if( err ){
				console.log( "Couldn't clean up resources: " + err );
				return;
			}
			console.log( "Cleaned up resources. Goodbye." );
		} );
	} );

	libqrv.queueReadableStream( fs.createReadStream( "./yarn.lock" ), ( err ) => {
		if( err ){
			console.log( "Couldn't queue readable stream: " + err );
			return;
		}

		// Readable stream has been queued.

		// When complete "readableStreamComplete" will be emitted.
	} );
} );

Default Options

{
  "debug": false,
  "outputDirectory": "/tmp/tmp-34.........", // geneated by tmp
  "qr": {
    "width": 240,
    "scale": 1,
    "margin": 0,
    "errorCorrectionLevel": "low"
  },
  "video": {
    "output": {
      "framerate": 25
    },
    "input": {
      "framerate": 1
    }
  }
}

Options to constructor

| Option Name | Default Value | Description | | ------------------ | ------------- | ----------- | | outputDirectory | Dynamically Generated ( uses tmp ) | The directory where the output .mp4 will be placed. | | debug | false | Whether or not to emit debug events | | qr | See QR Options | Configuration that relates to QR Code generation | | video | See Video Options | Configuration that relates to the video generation |

QR Options

| Option Name | Default Value | Description | | ------------------ | ------------- | ----------- | | width | 240 | The width of the QR code frame that is generated | | scale | 1 | The number of pixels that are used per "block" to make up the QR code | | margin | 0 | The amount of blank space that is kept around the QR code. Synonymous with HTML padding | | errorCorrectionLevel | "low" | How much error correction is used in the QR code. |

Video Options

| Option Name | Default Value | Description | | ------------------ | ------------- | ----------- | | input.framerate | 1 | The framerate relating to the QR code images. Per second | | output.framerate | 25 | The output .mp4 video framerate. Per second |

Constructor LibQRV uses a configuration object that is passed into the constructor. Additionally, the constructor takes a callback that is called with cb( err, instance ) where err should be null, and instance is the newly created instance of LibQRV.

Help Wanted

If you find this module or repository useful, please consider making a pull request to it.

Running tests

$ yarn run test

yarn run v1.3.2
$ ./node_modules/mocha/bin/mocha -t 60000


  Base
    ✓ LibQRV is a function
    Validations
      ✓ Fails if an invalid config is passed in
    Basic operation
      ✓ Constructor returns sane object in callback
      ✓ Emits a 'readableStreamComplete' event when finished encoding a readable stream. (8492ms)
    convertFile operation
      ✓ Works when we specify a filename (10250ms)
      ✓ Works when we don't specify a filename (8534ms)


  6 passing (27s)

✨  Done in 28.27s.

License

MIT