The Node Version of the Recently Popular Sorry GIF Maker
Author: Li Pinghai
The Node.js version of the recently popular sorry GIF maker, inspired by Xuty’s original Ruby version. This document also references the original documentation.
Feel free to open an issue if you have any questions, and please star the project if you like it. Thank you!
Project Description
- The server uses Koa and fluent-ffmpeg, with subtitles and GIFs stored in the cache directory.
- The API follows RESTful conventions.
- The pages are rendered with EJS, and the build script
build.js
generates the pages and resources in thedist
directory. - Project configuration is in
config.js
(remove or replace the analytics code for deployment).
Source Code Structure
├── package
├── package.lock
├── common # Utilities
├── server # Node.js source code
├── view # Page source code
├── template # GIF templates
├── config.js # Configuration
├── build.js # Page build script
├── README.md
└── cache # GIF and subtitle cache
Other Versions
- Original Ruby version by @Xuty
- Python version by @East196
- Java version by @li24361
- C# ASP.NET version by @shuangrain
- WeChat Mini Program by @CoXier
API
To create a GIF:
POST {host}/api/{template_name}/
{
subtitle:['OK',.....]
}
# Returns the GIF's hash
-> 200
{
status: 200,
data: 'c2f4069ed207dc38e0f2d9359a2fa6b7'
}
To get the GIF:
GET {host}/api/{template_name}/{gif_hash}
Currently supported template names are:
- sorry
- wangjingze
Deployment Guide
Installation
npm i
@ffmpeg-installer/ffmpeg
may fail to install; try running npm i
a few more times.
Build the Pages
npm run build
Deployment
For local development, use npm run server
.
For online deployment, it’s recommended to use pm2
for management. First install it with npm i pm2 -g
, then start the project with pm2 start server/index.js
.
Creating Subtitle Templates (template.ass)
First, use Aegisub to create subtitles for the template video and save them as template.ass
. (You can refer to this Aegisub tutorial.)
Then replace the text with the template string <%= sentences[n] %>
.