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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mi-parser

v0.1.1

Published

A CLI tool to parse MediaInfo output

Readme

MediaInfo Parser

A TypeScript library and CLI tool to parse MediaInfo output from text files and display the information in various formats.

Features

  • Parse MediaInfo text output into structured data
  • Multiple output formats: formatted text, YAML, or summary view
  • Support for all MediaInfo tracks: General, Video, Audio, Text/Subtitles, and Chapters
  • YAML output option for structured data
  • Human-readable formatting for file sizes, durations, and bitrates
  • Standalone library - use the parser in your own projects

Library Usage

Installation

# npm
npm install mi-parser

# pnpm  
pnpm add mi-parser

# yarn
yarn add mi-parser

Basic Usage

import { parseMediaInfo } from 'mi-parser';

const mediaInfoText = `
General
Complete name                            : /path/to/video.mp4
Format                                   : MPEG-4
File size                                : 1.50 GiB
Duration                                 : 1 h 45 min 30 s

Video
Format                                   : AVC
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Frame rate                               : 23.976 FPS
`;

const result = parseMediaInfo(mediaInfoText);

console.log(result.general.completeName); // "/path/to/video.mp4"
console.log(result.general.fileSize);     // 1610612736 (bytes)
console.log(result.video[0].width);       // 1920
console.log(result.video[0].height);      // 1080

TypeScript Interfaces

import { MediaInfo, GeneralTrack, VideoTrack, AudioTrack, TextTrack, Chapter } from 'mi-parser';

// All interfaces are fully typed for excellent IDE support
const mediaInfo: MediaInfo = parseMediaInfo(text);

Available Types

  • MediaInfo - Main interface containing all tracks
  • GeneralTrack - File metadata and general information
  • VideoTrack - Video stream information
  • AudioTrack - Audio stream information
  • TextTrack - Subtitle/text stream information
  • Chapter - Chapter/menu information

CLI Usage

Installation

  1. Install dependencies:
pnpm install
  1. Build the project:
pnpm run build

Basic usage:

pnpm start <mediainfo-file.txt>

Using development mode (no build required):

pnpm run dev <mediainfo-file.txt>

Command line options:

  • --yaml or -y: Output as YAML
  • --output <file> or -o <file>: Output to file (only works with --yaml)
  • --summary or -s: Show only summary information
  • --help: Show help information

Examples:

# Display formatted output
pnpm start sample.txt

# Show summary only
pnpm start sample.txt --summary

# Output as YAML to console
pnpm start sample.txt --yaml

# Output as YAML to file
pnpm start sample.txt --yaml --output mediainfo.yaml

Sample MediaInfo Output

To test the parser, create a text file with MediaInfo output like this:

General
Unique ID                                : 12345
Complete name                            : /path/to/video.mp4
Format                                   : MPEG-4
File size                                : 1.50 GiB
Duration                                 : 1 h 45 min 30 s

Video
ID                                       : 1
Format                                   : AVC
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Frame rate                               : 23.976 FPS

Audio
ID                                       : 2
Format                                   : AAC
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz

Development

  • pnpm run dev <file>: Run CLI in development mode with tsx
  • pnpm run build: Compile TypeScript to JavaScript
  • pnpm run test: Build and run the compiled version

Publishing

This project uses GitHub Actions for automated releases:

Setup

  1. Add NPM_TOKEN to your GitHub repository secrets:
    • Go to npmjs.com → Account → Access Tokens
    • Create an "Automation" token
    • Add it as NPM_TOKEN in your GitHub repo settings → Secrets

Release Process

  1. Update CHANGELOG.md with new version details
  2. Commit changes: git commit -am "Release v1.x.x"
  3. Create and push a version tag: git tag v1.x.x && git push origin v1.x.x
  4. GitHub Actions will automatically:
    • Run tests on multiple Node.js versions
    • Build the project
    • Create a GitHub release with changelog notes
    • Publish to npm registry
    • Publish to GitHub Package Registry

Manual Publishing

pnpm run build
pnpm publish --access public

Project Structure

  • mediainfo.ts: Core parser library - use this in your projects
  • main.ts: CLI interface and formatting logic
  • package.json: Project configuration and dependencies
  • tsconfig.json: TypeScript compilation settings

Parsed Data Format

The parser converts MediaInfo text into structured objects with proper TypeScript typing:

  • File sizes are converted to bytes (number)
  • Durations are converted to milliseconds (number)
  • Bit rates are converted to bits per second (number)
  • Sampling rates are converted to Hz (number)
  • Dates are converted to Date objects
  • Boolean flags (Default/Forced) are converted to boolean values