Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"meow": "^10.1.3",
"nanoid": "^5.0.7",
"ndarray": "^1.0.19",
"p-map": "^7.0.2"
"p-map": "^7.0.2",
"yaml": "^2.7.1"
},
"scripts": {
"build": "pkgroll --clean-dist --sourcemap",
Expand Down
20 changes: 17 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import assert from "assert";
import { fileTypeFromFile } from "file-type";
import { readFileSync } from "fs";
import JSON5 from "json5";
import YAML from "yaml";
import meow from "meow";
import pMap from "p-map";
import { ConfigurationOptions } from "./configuration.js";
Expand All @@ -22,9 +23,14 @@ const cli = meow(
$ editly --json JSON_PATH
where JSON_PATH is the path to an edit spec JSON file, can be a normal JSON or JSON5

Or alternatively:
$ editly --yaml YAML_PATH
where YAML_PATH is the path to an edit spec YAML file

Options
--out Out video path (defaults to ./editly-out.mp4) - can also be a .gif
--json Use JSON edit spec
--yaml Use YAML edit spec
--transition-name Name of default transition to use (default: random)
--transition-duration Default transition duration
--clip-duration Default clip duration
Expand All @@ -47,6 +53,7 @@ const cli = meow(
Examples
$ editly title:'My video' clip1.mov clip2.mov title:'My slideshow' img1.jpg img2.jpg title:'THE END' --audio-file-path /path/to/music.mp3 --font-path /path/to/my-favorite-font.ttf
$ editly my-editly.json5 --out output.gif
$ editly my-editly.yaml --out output.gif
`,
{
importMeta: import.meta,
Expand All @@ -65,23 +72,30 @@ const cli = meow(
loopAudio: { type: "boolean" },
outputVolume: { type: "string" },
json: { type: "string" },
yaml: { type: "string" },
out: { type: "string" },
audioFilePath: { type: "string" },
},
},
);

(async () => {
let { json } = cli.flags;
if (cli.input.length === 1 && /\.(json|json5|js)$/.test(cli.input[0].toLowerCase()))
json = cli.input[0];
let { json, yaml } = cli.flags;
if (cli.input.length === 1) {
if (/\.(json|json5|js)$/.test(cli.input[0].toLowerCase()))
json = cli.input[0];
else if (/\.(yml|yaml)$/.test(cli.input[0].toLowerCase()))
yaml = cli.input[0];
}

let params: Partial<ConfigurationOptions> = {
defaults: {},
};

if (json) {
params = JSON5.parse(readFileSync(json, "utf-8"));
} else if (yaml) {
params = YAML.parse(readFileSync(yaml, "utf-8"));
} else {
const clipsIn = cli.input;
if (clipsIn.length < 1) cli.showHelp();
Expand Down