Browse Source

default to first video size

fixes #13
pull/22/head
Mikael Finstad 6 years ago
parent
commit
c6e20cc2de
  1. 9
      README.md
  2. 18
      index.js

9
README.md

@ -59,22 +59,23 @@ editly \
img1.jpg \ img1.jpg \
img2.jpg \ img2.jpg \
title:'THE END' \ title:'THE END' \
--fast \
--audio-file-path /path/to/music.mp3 --audio-file-path /path/to/music.mp3
``` ```
Or create an MP4 (or GIF) from a JSON or JSON5 edit spec *(JSON5 is just a more friendly JSON format)*: Or create an MP4 (or GIF) from a JSON or JSON5 edit spec *(JSON5 is just a more friendly JSON format)*:
```sh ```sh
editly my-editly.json5 --out output.gif
editly my-editly.json5 --fast --out output.gif
``` ```
For examples of how to make an JSON edit spec, see below or https://github.com/mifi/editly/tree/master/examples For examples of how to make an JSON edit spec, see below or https://github.com/mifi/editly/tree/master/examples
By default it will use the **width**, **height** and **frame rate** from the **first** input video. **all other clips will be converted to these dimensions** You can override these parameters however. If none are specified, it will use defaults.
When you run with `--fast` or `fast: true` it will render a much quicker low resolution preview ⏩
**TIP 1:** Run with `--fast` or `fast: true` first to improve speed while testing your edit ⏩
By default without `--fast` it will use the **width**, **height** and **frame rate** from the **first** input video. **all other clips will be converted to these dimensions.** You can of course override any or all of these parameters.
**TIP 2:** Use this tool in conjunction with [LosslessCut](https://github.com/mifi/lossless-cut)
**TIP:** Use this tool in conjunction with [LosslessCut](https://github.com/mifi/lossless-cut)
## Javascript library ## Javascript library

18
index.js

@ -198,16 +198,24 @@ module.exports = async (config = {}) => {
if (fast) desiredWidth = 320; if (fast) desiredWidth = 320;
else if (requestedWidth) desiredWidth = requestedWidth; else if (requestedWidth) desiredWidth = requestedWidth;
else if (isGif) desiredWidth = 320; else if (isGif) desiredWidth = 320;
else desiredWidth = 640;
if (detectedWidth && detectedHeight) { if (detectedWidth && detectedHeight) {
const calculatedHeight = Math.round((detectedHeight / detectedWidth) * desiredWidth);
height = isGif ? calculatedHeight : multipleOf2(calculatedHeight); // x264 requires multiple of 2
width = desiredWidth;
} else {
if (desiredWidth) {
const calculatedHeight = Math.round((detectedHeight / detectedWidth) * desiredWidth);
height = isGif ? calculatedHeight : multipleOf2(calculatedHeight); // x264 requires multiple of 2
width = desiredWidth;
} else {
width = detectedWidth;
height = detectedHeight;
}
} else if (desiredWidth) {
width = desiredWidth; width = desiredWidth;
height = desiredWidth; height = desiredWidth;
// console.log(`Cannot detect width/height from video, set defaults ${width}x${height}`); // console.log(`Cannot detect width/height from video, set defaults ${width}x${height}`);
} else {
// No video
width = 640;
height = 640;
} }
// User override? // User override?

Loading…
Cancel
Save