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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mtn-thumbnailer

v1.1.0

Published

Node.js wrapper for Movie Thumbnailer (mtn) - Generate video thumbnails and contact sheets

Downloads

188

Readme

mtn-thumbnailer

Node.js wrapper untuk Movie Thumbnailer (mtn) - generate video thumbnails dan contact sheets dengan mudah.

Fitur

  • ✅ TypeScript support
  • ✅ Promise-based API
  • ✅ Progress callbacks
  • ✅ Batch processing
  • ✅ Video metadata extraction
  • ✅ Full mtn options support
  • ✅ Cross-platform (Linux, macOS, Windows)

Instalasi

Prerequisites

Pastikan mtn sudah terinstall di sistem Anda:

# Ubuntu/Debian
sudo apt-get install mtn

# Atau build dari source
cd /path/to/mtn
cd src && make && sudo make install

Install Package

npm install mtn-thumbnailer

Quick Start

import { MtnThumbnailer } from 'mtn-thumbnailer';

// Create instance
const mtn = new MtnThumbnailer();

// Generate thumbnail
const result = await mtn.generateThumbnail('video.mp4', {
  columns: 3,
  rows: 2,
  minHeight: 200,
});

console.log(`Thumbnail saved to: ${result.outputPath}`);

Usage

Basic Example

import { MtnThumbnailer } from 'mtn-thumbnailer';

async function main() {
  const mtn = new MtnThumbnailer();
  
  // Check availability
  const available = await mtn.checkAvailability();
  if (!available) {
    console.error('mtn not found!');
    return;
  }
  
  // Generate with defaults
  const result = await mtn.generateThumbnail('movie.mp4');
  
  if (result.success) {
    console.log('✓ Generated:', result.outputPath);
  }
}

main();

Advanced Options

import { MtnThumbnailer } from 'mtn-thumbnailer';

const mtn = new MtnThumbnailer();

const result = await mtn.generateThumbnail('movie.mp4', {
  // Grid layout
  columns: 4,
  rows: 3,
  gap: 10,
  
  // Output
  outputSuffix: '_preview.jpg',
  jpegQuality: 95,
  
  // Appearance
  minHeight: 200,
  backgroundColor: '000000',
  showInfo: true,
  showTimestamp: true,
  
  // Detection
  edgeDetection: 6,
  blankThreshold: 0.8,
  
  // Timing
  skipBeginning: 30,
  skipEnd: 30,
  
  // Custom title
  additionalText: 'My Video Preview',
  
  // Advanced
  shadow: 5,
  extractCover: true,
  verbose: true,
});

Progress Callback

const result = await mtn.generateThumbnail(
  'movie.mp4',
  { columns: 3, rows: 2 },
  (progress) => {
    console.log(`Progress: ${progress.percentage.toFixed(0)}%`);
    console.log(`Current shot: ${progress.currentShot}`);
    if (progress.currentTime) {
      console.log(`Time: ${progress.currentTime.toFixed(1)}s`);
    }
  }
);

Batch Processing

import { MtnThumbnailer } from 'mtn-thumbnailer';

const mtn = new MtnThumbnailer();

const videos = [
  'video1.mp4',
  'video2.mp4',
  'video3.mp4',
];

const results = await mtn.generateThumbnails(
  videos,
  { columns: 3, outputDir: './thumbnails' },
  (videoPath, progress) => {
    console.log(`Processing ${videoPath}: ${progress.percentage}%`);
  }
);

// Summary
const successCount = results.filter(r => r.success).length;
console.log(`Success: ${successCount}/${results.length}`);

Get Video Metadata

const metadata = await mtn.getVideoMetadata('movie.mp4');

console.log('Duration:', metadata.duration, 'seconds');
console.log('Resolution:', metadata.width, 'x', metadata.height);
console.log('Codec:', metadata.codec);
console.log('FPS:', metadata.frameRate);

API Reference

Class: MtnThumbnailer

Constructor

new MtnThumbnailer(mtnPath?: string)
  • mtnPath - Optional path to mtn binary (auto-detected if not specified)

Methods

generateThumbnail(videoPath, options?, onProgress?)

Generate thumbnail for a single video.

async generateThumbnail(
  videoPath: string,
  options?: MtnOptions,
  onProgress?: (progress: MtnProgress) => void
): Promise<MtnResult>
generateThumbnails(videoPaths, options?, onProgress?)

Generate thumbnails for multiple videos.

async generateThumbnails(
  videoPaths: string[],
  options?: MtnOptions,
  onProgress?: (path: string, progress: MtnProgress) => void
): Promise<MtnResult[]>
getVideoMetadata(videoPath)

Extract video metadata.

async getVideoMetadata(videoPath: string): Promise<VideoMetadata>
checkAvailability()

Check if mtn binary is available.

async checkAvailability(): Promise<boolean>
getVersion()

Get mtn version string.

async getVersion(): Promise<string>

Options (MtnOptions)

| Option | Type | Default | Description | |--------|------|---------|-------------| | columns | number | 3 | Number of columns | | rows | number | 0 (auto) | Number of rows | | step | number | 120 | Time step in seconds | | minHeight | number | 150 | Minimum height in pixels | | width | number | 1024 | Output width (0 = auto) | | gap | number | 0 | Gap between shots | | outputDir | string | - | Output directory | | outputSuffix | string | _s.jpg | Output filename suffix | | jpegQuality | number | 90 | JPEG quality (1-100) | | backgroundColor | string | FFFFFF | Background color (hex) | | font | string | - | Font file path | | edgeDetection | number | 0 | Edge detection level | | blankThreshold | number | 0.8 | Blank frame threshold | | skipBeginning | number | 0 | Skip seconds at start | | skipEnd | number | 0 | Skip seconds at end | | showInfo | boolean | true | Show metadata info | | showTimestamp | boolean | true | Show timestamps | | verbose | boolean | false | Verbose output | | shadow | number/true | false | Shadow radius | | extractCover | boolean | false | Extract album art | | filters | string | - | FFmpeg filter chain |

Result (MtnResult)

interface MtnResult {
  success: boolean;
  outputPath?: string;
  infoPath?: string;
  coverPath?: string;
  executionTime: number;
  output: string;
  error?: string;
  exitCode: number;
}

Progress (MtnProgress)

interface MtnProgress {
  currentShot: number;
  totalShots: number;
  percentage: number;
  currentTime?: number;
  duration?: number;
}

Metadata (VideoMetadata)

interface VideoMetadata {
  duration?: number;      // seconds
  width?: number;         // pixels
  height?: number;        // pixels
  codec?: string;
  audioCodec?: string;
  frameRate?: number;
  bitrate?: number;       // kb/s
  size?: number;          // bytes
}

Examples

Lihat folder examples/ untuk contoh lengkap:

Development

# Install dependencies
npm install

# Build
npm run build

# Test
npm test

# Lint
npm run lint

License

GPL-2.0 (same as mtn)

Links