nicoize
v0.1.0
Published
Add NicoNico-style scrolling comments (text + emotes) onto a video using FFmpeg.
Readme
nicoize
Add NicoNico-style scrolling comments (text + emotes) onto a video using FFmpeg.
Install
Requires FFmpeg/FFprobe in PATH and Node.js >= 18.
npm install nicoizeUsage (API)
import { nicoize, type NicoizeData } from "nicoize";
const data: NicoizeData = {
chats: [
/* ... */
],
};
await nicoize({
data,
videoPath: "input.mp4",
outputPath: "output.mp4",
fontFile: "NotoSansJP.ttf",
});options:
fontFile(required): path to a font that supports Japanese glyphs.fontSizeRatio(default 0.08): font size relative to video height.scrollDurationSeconds(default 4): seconds from first appearance to fully off-screen. Longer text moves faster to meet this duration.fontColor(default white): font color.strokeColor(default black): stroke color.safeAreaRatio(default 0.05): top/bottom margin ratio.videoCodec(default libx264):crf(20),preset(veryfast).suppressFfmpegOutput(default true): hide FFmpeg logs.onLog: callback to receive FFmpeg stderr lines.
Usage (CLI)
npx nicoize --chat sample.json --video input.mp4 --font-file NotoSansJP.ttf --output output.mp4 --overwrite- Required flags:
--chat,--video,--font-file - Optional:
--output,--font-size-ratio,--duration,--font-color,--stroke-color,--safe-area-ratio,--codec,--crf,--preset,--overwrite,--ffmpeg-verbose.
Sample chat data
{
"chats": [
{
"offsetSeconds": 3,
"fragments": [
{
"type": "text",
"text": "Nice to meet you!"
}
]
},
{
"offsetSeconds": 8,
"fragments": [
{
"type": "emote",
"url": "https://example.com/emote.png"
},
{
"type": "text",
"text": "here we go"
}
]
}
]
}Emotes can be static images or animated GIFs.
License
ISC
