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

light-ffmpeg-trans

v1.1.5

Published

Concats a list of videos together using ffmpeg with sexy OpenGL transitions. fork from ffmpeg-concat

Downloads

19

Readme

light-ffmpeg-trans

拼接 一组视频.,通过使用 ffmpeg和 性感的 OpenGL 过渡 (动画效果)

9个视频 与 独特过渡 连接在一起的示例

请注意,由于GIF预览,质量和fps很差;这个是源文件

介绍

FFmpeg是命令行视频编辑中的事实标准,但使用 非平凡过渡 将视频连接在一起真的很困难. 这里有一些错综复杂 的例子两个视频之间的简单交叉淡入淡出. FFmpeg过滤图非常强大,但是为了实现过渡动画,它们太复杂且容易出错.

另一方面,GL Transitions,是一个伟大的开源由Gaëtan Renaudeau倡议,旨在使用 GLSL 建立一个普遍的过渡集合,它非常简单的规范使得定制现有过渡或编写自己的过渡非常容易,而不是使用复杂的ffmpeg过滤图.

使用 gl-transitions 这个模块和CLI轻松地将视频连接在一起.

安装

这个模块需要ffmpeg要安装.

npm install --save light-ffmpeg-trans

# 或者 想使用 cli
npm install -g light-ffmpeg-trans

CLI

  Usage: light-ffmpeg-trans [options] <videos...>

  Options:

    -V, --version                         输出版本号
    -o, --output <output>                 要写入的mp4文件的路径(默认值:out.mp4)
    -t, --transition-name <name>          要使用的gl-transition名称(默认值:淡入淡出)
    -d, --transition-duration <duration>  转换持续时间以毫秒为单位(默认值:500)
    -T, --transitions <file>              json文件加载转换
    -f, --frame-format <format>           用于临时帧图像的格式(默认值:raw)
    -c, --concurrency <number>            要并行处理的视频数量(默认值:4)
    -C, --no-cleanup-frames               禁用清除临时帧图像
    -O, --temp-dir <dir>                  用于存储帧数据的临时工作目录
    -h, --help                            输出使用信息

  Example:

    light-ffmpeg-trans -t circleopen -d 750 -o huzzah.mp4 0.mp4 1.mp4 2.mp4

用法

const concat = require('light-ffmpeg-trans')

// 拼接 3 个 mp4s 使用 2  个 500ms directionalWipe 过渡
await concat({
  output: 'test.mp4',
  videos: [
    'media/0.mp4',
    'media/1.mp4',
    'media/2.mp4'
  ],
  transition: {
    name: 'directionalWipe',
    duration: 500
  }
})
// 拼接 5 个 mp4 使用 4种不同的过渡
await concat({
  output: 'test.mp4',
  videos: [
    'media/0.mp4',
    'media/1.mp4',
    'media/2.mp4',
    'media/0.mp4',
    'media/1.mp4'
  ],
  transitions: [
    {
      name: 'circleOpen',
      duration: 1000
    },
    {
      name: 'crossWarp',
      duration: 800
    },
    {
      name: 'directionalWarp',
      duration: 500,
      // 将自定义参数传递给转换
      params: { direction: [ 1, -1 ] }
    },
    {
      name: 'squaresWire',
      duration: 2000
    }
  ]
})

API

concat(options)

将 视频文件 与 OpenGL过渡 连接在一起. 返回一个Promise用于输出视频的时间.

请注意,您必须指定videos,output,或者transition要么transitions.

请注意,输出视频的大小 和 fps 由 第一个输入视频决定.

options

videos

类型: Array<String> 必需

要连接的视频数组,其中每个 item 都是视频文件的路径或URL.

output

类型: String 必需

输出的mp4视频文件路径.

注意: 我们目前只支持输出到mp4;如果您希望获得更多格式的支持,请打开一个问题.

transition

类型: Object

指定在每个视频之间使用的默认过渡.

请注意,您必须指定其中一个transition要么transitions,取决于您对每次过渡的控制程度. 如果同时指定,transitions优先.

// 例
const transition = {
  duration: 1000, // ms
  name: 'directionalwipe', // 要使用的 gl-transition名称(小写匹配)
  params: { direction: [1, -1] } // 可选地覆盖默认参数
}
transitions

类型: Array<Object>

指定每个视频之间的 (可能唯一的) 过渡. 如果有N个视频,则应该有N-1个过渡.

请注意,您必须指定其中一个transition要么transitions,取决于您对每次过渡的控制程度. 如果同时指定,transitions优先.

// 例
const transitions = [
  {
    duration: 1000,
    name: 'fade'
  },
  {
    duration: 500,
    name: 'swap'
  }
]
audio

类型: String 必需

音频文件的路径或URL,用作 输出视频 的音轨.

frameFormat

类型: string默认: raw

临时帧图像的格式. 例如,您可以使用png要么jpg.

注意: 出于性能原因默认为raw,写入和读取 原始二进制像素数据 比 编码和解码png帧快得多. 原始格式很难预览和调试,在另一种情况下,您可能想要更改frameFormatpng.

concurrency

类型: Number默认: 4

要并行处理的最大视频数量.

log

类型: Function默认: noop

用于记录进度和底层ffmpeg命令的可选功能. 例如,您可以使用console.log

cleanupFrames

类型: boolean默认: true

默认情况下,我们清理临时帧图像. 如果你需要调试中间结果,将此设置为false.

tempDir

类型: string默认值: /tmp下的随机目录

用于存储中间帧数据的临时工作目录. 这是cleanupFrames时,帧被保存的位置.

过渡

这里有一些gl-transitions我发现对高质量的视频过渡 特别有用:

有关