Commit graph

2236 commits

Author SHA1 Message Date
redzic 48e69be774
Bump missing resume file messages down to INFO (#417) 2021-11-19 08:59:12 -06:00
redzic c6e020ea93
Improve error handling for concatenation (#414)
* Log the command used for concat (activated with log level `debug`)
  (the command along with process output is logged again at log level
  `error` if the command failed, regardless of `--log-level`)
* Replace some unwraps with `Result`s
* Add more `with_context()`s
2021-11-18 19:31:19 -06:00
redzic dc3b0cd27f
Better error handling if parsing scenes.json failed (#413) 2021-11-18 18:57:10 -06:00
redzic 34d991d06d
Delegate chunk starts/finishes to debug log level, other logging changes (#412)
* Rename `--logging` to `--log-file` (`-l` shorthand still works)
* Introduce new `--log-level` option to set the log level filter

This change makes `--verbose` not log chunk starts and finishes, and
that information is not logged in the log file either unless
`--log-level=debug` is set. By default, `--log-level` is set to `info`.

The `debug` log level also logs the rav1e scenechange decision info
for each frame.
2021-11-18 14:06:50 -06:00
redzic fdef1f4a2d
Use dimmed colors instead of fixed xterm 256 colors (#411) 2021-11-18 08:27:51 -06:00
redzic db5e569f9d
Adjust CLI output to be more colorful (#407)
* Adjust verbose progress style for workers

* Also add `-y` flag to overwrite output file without confirmation

* Update dependencies

* Fix compilation on older versions of rustc
2021-11-17 23:01:46 -06:00
Josh Holmer b10cb6e7cf
Fix a case where the log file could fail to be created (#409)
Previously, these warn statements came before we create
the temp directory. I'm assuming when the first log
statement is run, flexi_logger then attempts to create
the log file. If it fails, it doesn't try again.

Ensuring we create the temp directory before attempting
to log should resolve this issue.
2021-11-17 18:07:42 -06:00
redzic f94c65f992
Improve logging (especially with --verbose) (#404)
* Improve logging (especially with `--verbose`)

Much more information is now logged when using `--verbose` (all INFO
messages), and the output is also much cleaner.

The issue of logs being hidden while the progress bar is active
because of conflicting ANSI escape codes has been completely fixed, and
no more undesirable hacks are required to correctly display the
set_thread_affinity warning message correctly, for example. This has
been achieved by using indicatif's `println` function instead of just
printing to stderr directly.

flexi_logger has been moved to av1an-cli as it should be, since a
logging framework that actually prints things and handles log level
filtering is not the responsibility of the core library. However, the
actual progress bar code with indicatif still lives in av1an-core for
now.

* Make `--quiet` conflict with `--verbose`

* Fix resuming and improve error handling slightly
2021-11-17 10:57:08 +02:00
redzic 637314e7f1
Fix compilation on macos (#403) 2021-11-16 03:42:41 +02:00
redzic 98bb4cc4b6
Allow setting thread affinity for each worker (#402)
Introduces a new command line option called `--set-thread-affinity=n`,
where `n` specifies the number of threads to assign to each worker.

We use the `affinity` crate instead of the `nix` crate directly to
get abstractions for Windows and Linux.
2021-11-16 00:15:26 +02:00
redzic 7f2734c7e1
Initial round of improvements for error handling (#401)
The main change that this commit introduces is an `EncoderCrash` type
for errors, which also reports the stderr of the process piping to
the encoder so that it is easier to tell what the actual error is.

Target quality probe crashes are now properly logged with the
`EncoderCrash` type, replacing the old panicking code and making the
error significantly easier to read.

An "optimization" has been implemented which does not wait for the child
process piping to the encoder to exit, and instead collects its stderr
output asynchronously and immediately exits upon an encoder crash. This
does not yet apply to target quality probes, as there is not yet a
single interface for running an encoder (it is done manually for now).
This will change in the future, but this patch is getting too big for
everything so for now we just capture stderr synchronously for target
quality probes.

- Also update `get_percentile` to use an O(N) algorithm from the
  standard library instead of O(N*log N).
2021-11-11 04:52:32 +02:00
redzic 754c1192fe
Always copy subtitles and all audio tracks (#400)
* Always copy subtitles and all audio tracks

Require mkvmerge for x265

* cargo update

* Fix concat if audio file does not exist

* Use stable rustc in Docker, do not compile VVC

* Use old Docker image for now which works with vapoursynth

* Fix tests.yml

* Use mkvmerge for tests

* Add mkvtoolnix as a dependency in tests.yml
2021-11-07 14:20:12 +02:00
Sven-Hendrik Haase a8812b9900
Clean up installation instructions and add crates.io badge (#396)
I just put av1an into Arch Linux's [community] repository so this should be reflected in the README.
2021-11-02 13:25:09 +02:00
Zen a874dec452 av1an 0.2.0 release 2021-10-31 22:56:47 +02:00
redzic c16f6a2730
Fix vergen for release again (#394) 2021-10-31 22:51:10 +02:00
Zen 5c8a99879f bump av1an-cli version 2021-09-12 22:26:42 +03:00
redzic eb1047aa30
Fix vergen for release (#393) 2021-10-31 22:20:38 +02:00
Zen 782f74982b Bump version 2021-09-11 21:24:58 +03:00
Zen e63ae64606 correct docs 2021-09-10 21:20:09 +03:00
Josh Holmer 911b75013e
Use cargo version of rav1e 0.5 (#391) 2021-10-31 20:20:58 +02:00
Zen 76bae0fae7 Fix docs markdown 2021-10-11 20:27:50 +03:00
Zen 95f053cfb1 Fix readme markdown 2021-10-10 20:25:27 +03:00
redzic e2451684b8
Refactor: Better ffmpeg pipe handling + more info in --version (#389)
* Refactor: Better ffmpeg pipe handling + more info in --version

* Update dependencies
* Better documentation in `--help`
* Include git commit hash and more info in `--version`
* Add `-k` as shorthand for `--keep`
* Do not pass `ffmpeg_pipe` around everywhere
* Use macro to generate encoder bit depth functions
* Fix documentation in README

* Fix some clippy warnings
2021-10-30 14:49:26 +03:00
redzic 2f50335b6e
Fix hanging of VMAF calculation (#386)
* Fix run_vmaf by removing Stdio::piped() when not needed

* Update dependencies
2021-10-24 23:10:29 +03:00
Josh Holmer 32cebb8808
Scene detect changes (#383)
* Remove sc-downscale-height CLI option

The standard scenecut detection method at 1080p
is currently as fast as downsampling to 720p
and running scenecut detection on that, and the
fast scenecut method is significantly faster
without downsampling, because the algorithm
is faster than ffmpeg's resizing algorithm.

As such, it doesn't make sense to have this option anymore.

* Fix conditional use of newer VS APIs

It makes sense to enable these by default,
since the vast majority of users
should have a moderately recent version
of Vapoursynth.

We also needed to disable the static ffmpeg
as the default for now. libaom returns None
for the pixel format, so it is not usable
for the changes needed later in this PR.
I attempted to get the git version of
ffmpeg-next compiling with libdav1d,
but was running into issues, I believe
because Arch's package manager only includes
a dynamic library for libdav1d and not
a static version. It probably makes sense
to disable it anyway given the issues
Windows users have been having with it.

* No longer convert input to 8-bit for scene detect

It appears that downconverting does have an impact
on scene detection accuracy. The speed penalty
for running in 10-bit compared to 8-bit is only
10%. Given this, it seems preferable to run
the scene detect in the more accurate format.

* Skip ffmpeg intermediate step for vapoursynth input

* Fix skipping of ffmpeg pipe step

This optimization added in #379 was never triggered.
Because the initialize() method always added a set
of default params to self.ffmpeg_params, the clause
to skip the ffmpeg pipe, self.ffmpeg_params.is_empty(),
was unreachable.

* Revert "Remove sc-downscale-height CLI option"

This reverts commit a51763607faddae07a595f567d4f4cf815de3299.

* Validate pixel formats based on encoder support

* Fix CI build

The dynamic linking of ffmpeg doesn't seem to play nicely with
the old version of ffmpeg which is packaged in Ubuntu's last LTS.
This enables static linking when we are running in CI to work around
that issue, given that that workaround is easier than overhauling
which docker container we use.
2021-10-20 19:54:48 +03:00
Zen 6d55c06561 Improve VMAF plot readibility 2021-10-20 02:08:29 +03:00
redzic 74f8339758
Fix scene detection in some very specific scenarios (#385) 2021-10-20 00:00:38 +03:00
Zak 176e7811d6
Tweaked default settings for better target-quality+normal encoding (#363)
Fixing the vpxenc error
Not forcing keyframes in target-quality
Fixing aom tpl_rdo
2021-10-18 02:26:18 +03:00
Zen 3e9f729d3c fix building 2021-10-14 02:13:14 +03:00
Josh Holmer c8547c7c9b
Changes for rav1e's hybrid scene detection update (#381) 2021-10-14 02:04:11 +03:00
redzic 3147a942a7
Reduce piping overhead to encoder in certain situations (#379)
Previously, we always piped the chunk method into FFmpeg
to apply filters and convert the pixel format, but this
just adds unnecessary overhead if there is no FFmpeg filter
specified and if the pixel format of the source and encode
are the same. So, in that situation, we now pipe the chunk
method directly into the encoder instead. This should
nicely speed things up a bit (and possibly reduce memory
consumption).

Additionally, `--pix-format` is now verified using the FFmpeg
API when the CLI args are parsed, making it impossible to
accidentally specify an incorrect format. Previously, there
were no checks at all, so if you specified the wrong format it
would just fail during the encoding process with no obvious
indication of the root cause.

This does not apply to vapoursynth input for now, as that
would be slightly more complicated since it has a different
API for getting the pixel format.
2021-10-13 05:21:55 +03:00
Josh Holmer 2a0c47d294
Do not split encoder args for non-vpx-based CLIs (#378)
This fixes an issue with encoders such as x264
where parsing would fail if you passed a negative
argument, such as `--deblock -1:-1`.
2021-10-13 00:51:21 +03:00
redzic e9ef27f524
Perform startup check before confirming output file overwrite (#377) 2021-10-09 14:07:21 +03:00
redzic 9b1a00775b
Set log level in FFmpeg + small fixes (#376)
* Small fixes/cleanup

* Set log level to fatal in ffmpeg

* Update dependencies
2021-10-09 02:47:08 +03:00
redzic f5c3b3c85a
Fix many clippy warnings, many small code style changes (#375) 2021-10-05 20:08:18 +03:00
redzic 2b534e14c9
Refactor into Input type for handling vapoursynth input (#374)
* Refactor into `Input` type for handling vapoursynth input

Fixes several issues, namely `--vmaf` not working on vapoursynth input
as well as unifying the VMAF interface, which also results in
`--vmaf-threads` being passed correctly to `--vmaf`, which is massively
faster now as a result. If `--vmaf-threads` is not specified, then
the number of detected CPU threads is used for `--vmaf`.

Additionally, VMAF plots are rendered as SVGs now, which also removes
some dependencies since we don't use the bitmap backend at all anymore.

* Small cleanup: more consistent usage of `as_path`
2021-10-04 19:22:08 +03:00
Josh Holmer 5fbee3dfed
Rewriting simpler ffmpeg calls using the API (#372)
* Use ffmpeg API for get_keyframes

* Use ffmpeg API for has_audio

* Remove unused function get_frame_types
2021-10-04 16:17:11 +03:00
Josh Holmer 657810d162
Allow disabling extra splits by setting to 0 (#371) 2021-10-03 20:06:38 +03:00
Josh Holmer f52c82f15c
Use a different method for ffmpeg frame count (#368)
* Use a different method for ffmpeg frame count

This method uses ffprobe to count the number of packets
(which is identical to the number of frames, but faster)
in a video stream. This works with more video formats,
including with --enable-keyframe-filtering=2 in aomenc.
Performance should be similar or better than ffmpeg -copy.

* Add sanity check when using keyframe filtering 2

* Use ffmpeg-next crate for getting frame count

* Add LLVM/Clang to Github Actions

* Enable ffmpeg static and build features by default
2021-10-01 23:48:40 +03:00
Zen bb6ff7fcad Correct readme.md 2021-09-07 16:16:17 +03:00
Josh Holmer 195507ecd4
Routine dependency update (#362) 2021-09-20 21:19:07 +03:00
redzic 962f880764
Fix confirmation prompt (#361) 2021-09-17 21:07:35 +03:00
Josh Holmer 21817fe581
Add new scenechange method (#358)
This leaves the default at medium, which is an improved version
of the current scenecut detection method.
The fast method has also been improved from its previous version.
The slow method is a completely new implementation, which has
been shown to be more accurate, but is also about 15% slower.

This also removes the av-scenechange-fast split method,
in favor of making a separate CLI option for --sc-method,
which can be set to "fast", "medium", or "slow".

This also adds a CLI option for scenecut downscaling,
which can be specified by providing a maximum height e.g.
--sc-downscale-height 720 to downscale any input which is
above 720p to 720p for scenecut detection.
This will avoid upscaling anything below 720p, because that
would just slow down scenecut detection for no benefit.
2021-09-15 00:04:15 +03:00
Zen 2e667da9bf Limit vpspipe max_cache_size to 1024 2021-09-06 18:59:49 +03:00
Josh Holmer 64ea3c25c7
Fix printing on verbose scenechange info (#356)
Because of the scenes variable updating,
this would print the number of scenes after
extra splitting instead of the number of scenes
before splitting and then the number after splitting.
2021-09-08 00:18:01 +03:00
Josh Holmer bd2afa8369
Print scenechange info to stderr when in verbose mode (#355) 2021-09-07 21:42:00 +03:00
redzic f268d19641
Refactor: Remove parking_lot::Mutex from multi progress bar, rework mkvmerge concatenation implementation (#354)
- This removes the `parking_lot::Mutex` wrapping the multi progress bar, as it was not actually necessary. This also removes `parking_lot` as a dependency, as it is unused now.

- Rework the implementation of `mkvmerge` concatenation to not perform any unnecessary UTF-8 validation or allocations. This requires an algorithm to specify chunks with a '+' in between, but without a trailing '+', without later removing arguments (as the API of `std::process:Command` does not support this). This does not change the behavior of `-c mkvmerge` in any way, however.

- Also fix some miscellaneous clippy warnings.
2021-09-04 23:45:47 +03:00
Zen 906beb65f3 declutter lib.rs + prettify imports 2021-09-03 22:01:11 +03:00
Zen 6439b289df Cargo update 2021-09-02 01:06:56 +03:00
mxsrm 0316a4c0ce
Prevent data loss if concatenation failed (#353)
In some cases concatenation silently fails. To prevent loss of the
encoded data we now check if the output file exists. If it does not
exist we do not delete the temp folder.
2021-09-04 00:43:16 +03:00