Skip to content

Commit

Permalink
updated docs + cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed May 13, 2021
1 parent 6aee9d4 commit 5fd390d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 63 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Actions Status](https://github.com/wyattblue/auto-editor/workflows/build/badge.svg)](https://github.com/wyattblue/auto-editor/actions)
<a href="https://discord.com/invite/kMHAWJJ/"><img src="https://img.shields.io/discord/711767814821773372?color=%237289DA&label=chat&logo=discord&logoColor=white"></a>
<img src="https://img.shields.io/badge/version-21w16a-blue.svg">
<img src="https://img.shields.io/badge/version-21w19a-blue.svg">
<p align="center"><img src="https://raw.githubusercontent.com/wyattblue/auto-editor/master/articles/imgs/auto-editor_banner.png" title="Auto-Editor" width="700"></p>

**Auto-Editor** is a command line application for automatically **editing video and audio** by analyzing where sections are silent and cutting them up.
Expand Down Expand Up @@ -44,7 +44,7 @@ auto-editor example.mp4 --frame_margin 8
- [How to Install Auto-Editor](https://github.com/WyattBlue/auto-editor/blob/master/articles/installing.md)
- [How to Edit Videos With Auto-Editor](https://github.com/WyattBlue/auto-editor/blob/master/articles/editing.md)
- [How to Use Motion Detection in Auto-Editor](https://github.com/WyattBlue/auto-editor/blob/master/articles/motionDetection.md)
- [`--cut_out`, `--ignore`, and Range Syntax](https://github.com/WyattBlue/auto-editor/blob/master/articles/rangeSyntax.md)
- [What's new in Range Syntax](https://github.com/WyattBlue/auto-editor/blob/master/articles/rangeSyntax.md)
- [Zooming](https://github.com/WyattBlue/auto-editor/blob/master/articles/zooming.md)
- [The Rectangle Effect](https://github.com/WyattBlue/auto-editor/blob/master/articles/rectangleEffect.md)
- [Subcommands](https://github.com/WyattBlue/auto-editor/blob/master/articles/subcommands.md)
Expand Down
10 changes: 5 additions & 5 deletions articles/new.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ New Release!

---

Changed how `--cut_out` works.
Changed how `--cut_out` works. It removes sections regardless of what silent speed is.
* The format `--cut_out start-end` has been changed to `--cut_out start,end`
* It now also cuts sections off regardless of what silent speed is.
* `--cut_out` and other range options are now based on frames instead of seconds.

Replaced `--ignore` with `--mark_as_loud`. It also uses commas instead of hyphens.

Added `--mark_as_silent`, Mark a given range as silent. This is dependent on what silent speed is.
Added `--mark_as_silent`, Mark a given range as silent. This is dependent on what silent speed is. Has same functionally as `--cut_out` before 21w19a.

Added `--set_speed_for_range`. Allows you to set a custom speed for any section.
args are: `{speed},{starting point},{ending point}`

---

The default video codec has been changed from 'uncompressed' to 'copy'.

`--video_codec`'s default has been changed from 'uncompressed' to 'copy'.

unset is a new value that all FFmpeg-based options can take and it means don't include this option in the FFmpeg commands.

68 changes: 20 additions & 48 deletions articles/rangeSyntax.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,46 @@
# `--cut_out`, `--ignore`, and Range Syntax
# What's New in Range Syntax
last modified May 13, 2021. 21w19a.

Range syntax is the common format used in:

## `--cut_out`
- `--mark_as_loud`
- `--mark_as_silent`
- `--cut_out`
- `--set_speed_for_range`

is used to remove any sections of the media specified. For example:
and describes a range in time based on frames from 0, the first frame, all the way till the end.

```
auto-editor example.mp4 --cut_out 0-5
auto-editor example.mp4 --mark_as_silent 0,60
```

Will remove the first five seconds of `example.mp4`

And:

```
auto-editor example.mp4 --cut_out 20-end
```

Will remove all of `example.mp4` besides the first 20 seconds.


You can also use decimals:

```
auto-editor example.mp4 --cut_out 10.7-23.4
```

and it will cut out the range from 10.7 seconds to 23.4 seconds.


## `--ignore`

Ignore does the inverse of `--cut_out`, it ensures that auto-editor does not cut out anything in that section (**Ignore** loudness).

It can be used along with `--cut_out`.
It accepts any integer greater than and equal to 0 and can take strings (variables) like 'start' and 'end'.

```
auto-editor example.mp4 --ignore 0-20 --cut_out 20-end
auto-editor example.mp4 --mark_as_loud 72,end
```

or used byitself.
Range Syntax has a nargs value of '\*' meaning it can take any many ranges.

```
auto-editor example.mp4 --ignore 20-30
auto-editor example.mp4 --cut_out 0,20 45,60, 234,452
```

both `--cut_out` and `--ignore` use range syntax so any range that is recognized by `--cut_out` will be recognize `--ignore` or any future option that uses it.
---

## Range Syntax

Range syntax is a special data type for declaring ranges.

It follows the pattern: `{float}-{float} ...` using a hyphen to deliminate between the start and end point, and is in seconds instead of the usual "frames" unit.

It can be repeated infinitely. So
The `--set_speed_for_range` option has an additional argument for speed. The command:

```
auto-editor example.mp4 --cut_out 0-10 20-30 40-45
auto-editor example.mp4 --set_speed_for_range 2,0,30
```

is possible. In addition, the special values `start` and `end` can be used instead of floats. `end` represents the total length of the video in seconds while `start` is just equivalent to `0`.
means set the speed of the video to twice as fast (2x) from the 0th frame to the 30th frame.


### Out-of-bounds and Edge Cases.
## Notes

Going out-of-bounds don't cause an error.
before 21w19a. Range Syntax was second based and used hyphens as separators instead of commas.

```
auto-editor example.mp4 --cut_out 10-500
```
The `--ignore` has been renamed to the more accurately described `--mark_as_loud`.

Using an invalid range, ex (`10-5`) is Undefined Behavior.

12 changes: 4 additions & 8 deletions auto_editor/renderVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ def fset(cmd, option, value):
new_codec = ffprobe.getVideoCodec(vidFile)
if(new_codec != 'dvvideo'): # This codec seems strange.
cmd.extend(['-vcodec', new_codec])

# if(new_codec == 'h264' and system() != 'Linux'):
# cmd.extend(['-allow_sw', '1'])
else:
cmd = fset(cmd, '-vcodec', args.video_codec)

Expand All @@ -36,7 +33,6 @@ def fset(cmd, option, value):
return cmd

def scaleToSped(ffmpeg, ffprobe, vidFile, args, temp):

SCALE = f'{temp}{sep()}scale.mp4'
SPED = f'{temp}{sep()}spedup.mp4'

Expand Down Expand Up @@ -102,7 +98,8 @@ def read(self, buf_size):
'-pix_fmt', pix_fmt]

if(args.scale != 1):
cmd.extend(['-vf', f'scale=iw*{args.scale}:ih*{args.scale}', f'{temp}{sep()}scale.mp4'])
cmd.extend(['-vf', f'scale=iw*{args.scale}:ih*{args.scale}',
f'{temp}{sep()}scale.mp4'])
else:
cmd = properties(cmd, args, vidFile, ffprobe)
cmd.append(f'{temp}{sep()}spedup.mp4')
Expand Down Expand Up @@ -153,6 +150,8 @@ def read(self, buf_size):
def renderOpencv(ffmpeg, ffprobe, vidFile: str, args, chunks: list, speeds: list, fps,
has_vfr, effects, temp, log):
import cv2
import numpy as np
from interpolate import interpolate

if(has_vfr):
cmd = ['-i', vidFile, '-map', '0:v:0', '-vf', f'fps=fps={fps}', '-r', str(fps),
Expand Down Expand Up @@ -206,9 +205,6 @@ def findState(chunks, cframe) -> int:
# cframe not in chunks
return 0

import numpy as np
from interpolate import interpolate

def values(val, log, _type, totalFrames, width, height):
if(val == 'centerX'):
return int(width / 2)
Expand Down

0 comments on commit 5fd390d

Please sign in to comment.