Skip to content

Commit

Permalink
refactor: rename --force to --crop
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the `--force` option has been
renamed to `--crop` to be consistent with new
`--nocrop` option
  • Loading branch information
nwronski committed Oct 27, 2019
1 parent 4aaeb71 commit a5520d1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ batch.cli();
- The output **directory** to hold the transcoded videos. If you do not specify an output directory then each transcoded file will be placed in the same directory as its source file. Note: if a source file is already in the same file format as the transcoded video (e.g.: both source and output are both `.mkv`) then you must specify an output directory, as the program will not overwrite existing files.
- `--mask [pattern]` (Default: `**/*.{mp4,avi,mkv,m4v,ts,mov}`) (Alias: `-m`)
- Search pattern to use for input directory. Note that the default pattern will search in nested directories. For more information about what values can be used, see the [glob](https://github.com/isaacs/node-glob) documentation.
- `--force` _Mixed values_ (Alias: `-f`)
- `--crop` _Mixed values_ (Alias: `-c`)
- If you provide **an actual crop value** (e.g.: `"0:0:0:0"`) as the argument for this option, then that crop value will be used **for all videos**.
- If you provide anything other than an actual crop value (e.g. `1`) as the argument for this option, then when crop detection returns conflicting crop values it will just use the least extreme crop value and continue transcoding.
- `--diff` _Flag: does not accept a value_ (Default: `false`)
Expand Down
4 changes: 2 additions & 2 deletions batch-transcode-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ let defs = {
mask: 'm',
help: 'h',
version: 'v',
force: 'f',
crop: 'c',
keep: 'k'
},
boolean: [
'debug', 'quiet', 'flatten', 'diff', 'help', 'version', 'keep', 'nocrop'
],
string: [
'input', 'output', 'mask', 'force'
'input', 'output', 'mask', 'crop'
],
default: defaultOptions,
unknown: function (arg) {
Expand Down
2 changes: 1 addition & 1 deletion lib/default-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
// Only try to transcode videos that do not exist in the output directory
diff: false,
// If crop detection returns multiple values then take the least extreme crop
force: false,
crop: false,
// Never delete any output files, no matter what happens
keep: false,
// Skip crop detection and do not pass a --crop value to transcode-video
Expand Down
4 changes: 2 additions & 2 deletions lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const args = [
alias: 'm'
},
{
arg: 'force [crop]',
arg: 'crop [crop]',
desc: 'If you provide an actual crop value (e.g.: "0:0:0:0") as the argument for this option, then that crop value will be used for all videos. If you provide anything other than an actual crop value (e.g. 1) as the argument for this option, then when crop detection returns conflicting crop values it will just use the least extreme crop value and continue transcoding.',
def: 'false',
alias: 'f'
alias: 'c'
},
{
arg: 'diff',
Expand Down
8 changes: 4 additions & 4 deletions lib/video-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ export default class VideoFile {
_detectCrop() {
let prom;
let isNoCrop = this.options['nocrop'] === true;
let isFixedCrop = /([0-9]+\:){3}[0-9]+/.test(this.options['force']);
let isFixedCrop = /([0-9]+\:){3}[0-9]+/.test(this.options['crop']);
if (isNoCrop || isFixedCrop) {
const useCommand = [ 'transcode-video' ];
if (isFixedCrop && !isNoCrop) {
// Force the crop value provided using the --force option
useCommand.push('--crop', this.options['force'].trim());
// Force the crop value provided using the --crop option
useCommand.push('--crop', this.options['crop'].trim());
}
useCommand.push(this.filePathRel);
this._crop = prom = Promise.resolve(useCommand.join(' '));
Expand All @@ -158,7 +158,7 @@ export default class VideoFile {
if (useCommands.length === 0) {
throw new TranscodeError('Crop detection failed. Skipping transcode for file.', this.fileName, output);
} else if (useCommands.length > 1) {
if (this.options['force'] !== false) {
if (this.options['crop'] !== false) {
// Pick the least extreme crop
useCommands.sort(cropCompareFunc);
} else {
Expand Down

0 comments on commit a5520d1

Please sign in to comment.