Skip to content

Commit 5f701e8

Browse files
committed
Revert "Remove support for DgDecNv (#796)"
This reverts commit a946721.
1 parent 75d2a5f commit 5f701e8

File tree

7 files changed

+63
-7
lines changed

7 files changed

+63
-7
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Prerequisites:
7373
Optional:
7474

7575
- [L-SMASH](https://github.com/AkarinVS/L-SMASH-Works) VapourSynth plugin for better chunking (recommended)
76+
- [DGDecNV](https://www.rationalqm.us/dgdecnv/dgdecnv.html) Vapoursynth plugin for very fast and accurate chunking, `dgindexnv` executable needs to be present in system path and an NVIDIA GPU with CUVID
7677
- [ffms2](https://github.com/FFMS/ffms2) VapourSynth plugin for better chunking
7778
- [bestsource](https://github.com/vapoursynth/bestsource) Vapoursynth plugin for slow but accurate chunking
7879
- [mkvmerge](https://mkvtoolnix.download/) to use mkvmerge instead of FFmpeg for file concatenation

av1an-core/src/context.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Av1anContext {
147147
// generated when vspipe is first called), so it's not worth adding all the extra complexity.
148148
if (self.args.input.is_vapoursynth()
149149
|| (self.args.input.is_video()
150-
&& matches!(self.args.chunk_method, ChunkMethod::LSMASH | ChunkMethod::FFMS2 | ChunkMethod::BESTSOURCE)))
150+
&& matches!(self.args.chunk_method, ChunkMethod::LSMASH | ChunkMethod::FFMS2 | ChunkMethod::DGDECNV | ChunkMethod::BESTSOURCE)))
151151
&& !self.args.resume
152152
{
153153
self.vs_script = Some(match &self.args.input {
@@ -665,7 +665,10 @@ impl Av1anContext {
665665
fn create_encoding_queue(&mut self, scenes: &[Scene]) -> anyhow::Result<Vec<Chunk>> {
666666
let mut chunks = match &self.args.input {
667667
Input::Video(_) => match self.args.chunk_method {
668-
ChunkMethod::FFMS2 | ChunkMethod::LSMASH | ChunkMethod::BESTSOURCE => {
668+
ChunkMethod::FFMS2
669+
| ChunkMethod::LSMASH
670+
| ChunkMethod::DGDECNV
671+
| ChunkMethod::BESTSOURCE => {
669672
let vs_script = self.vs_script.as_ref().unwrap().as_path();
670673
self.create_video_queue_vs(scenes, vs_script)
671674
}

av1an-core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ pub enum ChunkMethod {
305305
FFMS2,
306306
#[strum(serialize = "lsmash")]
307307
LSMASH,
308+
#[strum(serialize = "dgdecnv")]
309+
DGDECNV,
308310
#[strum(serialize = "bestsource")]
309311
BESTSOURCE,
310312
}

av1an-core/src/settings.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use crate::concat::ConcatMethod;
1313
use crate::encoder::Encoder;
1414
use crate::parse::valid_params;
1515
use crate::target_quality::TargetQuality;
16-
use crate::vapoursynth::{is_bestsource_installed, is_ffms2_installed, is_lsmash_installed};
16+
use crate::vapoursynth::{
17+
is_bestsource_installed, is_dgdecnv_installed, is_ffms2_installed, is_lsmash_installed,
18+
};
1719
use crate::vmaf::validate_libvmaf;
1820
use crate::{ChunkMethod, ChunkOrdering, Input, ScenecutMethod, SplitMethod, Verbosity};
1921

@@ -125,6 +127,12 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
125127
"FFMS2 is not installed, but it was specified as the chunk method"
126128
);
127129
}
130+
if self.chunk_method == ChunkMethod::DGDECNV && which::which("dgindexnv").is_err() {
131+
ensure!(
132+
is_dgdecnv_installed(),
133+
"Either DGDecNV is not installed or DGIndexNV is not in system path, but it was specified as the chunk method"
134+
);
135+
}
128136
if self.chunk_method == ChunkMethod::BESTSOURCE {
129137
ensure!(
130138
is_bestsource_installed(),

av1an-core/src/vapoursynth.rs

+33-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::path::{Path, PathBuf};
66
use anyhow::{anyhow, bail};
77
use once_cell::sync::Lazy;
88
use path_abs::PathAbs;
9+
use std::process::Command;
910
use vapoursynth::prelude::*;
1011
use vapoursynth::video_info::VideoInfo;
1112

@@ -45,6 +46,13 @@ pub fn is_ffms2_installed() -> bool {
4546
*FFMS2_PRESENT
4647
}
4748

49+
pub fn is_dgdecnv_installed() -> bool {
50+
static DGDECNV_PRESENT: Lazy<bool> =
51+
Lazy::new(|| VAPOURSYNTH_PLUGINS.contains("com.vapoursynth.dgdecodenv"));
52+
53+
*DGDECNV_PRESENT
54+
}
55+
4856
pub fn is_bestsource_installed() -> bool {
4957
static BESTSOURCE_PRESENT: Lazy<bool> =
5058
Lazy::new(|| VAPOURSYNTH_PLUGINS.contains("com.vapoursynth.bestsource"));
@@ -57,6 +65,8 @@ pub fn best_available_chunk_method() -> ChunkMethod {
5765
ChunkMethod::LSMASH
5866
} else if is_ffms2_installed() {
5967
ChunkMethod::FFMS2
68+
} else if is_dgdecnv_installed() {
69+
ChunkMethod::DGDECNV
6070
} else if is_bestsource_installed() {
6171
ChunkMethod::BESTSOURCE
6272
} else {
@@ -194,12 +204,34 @@ pub fn create_vs_file(
194204
match chunk_method {
195205
ChunkMethod::FFMS2 => "ffindex",
196206
ChunkMethod::LSMASH => "lwi",
207+
ChunkMethod::DGDECNV => "dgi",
197208
ChunkMethod::BESTSOURCE => "json",
198209
_ => return Err(anyhow!("invalid chunk method")),
199210
}
200211
)))?;
201212

202-
if chunk_method == ChunkMethod::BESTSOURCE {
213+
if chunk_method == ChunkMethod::DGDECNV {
214+
// Run dgindexnv to generate the .dgi index file
215+
let dgindexnv_output = temp.join("split").join("index.dgi");
216+
217+
Command::new("dgindexnv")
218+
.arg("-h")
219+
.arg("-i")
220+
.arg(source)
221+
.arg("-o")
222+
.arg(&dgindexnv_output)
223+
.output()?;
224+
225+
let dgindex_path = dgindexnv_output.canonicalize()?;
226+
load_script.write_all(
227+
format!(
228+
"from vapoursynth import core\n\
229+
core.max_cache_size=1024\n\
230+
core.dgdecodenv.DGSource(source={dgindex_path:?}).set_output()"
231+
)
232+
.as_bytes(),
233+
)?;
234+
} else if chunk_method == ChunkMethod::BESTSOURCE {
203235
load_script.write_all(
204236
format!(
205237
"from vapoursynth import core\n\

av1an/src/main.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ fn version() -> &'static str {
4444
* VapourSynth Plugins
4545
systems.innocent.lsmas : {}
4646
com.vapoursynth.ffms2 : {}
47+
com.vapoursynth.dgdecodenv : {}
4748
com.vapoursynth.bestsource : {}",
4849
isfound(vapoursynth::is_lsmash_installed()),
4950
isfound(vapoursynth::is_ffms2_installed()),
51+
isfound(vapoursynth::is_dgdecnv_installed()),
5052
isfound(vapoursynth::is_bestsource_installed())
5153
)
5254
}
@@ -334,6 +336,10 @@ pub struct CliOpts {
334336
/// cause artifacts in the piped output). Slightly faster than lsmash for y4m input. Requires the ffms2 vapoursynth plugin to be
335337
/// installed.
336338
///
339+
/// dgdecnv - Very fast, but only decodes AVC, HEVC, MPEG-2, and VC1. Does not require intermediate files.
340+
/// Requires dgindexnv to be present in system path, NVIDIA GPU that support CUDA video decoding, and dgdecnv vapoursynth plugin
341+
/// to be installed.
342+
///
337343
/// bestsource - Very slow but accurate. Linearly decodes input files, very slow. Does not require intermediate files, requires the BestSource vapoursynth plugin
338344
/// to be installed.
339345
///
@@ -349,7 +355,7 @@ pub struct CliOpts {
349355
/// segment - Create chunks based on keyframes in the source. Not frame exact, as it can only split on keyframes in the source.
350356
/// Requires intermediate files (which can be large).
351357
///
352-
/// Default: lsmash (if available), otherwise ffms2 (if available), otherwise bestsource (if available), otherwise hybrid.
358+
/// Default: lsmash (if available), otherwise ffms2 (if available), otherwise DGDecNV (if available), otherwise bestsource (if available), otherwise hybrid.
353359
#[clap(short = 'm', long, help_heading = "Encoding")]
354360
pub chunk_method: Option<ChunkMethod>,
355361

docs/CLI.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@
239239
Slightly faster than lsmash for y4m input. Requires the ffms2 vapoursynth plugin to
240240
be installed.
241241
242+
dgdecnv - Very fast, but only decodes AVC, HEVC, MPEG-2, and VC1. Does not require intermediate files.
243+
Requires dgindexnv to be present in system path, NVIDIA GPU that support CUDA video decoding, and dgdecnv vapoursynth plugin
244+
to be installed.
245+
242246
bestsource - Very slow but accurate. Linearly decodes input files. Does not require intermediate files, requires the BestSource vapoursynth plugin
243247
to be installed.
244248
@@ -256,9 +260,9 @@
256260
segment - Create chunks based on keyframes in the source. Not frame exact, as it can
257261
only split on keyframes in the source. Requires intermediate files (which can be large).
258262
259-
Default: lsmash (if available), otherwise ffms2 (if available), otherwise bestsource (if available), otherwise hybrid.
263+
Default: lsmash (if available), otherwise ffms2 (if available), otherwise DGDecNV (if available), otherwise bestsource (if available), otherwise hybrid.
260264
261-
[possible values: segment, select, ffms2, lsmash, bestsource, hybrid]
265+
[possible values: segment, select, ffms2, lsmash, dgdecnv, bestsource, hybrid]
262266
263267
--chunk-order <CHUNK_ORDER>
264268
The order in which av1an will encode chunks

0 commit comments

Comments
 (0)