Skip to content

Commit cfdc276

Browse files
committed
[Project] Released v0.1.1
1 parent c9b1d56 commit cfdc276

File tree

10 files changed

+2168
-1355
lines changed

10 files changed

+2168
-1355
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
parserOptions: {
77
project: './tsconfig.json',
88
},
9-
plugins: ['@typescript-eslint'],
9+
plugins: ['@typescript-eslint', 'prettier'],
1010
extends: ['plugin:prettier/recommended', 'eslint:recommended', 'plugin:@typescript-eslint/recommended'],
1111
rules: {
1212
'@typescript-eslint/dot-notation': 'error',

.github/workflows/.ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ jobs:
5757
# - name: Publish
5858
# run: npm publish
5959
# env:
60-
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
60+
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.lintstagedrc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"*.{ts,json,md,yml}": ["prettier --write"],
3-
"*.{ts}": [
4-
"pnpm lint",
5-
"pnpm test"
6-
]
2+
"*.{ts,json,md,yml}": ["prettier --write"],
3+
"*.{ts}": ["pnpm lint", "pnpm test"]
74
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Alexandre Mogère
3+
Copyright (c) 2024 Alexandre Mogère
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 88 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FFmpeg Template Assembly
22

3-
`ffmpeg-template-assembly` is a powerful tool designed to streamline the process of video compilation using FFmpeg. It allows for dynamic template generation and video rendering, making it an ideal solution for creating personalized videos programmatically.
3+
`ffmpeg-template-assembly` is a tool designed to streamline the process of video compilation using FFmpeg. It allows for dynamic template generation and video rendering, making it an ideal solution for creating personalized videos programmatically.
44

55
## Description
66

@@ -16,6 +16,16 @@ Ensure you have the following prerequisites installed:
1616

1717
### Installing
1818

19+
#### NPM
20+
21+
Install the project dependencies using npm, yarn or [pnpm](https://pnpm.io/):
22+
23+
```bash
24+
pnpm add ffmpeg-template-assembly
25+
```
26+
27+
#### Clone Repository
28+
1929
Clone the repository and install the dependencies:
2030

2131
```bash
@@ -26,7 +36,7 @@ pnpm i
2636

2737
### Configuration
2838

29-
Create a JSON file (e.g., `sample.json`) in the `src/shared/templates` directory with your template descriptor.
39+
Create a JSON file (e.g., `sample.json` in the `src/shared/templates` directory) with your template descriptor.
3040

3141
### Usage
3242

@@ -40,93 +50,112 @@ pnpm compile src/shared/templates/sample.json
4050

4151
This will generate a video named `sample_output.mp4` in the `build` directory.
4252

43-
#### Compilation Function
53+
#### Importing the Package
4454

4555
Import the `compile` function from the package and provide a project configuration object:
4656

4757
```javascript
48-
import { compile } from 'ffmpeg-template-assembly';
58+
import { compile, loadConfig } from 'ffmpeg-template-assembly';
4959

5060
// Project Configuration
51-
const projectConfig: ProjectConfig = {
52-
assetsDir: './src/shared/assets',
61+
const projectConfig = {
62+
assetsDir: './assets',
5363
currentLocale: 'en',
5464
fields: {
5565
form_1_firstname: 'Firsname',
5666
form_1_lastname: 'Lastname',
57-
form_1_job: 'Developer',
58-
form_2_keyword1: 'One',
59-
form_2_keyword2: 'Two',
60-
form_2_keyword3: 'Three',
6167
},
6268
};
6369
```
6470

6571
You might provide a template descriptor to the `compile` function to generate a video:
6672

6773
```javascript
68-
const templateDescriptor = {
69-
"global": {
70-
"variables": {
71-
"videoDemo": "https://github.com/heristop/ffmpeg-template-assembly/raw/develop/src/shared/assets/videos/earth.mp4",
72-
"colorsList": ["#FFFFFF","#000000"]
74+
compile(projectConfig, {
75+
global: {
76+
variables: {
77+
videoDemo: 'https://github.com/heristop/ffmpeg-template-assembly/raw/develop/src/shared/assets/videos/earth.mp4',
78+
colorsList: ['#FFFFFF', '#000000'],
79+
},
80+
music: {
81+
name: 'default',
82+
url: 'https://github.com/heristop/ffmpeg-template-assembly/raw/develop/src/shared/assets/musics/point_being_-_go_by_ocean___ryan_mccaffrey.mp3',
7383
},
74-
"orientation": "landscape",
75-
"musicEnabled": true,
76-
"transitionDuration": 0.5
84+
orientation: 'landscape',
85+
musicEnabled: true,
86+
transitionDuration: 0.5,
7787
},
78-
"sections": [
88+
sections: [
7989
{
80-
"name": "readme_video",
81-
"type": "project_video",
82-
"visibility": ["video_segment"],
83-
"options": {
84-
"backgroundColor": "{{ color1 }}@0.1",
85-
"videoUrl": "{{ videoDemo }}",
86-
"duration": 0.5,
87-
"musicVolumeLevel": 0.4
90+
name: 'intertitle_1',
91+
type: 'color_background',
92+
visibility: ['video_segment'],
93+
options: {
94+
backgroundColor: '{{ color2 }}@0.1',
95+
videoUrl: '{{ videoDemo }}',
96+
duration: 3,
97+
musicVolumeLevel: 0.4,
8898
},
89-
"filters": [
99+
filters: [
90100
{
91-
"type": "drawbox",
92-
"values": {
93-
"x": 0,
94-
"y": 0,
95-
"w": 1280,
96-
"h": 360,
97-
"c": "{{ color2 }}@1",
98-
"t": "fill"
99-
}
101+
type: 'drawbox',
102+
values: {
103+
x: 0,
104+
y: 0,
105+
w: 1280,
106+
h: 360,
107+
c: '{{ color1 }}@1',
108+
t: 'fill',
109+
},
100110
},
101111
{
102-
"type": "drawtext",
103-
"values": {
104-
"text": {
105-
"en": "{{ form_1_firstname }} {{ form_1_lastname }}"
112+
type: 'drawtext',
113+
values: {
114+
text: {
115+
en: '{{ form_1_firstname }} {{ form_1_lastname }}',
106116
},
107-
"fontcolor": "#FFFFFF",
108-
"fontsize": 40,
109-
"x": "(w-text_w)/2",
110-
"y": "(h-text_h)/1.4",
111-
"fontfile": "Quicksand.ttf",
112-
"alpha": "'if(lt(t,0.5),0,if(lt(t,1.5),(t-0.5)/1,if(lt(t,5),1,if(lt(t,7),(1-(t-6))/1,0))))'"
113-
}
117+
fontcolor: '{{ color1 }}',
118+
fontsize: 40,
119+
x: '(w-text_w)/2',
120+
y: '(h-text_h)/1.4',
121+
fontfile: 'Quicksand.ttf',
122+
alpha: "'if(lt(t,0.5),0,if(lt(t,1.5),(t-0.5)/1,if(lt(t,5),1,if(lt(t,7),(1-(t-6))/1,0))))'",
123+
},
114124
},
115-
]
116-
}
117-
]
118-
};
119-
120-
121-
await compile(projectConfig, templateDescriptor);
125+
],
126+
},
127+
{
128+
name: 'video_1',
129+
type: 'video',
130+
visibility: ['video_segment'],
131+
options: {
132+
videoUrl: '{{ videoDemo }}',
133+
duration: 4,
134+
musicVolumeLevel: 1,
135+
},
136+
filters: [
137+
{
138+
type: 'fadein',
139+
values: {
140+
color: '{{ color2 }}',
141+
},
142+
},
143+
{
144+
type: 'fadeout',
145+
values: {
146+
color: '{{ color2 }}',
147+
},
148+
},
149+
],
150+
},
151+
],
152+
});
122153
```
123154

124155
Or you might provide a path to the template descriptor JSON file:
125156

126157
```javascript
127-
const templatePath = './src/shared/templates/sample.json';
128-
129-
await compile(projectConfig, templatePath);
158+
await compile(projectConfig, await loadConfig('./src/shared/templates/sample.json'));
130159
```
131160

132161
## Running Tests
@@ -139,7 +168,7 @@ pnpm test
139168

140169
## Architecture
141170

142-
[![Architecture](graph.svg)](graph.svg)
171+
[![Architecture](https://github.com/heristop/ffmpeg-template-assembly/blob/main/graph.svg)](https://github.com/heristop/ffmpeg-template-assembly/blob/main/graph.svg)
143172

144173
## Contributing
145174

package.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "ffmpeg-template-assembly",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
4+
"main": "./dist/index.cjs",
45
"module": "./dist/index.js",
5-
"types": "./dist/core/types.d.ts",
6+
"types": "./dist/index.d.ts",
67
"author": "heristop",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/heristop/ffmpeg-template-assembly.git"
11+
},
712
"license": "MIT",
813
"scripts": {
914
"compile": "ts-node-esm src/main.ts",
@@ -19,18 +24,30 @@
1924
"tsup": {
2025
"entry": [
2126
"src",
27+
"!src/main.ts",
2228
"!src/shared/assets/*",
2329
"!src/shared/assets/**/*"
2430
],
2531
"format": [
26-
"esm"
32+
"esm",
33+
"cjs"
2734
],
2835
"splitting": false,
29-
"sourcemap": false,
36+
"sourcemap": true,
3037
"dts": true,
31-
"clean": true
38+
"clean": true,
39+
"minify": false
3240
},
3341
"type": "module",
42+
"files": [
43+
"dist"
44+
],
45+
"keywords": [
46+
"ffmpeg",
47+
"video-processing",
48+
"video-editing",
49+
"ffmpeg-script"
50+
],
3451
"dependencies": {
3552
"axios": "^1.6.8",
3653
"extract-zip": "^2.0.1",

0 commit comments

Comments
 (0)