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

pdf2mp4

v1.0.0

Published

npm module that converts pdf to mp4

Downloads

16

Readme

pdf2mp4

Module that converts pdf files to MP4 in high resolution. Can be used for fast reading applications.

Required system dependencies:

multithreaded!

Installation

npm install pdf2mp4

Prerequisites

  • git
  • npm & node
  • ImageMagick & gm
  • ffmpeg

Setup

git clone https://github.com/irgipaulius/pdf2mp4

cd pdf2mp4

npm install

GraphicsMagick

Next, you must install ImageMagick and gm on your system:

  • Official instructions: https://github.com/yakovmeister/pdf2image/blob/HEAD/docs/gm-installation.md

  • OSX:

    • brew install graphicsmagick
    • brew install gs
    • brew install imagemagick
  • Windows, Linux - install manually:

  • Standalone - install from source:

    • https://www.imagemagick.org/script/install-source.php
    • https://www.github.com/aheckmann/gm.git

FFMPEG

  • OSX
    • brew install ffmpeg
  • Windows
    • Download installation executables from https://evermeet.cx/ffmpeg/.
    • add .env with FFMPEG_PATH=path/to/ffmpeg/executable
  • Linux
    • sudo apt install ffmpeg
  • FreeBSD
    • pkg install ffmpeg

Usage

import { pdf2mp4, createEventLogger } from "pdf2mp4";

const e = createEventLogger(); // optional, but great for debugging

await pdf2mp4(
  {
    fileName: "sample.pdf",
    secondsPerFrame: 2.15,
    uploadDir: "./",
    outputDir: "./",
  },
  e
);

Properties

| Property | type | default value | description | | --------------- | ---------------- | ------------------------- | ---------------------------------------------------------------------------------------------- | | fileName | mandatory string | | name of the pdf file. | | secondsPerFrame | optional number | | either this or framesPerSecond must be set. | | framesPerSecond | optional number | | either this or secondsPerFrame must be set. | | maxConcurrency | optional number | 8 | max concurrent frames to process at the same time. Directly affects performance and stability. | | uploadDir | optional string | "pdf2mp4/upload" | path to directory where pdf files are located | | tempDir | optional string | "pdf2mp4/generated/temp" | path to directory where temporary files will be generated | | outputDir | optional string | "pdf2mp4/generated/video" | path to directory where generated mp4 file is placed |

Events (optional)

For example, on front-end you can implement a full-fledged processing loading animation, which is accurate to the actual process:

const e = new EventEmitter();

e.on("start", (message, filename) => {
  console.log(message); // Converting sample.pdf...
});

e.on("benchmark_raster", (message, benchmarkSeconds) => {
  console.log(message); // `Finished rasterization in 6.9420 seconds.`
});

e.on("benchmark_render", (message, benchmarkSeconds) => {
  console.log(message); // `Finished render in 6.9420 seconds.`
});

e.on("progress_raster", (message, progress) => {
  console.log(message); // Rasterizing... 69/100
  setProgress(progress / 100); // great to use with states for react
});

e.on("progress_render", (message, progress) => {
  console.log(message); // Rendering... 69/100
  setProgress(progress / 100); // great to use with states for react
});

e.on("end", (message, videoFilename, videoDestination) => {
  console.log(message); // Finished converting sample.pdf to /usr/Johnny/.../pdf2mp4/Am83rH3ar0.mp4.
  resolve(videoDestination); // final location of the mp4 file.
});

// no need to await, result will be in the 'end' event
pdf2mp4("sample.pdf", { framesPerSecond: 0.33 }, e);

Notes

This is my first ever published npm package. Submit issues to the github repository for any extra features or questions.

There is also a fully developed website that uses this package at https://www.hyperreader.eu, and it's source code is here.