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

ffmpeg-cut

v0.1.3-beta.1

Published

An npm package which supports parsing `ffmpeg`'s streams output and generates `ffmpeg` config for cutting video.

Downloads

5

Readme

ffmpeg-cut - Cut online video made easy

An npm package which supports parsing ffmpeg's streams output and generates ffmpeg config for cutting video.

Useful for those who want to cut a part of online video (auto hardsub by stream selector) without downloading the whole one.

Note: This is in development. See TODO below.

Install

npm install ffmpeg-cut

Usage

Parse and print streams info

Required ffmpeg on your PATH

# online url
ffmpeg-cut http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4

# pipe from ffmpeg's output
ffmpeg -i 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4' 2>&1 | ffmpeg-cut

# local file
ffmpeg-cut './X-Men.Apocalypse.2016.UHD.BluRay.2160p.10bit.HDR.2Audio.DTS-HD.MA.7.1.x265-beAst.mkv'

Print as JSON format

By default, ffmpeg-cut will print output as a JSON-like format. If you want to get output as a real JSON, speicify --format json argument.

ffmpeg-cut --format json http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
Pipe to jq
ffmpeg-cut --format json http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 | jq .

Output

# Executing: ffmpeg -i "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
{
  "streams": [
    {
      "type": "Audio",
      "index": "0:0",
      "raw": "Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)",
      "stream_index": 0,
      "defaults": true,
      "forced": false,
      "codec": "aac"
    },
    {
      "type": "Video",
      "index": "0:1",
      "raw": "Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1991 kb/s, 24 fps, 24 tbr, 24k tbn (default)",
      "stream_index": 0,
      "defaults": true,
      "forced": false,
      "codec": "h264"
    }
  ],
  "duration": "00:09:56.47",
  "bitrate": "2119",
  "bitrate_unit": "kb/s"
}

Sample output

{
  "streams": [
    {
      "type": "Video",
      "index": "0:0",
      "lang": "eng",
      "raw": "Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x1600, SAR 1:1 DAR 12:5, 23.98 fps, 23.98 tbr, 1k tbn (default)",
      "stream_index": 0,
      "defaults": true,
      "forced": false,
      "codec": "hevc"
    },
    {
      "type": "Audio",
      "index": "0:1",
      "lang": "eng",
      "raw": "Stream #0:1(eng): Audio: truehd, 48000 Hz, 7.1, s32 (24 bit) (default)",
      "stream_index": 0,
      "defaults": true,
      "forced": false,
      "codec": "truehd"
    },
    {
      "type": "Audio",
      "index": "0:2",
      "lang": "eng",
      "raw": "Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s",
      "stream_index": 1,
      "defaults": false,
      "forced": false,
      "codec": "ac3"
    },
    {
      "type": "Audio",
      "index": "0:3",
      "lang": "chi",
      "raw": "Stream #0:3(chi): Audio: truehd, 48000 Hz, 7.1, s32 (24 bit)",
      "stream_index": 2,
      "defaults": false,
      "forced": false,
      "codec": "truehd"
    },
    {
      "type": "Audio",
      "index": "0:4",
      "lang": "chi",
      "raw": "Stream #0:4(chi): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s",
      "stream_index": 3,
      "defaults": false,
      "forced": false,
      "codec": "ac3"
    },
    {
      "type": "Audio",
      "index": "0:5",
      "lang": "eng",
      "raw": "Stream #0:5(eng): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s",
      "stream_index": 4,
      "defaults": false,
      "forced": false,
      "codec": "ac3"
    },
    {
      "type": "Audio",
      "index": "0:6",
      "lang": "eng",
      "raw": "Stream #0:6(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s",
      "stream_index": 5,
      "defaults": false,
      "forced": false,
      "codec": "ac3"
    },
    {
      "type": "Subtitle",
      "index": "0:7",
      "lang": "eng",
      "raw": "Stream #0:7(eng): Subtitle: hdmv_pgs_subtitle",
      "stream_index": 0,
      "defaults": false,
      "forced": false,
      "codec": "hdmv_pgs_subtitle"
    },
    # ......
    # ......
    {
      "type": "Subtitle",
      "index": "0:20",
      "lang": "vie",
      "raw": "Stream #0:20(vie): Subtitle: subrip (default) (forced)",
      "stream_index": 13,
      "defaults": true,
      "forced": true,
      "codec": "subrip"
    },
    {
      "type": "Video",
      "index": "0:21",
      "raw": "Stream #0:21: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 1594x2362 [SAR 1:1 DAR 797:1181], 90k tbr, 90k tbn (attached pic)",
      "stream_index": 1,
      "defaults": false,
      "forced": false,
      "codec": "mjpeg" # Cover image
    }
  ],
  "duration": "02:23:58.30",
  "bitrate": "27982",
  "bitrate_unit": "kb/s"
}

TODO

  • [x] Parse ffmpeg output to JSON.
  • [ ] Parse more info like audio channel, audio bitrate, ...
  • [ ] Generate cut configuration from user's selector.
  • [ ] Handle errors.
  • [ ] Support youtube links with youtube-dl/yt-dlp.

LICENSE

New BSD License

© Ninh Pham