try
This commit is contained in:
parent
c9f8c4a7bf
commit
819f4b8f65
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "Av1an"
|
||||
version = "0.1.0"
|
||||
authors = ["Zen <46526140+master-of-zen@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "av1an_rust"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
pyo3 = { version = "*", features = ["extension-module"] }
|
2
MANIFEST.in
Normal file
2
MANIFEST.in
Normal file
|
@ -0,0 +1,2 @@
|
|||
include pyproject.toml Cargo.toml
|
||||
recursive-include src *
|
|
@ -10,6 +10,7 @@ from av1an.utils import frame_probe_fast, hash_path, terminate
|
|||
from av1an.concat import vvc_concat, concatenate_ffmpeg, concatenate_mkvmerge
|
||||
from av1an.logger import log
|
||||
from av1an.vapoursynth import create_vs_file, frame_probe_vspipe
|
||||
from av1an_rust import get_ffmpeg_info
|
||||
|
||||
|
||||
class Project(object):
|
||||
|
@ -137,10 +138,12 @@ class Project(object):
|
|||
|
||||
# Check for non-empty string
|
||||
if isinstance(self.output_file, str) and self.output_file:
|
||||
if self.output_file[-1] in ('\\', '/'):
|
||||
if self.output_file[-1] in ("\\", "/"):
|
||||
if not Path(self.output_file).exists():
|
||||
os.makedirs(Path(self.output_file), exist_ok=True)
|
||||
self.output_file = Path(f"{self.output_file}{self.input.stem}_{self.encoder}{suffix}")
|
||||
self.output_file = Path(
|
||||
f"{self.output_file}{self.input.stem}_{self.encoder}{suffix}"
|
||||
)
|
||||
else:
|
||||
self.output_file = Path(self.output_file).with_suffix(suffix)
|
||||
else:
|
||||
|
@ -202,7 +205,7 @@ class Project(object):
|
|||
"""Creating temporally folders when needed."""
|
||||
|
||||
if self.temp:
|
||||
if self.temp[-1] in ('\\', '/'):
|
||||
if self.temp[-1] in ("\\", "/"):
|
||||
self.temp = Path(f"{self.temp}{'.' + str(hash_path(str(self.input)))}")
|
||||
else:
|
||||
self.temp = Path(str(self.temp))
|
||||
|
@ -275,6 +278,9 @@ class Project(object):
|
|||
if not find_executable("ffmpeg"):
|
||||
print("No ffmpeg")
|
||||
terminate()
|
||||
else:
|
||||
log("Rust code")
|
||||
log(get_ffmpeg_info())
|
||||
|
||||
if self.chunk_method in ["vs_ffms2", "vs_lsmash"]:
|
||||
if not find_executable("vspipe"):
|
||||
|
|
24
pyproject.toml
Normal file
24
pyproject.toml
Normal file
|
@ -0,0 +1,24 @@
|
|||
[build-system]
|
||||
build-backend = "maturin"
|
||||
requires = ["setuptools", "wheel", "setuptools-rust"]
|
||||
|
||||
[tool.maturin]
|
||||
bindings = "pyo3"
|
||||
manylinux = "off"
|
||||
|
||||
[package.metadata.maturin]
|
||||
requires-dist = [
|
||||
"numpy",
|
||||
"scenedetect[opencv]",
|
||||
"opencv-python",
|
||||
"tqdm",
|
||||
"psutil",
|
||||
"scipy",
|
||||
"matplotlib",
|
||||
]
|
||||
classifiers = [
|
||||
"Programming Language :: Rust",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
9
setup.py
9
setup.py
|
@ -1,4 +1,5 @@
|
|||
import setuptools
|
||||
from setuptools_rust import Binding, RustExtension
|
||||
|
||||
# TODO: rewrite it in rust
|
||||
|
||||
|
@ -12,6 +13,8 @@ REQUIRES = [
|
|||
"matplotlib",
|
||||
]
|
||||
|
||||
setup_requires = ["setuptools-rust>=0.9.2"]
|
||||
|
||||
with open("README.md", "r") as f:
|
||||
long_description = f.read()
|
||||
|
||||
|
@ -27,8 +30,13 @@ setuptools.setup(
|
|||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/master-of-zen/Av1an",
|
||||
packages=setuptools.find_packages(".", exclude="tests"),
|
||||
setup_requires=setup_requires,
|
||||
install_requires=REQUIRES,
|
||||
py_modules=["av1an"],
|
||||
rust_extensions=[
|
||||
RustExtension("av1an_rust.av1an_rust", "Cargo.toml", binding=Binding.PyO3)
|
||||
],
|
||||
include_package_data=True,
|
||||
entry_points={"console_scripts": ["av1an=av1an:main"]},
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
|
@ -36,4 +44,5 @@ setuptools.setup(
|
|||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
zip_safe=False,
|
||||
)
|
||||
|
|
23
src/lib.rs
Normal file
23
src/lib.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use pyo3::prelude::*;
|
||||
use pyo3::wrap_pyfunction;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
/// Formats the sum of two numbers as string.
|
||||
#[pyfunction]
|
||||
fn get_ffmpeg_info() -> PyResult<String> {
|
||||
let mut cmd = Command::new("ffmpeg");
|
||||
|
||||
cmd.stderr(Stdio::piped());
|
||||
|
||||
let output = String::from_utf8(cmd.output().unwrap().stderr).unwrap();
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
/// A Python module implemented in Rust.
|
||||
#[pymodule]
|
||||
fn av1an_rust(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(get_ffmpeg_info, m)?)?;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue