diff --git a/README.md b/README.md index 22a971ebf..c745eb755 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Actions Status](https://github.com/wyattblue/auto-editor/workflows/build/badge.svg)](https://github.com/wyattblue/auto-editor/actions) - +
**Auto-Editor** is a command line application for automatically **editing video and audio** by analyzing where sections are silent and cutting them 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) diff --git a/articles/new.md b/articles/new.md index 9d2a6a8f9..ec809bc5f 100644 --- a/articles/new.md +++ b/articles/new.md @@ -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. diff --git a/articles/rangeSyntax.md b/articles/rangeSyntax.md index 5064ad60a..e6fd147ce 100644 --- a/articles/rangeSyntax.md +++ b/articles/rangeSyntax.md @@ -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. diff --git a/auto_editor/renderVideo.py b/auto_editor/renderVideo.py index 9affabf2c..3a286a25c 100644 --- a/auto_editor/renderVideo.py +++ b/auto_editor/renderVideo.py @@ -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) @@ -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' @@ -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') @@ -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), @@ -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)