Commit graph

38 commits

Author SHA1 Message Date
redzic 270b3ba3cb
Consolidate import style in rustfmt.toml (#619) 2022-04-20 20:24:55 +00:00
GaveUp f0d3f0ece9
Remove data streams when encoding audio (#616) 2022-04-17 05:40:01 +00:00
redzic 154a9141f5
Fix ffmpeg filter escaping (#602) 2022-03-29 13:04:41 +00:00
redzic 6634bc77f8
Update to ffmpeg 5.0 (#575)
* Update to ffmpeg 5.0
2022-02-22 22:17:37 +02:00
redzic d3687328b9
Escape commas in escape_path_in_filter (#495) 2022-01-03 20:48:45 +00:00
Josh Holmer 03244e0877
Add option to generate film grain tables for aomenc (#485) 2022-01-01 21:13:03 +00:00
redzic cad9b83af2
Fix clippy warnings (#451) 2021-12-16 01:25:46 +00:00
Josh Holmer 519bd0504e Merge branch 'unstable' 2021-12-15 15:03:21 -05:00
Redzic 2b3e255878 Fix nightly clippy warnings 2021-12-10 01:32:39 -06:00
Josh Holmer 28ab3b406a Add kbps and final file size estimates to progress bar (#439)
* Add kbps and final file size estimates to progress bar

This looks at the size of each chunk when it completes and saves that
size in kilobytes into the done.json file. For backwards compatibility
for encodes resumed from an earlier version of av1an, if the done.json
does not contain the chunk size, then on resume, av1an will lookup the
size of that chunk. The estimates on the progress bar also handle
resumes and chunk crashes gracefully.

* Include audio size in estimates
2021-12-09 12:29:15 -06: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
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 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
redzic e9ef27f524
Perform startup check before confirming output file overwrite (#377) 2021-10-09 14:07:21 +03:00
redzic f5c3b3c85a
Fix many clippy warnings, many small code style changes (#375) 2021-10-05 20:08:18 +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 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
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
redzic cef0df5e87
Lazily compile all regexes, move macros to util module (#345)
* Lazily compile all regexes, move macros to util module

* Clarify/fix documentation
2021-08-29 06:11:25 +03:00
Tatsuyuki Ishi 43da6b8687
ffmpeg: fix frame count parsing (#339)
The old code used to search for the first match that looked like a frame
count. When ffmpeg emits a warning, it would also emit the frame count at
the point of warning, therefore the previous implementation gave wrong
frame count when it happened.

Fix this by modifying the code to take the last match. Also replace the
index of cap by an explicit one since this is the index of capture group
(which is constant given the regex), not matches.
2021-08-22 07:35:54 +03:00
Zen 2980b70537 some doc comments 2021-08-07 02:40:00 +03:00
mxsrm 213e7c8e79
Small improvements to ffmpeg.rs (#331)
* ffmpeg: Ensure to map video streams only

Using 0✌️0 could map image files embedded into an mkv if they are
the first entry. 0:V:0 ensures that the first actual video stream
is mapped.

* ffmpeg: Drop subtitles when encoding audio

Formerly, when encoding audio av1an would also convert subtitles
(e.g. SRT would be converted to ASS). We should leave this decision
up to the user and drop subtitles while encoding audio.

* ffmpeg: Do not drop metadata

Formerly, metadata was dropped when encoding audio. This lead to missing
language tags on the audio file and to missing chapter names.
2021-08-16 20:17:52 +03:00
redzic 39494f06e2
Fix target quality and VMAF plotting on Windows (#319)
FFmpeg requires a very specific syntax to escape the file path in
Windows when using a filter, so this has been implemented with
conditional compilation. The behavior is the same on Windows, except
that the path is converted to an absolute path. Also, the only usage of
`std::env::current_dir` has been removed, since it was being used as an
ad-hoc way to convert a relative path to an absolute one, which doesn't
work if the temporary directory is in a different directory than the
current one.

We no longer kill the child processes from `process_pipe`,
since calling `wait` or `wait_with_output` closes the stdin handle
anyway.

Also, all usages of `cfg!(windows)` have been changed to `cfg!(target_os
= "windows")` to keep a consistent style.
2021-07-29 09:30:24 +03:00
redzic adf67a85f3
Refactor: fix chunk restarting, progress bar, and potential race condition (#316)
`DoneJson` is now a concurrent data structure, via `DashMap` and atomics
in the standard library. This should help avoid any potential race
conditions involved with one thread reading `done.json` while another
thread writes to it. Now, we only write to `done.json`, so any failure
from parsing the json while encoding is impossible.

The audio encoding is now done on a separate thread, and it is not
assumed that the audio encoding was finished if the `--resume` flag was
specified, which is now kept track of within `done.json`.

The initialization of the progress bar(s) now does not occur if the
corresponding initialization functions were not called, and the
functions to update the progress bar(s) are a NO-OP if it was not
initialized, rather than implicitly initializing it through the use of
the `Lazy` type from `once_cell`.

Additionally, all 3 concatenation functions now reside in the `concat` module.
2021-07-26 21:01:52 +03:00
redzic bf1b6e98b8
Better logging, integrate av1an-pyo3 into av1an-core (#314)
Implements more robust logging via flexi_logger. This replaces the old
logging implementation, and is also more ergonomic, since macros from the
`log` crate are now used instead of `format!` directly. Now, warnings
and errors are also logged to stderr, in addition to the log file.

This also removes av1an-pyo3, and integrates the code into av1an-core.

Concatenation with FFmpeg is now handled on Windows differently than
other platforms through conditional compilation. FFmpeg seems to need
double backslashes in the concat file, so this is explicitly handled
in the Windows build now. Also, the spinner is now disabled on Windows
builds since the default command prompt cannot display the characters
correctly.
2021-07-25 10:31:54 +03:00
redzic 4ef9bdaa8a
More idiomatic Rust, add Cargo.lock to the repo (#313)
Previously, we represented quantizer values as an owned `String` for
constructing various encoder commands, which is much slower and less
robust than representing the quantizer as an integral value. This has
been updated to represent the `q` and `n_threads` both as a `usize`, and
only convert to a `String` for formatting as needed.

Furthermore, several struct fields containing paths have been updated to
use a `PathBuf` or `&Path` instead of a `String`. These are the first
steps required to supporting non-UTF8 filenames on Windows and
Unix-based operating systems.

`run_vmaf_on_chunk`'s function signature has been update to take generic
arguments that satisfy `AsRef<Path>`, which allows the caller to save
themselves from creating a new `Path` if the original argument was a
`String`, for example.

* Do not represent the concatenation method as a string
* Fix pedantic clippy warnings
* Remove Cargo.lock from .gitignore
* Fix startup_check for ivf concatenation
* Add doc comment to `Args` for better help generation in Clap
* Use Display impl instead of directly using str::From for `Encoder` and `ConcatMethod`
* Do not unwrap the result of killing child processes
* Assert that VMAF calculation was successful
* Use more idiomatic Rust
2021-07-24 20:09:21 +03:00
redzic 733d9d947e
Many minor improvements, fix some pedantic clippy warnings (#299) 2021-07-16 03:15:48 +03:00
redzic 8cee2d3328
Fix chunking/resume, port chunk generation to Rust, remove unused Python code, update indicatif (#297)
* Use upstream indicatif instead of fork
* Port encode_file and all chunk generation to Rust, remove unused Python dependencies
2021-07-15 05:14:33 +03:00
redzic 3e30b31499
Add av-scenechange as the new and default scene detector (#292)
* Fix clippy warnings, run `cargo fmt`
* Add clippy::needless_pass_by_value lint to av1an-core
* Add av-scenechange as the new and default scene detector
2021-07-12 06:08:37 +03:00
redzic 018999a5fb
Port logging to Rust, fix clippy warnings and remove dead code (#280)
Port logging to Rust
2021-06-14 23:20:47 +03:00
Zen c14e6c015a fix audio doesn't copying 2021-06-01 16:34:08 +03:00
Zen 49cd278a02 Fix concat bug 2021-06-01 01:06:28 +03:00
Zen df68733e93 ffmpeg module to rust.
Ported get frame types
2021-05-20 09:31:17 +03:00
Zen b09a3a615d audio extraction to rust, and redone 2021-05-20 09:08:31 +03:00
Zen 5a0e9d4ece ffmpeg concatenation to rust 2021-05-17 15:08:55 +03:00
redzic d7c1253d04 Add --output_ivf flag to remux VP9 and AV1 to ivf
Move check to startup_check
2021-05-17 06:58:59 +03:00
Zen 817ce9b6bf get_keyframes to rust 2021-05-16 14:09:16 +03:00