@@ -58,25 +58,25 @@ impl Av1anContext {
58
58
Ok ( this)
59
59
}
60
60
61
- /// Initialize logging routines and create temporary directories
61
+ /// Initialize logging routines and create cache directories
62
62
fn initialize ( & mut self ) -> anyhow:: Result < ( ) > {
63
63
ffmpeg:: init ( ) ?;
64
64
ffmpeg:: util:: log:: set_level ( ffmpeg:: util:: log:: level:: Level :: Fatal ) ;
65
65
66
- if !self . args . resume && Path :: new ( & self . args . temp ) . is_dir ( ) {
67
- fs:: remove_dir_all ( & self . args . temp )
68
- . with_context ( || format ! ( "Failed to remove temporary directory {:?}" , & self . args. temp ) ) ?;
66
+ if !self . args . resume && Path :: new ( & self . args . cache ) . is_dir ( ) {
67
+ fs:: remove_dir_all ( & self . args . cache )
68
+ . with_context ( || format ! ( "Failed to remove cache directory {:?}" , & self . args. cache ) ) ?;
69
69
}
70
70
71
- create_dir ! ( Path :: new( & self . args. temp ) ) ?;
72
- create_dir ! ( Path :: new( & self . args. temp ) . join( "split" ) ) ?;
73
- create_dir ! ( Path :: new( & self . args. temp ) . join( "encode" ) ) ?;
71
+ create_dir ! ( Path :: new( & self . args. cache ) ) ?;
72
+ create_dir ! ( Path :: new( & self . args. cache ) . join( "split" ) ) ?;
73
+ create_dir ! ( Path :: new( & self . args. cache ) . join( "encode" ) ) ?;
74
74
75
- debug ! ( "temporary directory: {}" , & self . args. temp ) ;
75
+ debug ! ( "cache directory: {}" , & self . args. cache ) ;
76
76
77
- let done_path = Path :: new ( & self . args . temp ) . join ( "done.json" ) ;
77
+ let done_path = Path :: new ( & self . args . cache ) . join ( "done.json" ) ;
78
78
let done_json_exists = done_path. exists ( ) ;
79
- let chunks_json_exists = Path :: new ( & self . args . temp ) . join ( "chunks.json" ) . exists ( ) ;
79
+ let chunks_json_exists = Path :: new ( & self . args . cache ) . join ( "chunks.json" ) . exists ( ) ;
80
80
81
81
if self . args . resume {
82
82
match ( done_json_exists, chunks_json_exists) {
@@ -85,21 +85,21 @@ impl Av1anContext {
85
85
( false , true ) => {
86
86
info ! (
87
87
"resume was set but done.json does not exist in temporary directory {:?}" ,
88
- & self . args. temp
88
+ & self . args. cache
89
89
) ;
90
90
self . args . resume = false ;
91
91
}
92
92
( true , false ) => {
93
93
info ! (
94
94
"resume was set but chunks.json does not exist in temporary directory {:?}" ,
95
- & self . args. temp
95
+ & self . args. cache
96
96
) ;
97
97
self . args . resume = false ;
98
98
}
99
99
( false , false ) => {
100
100
info ! (
101
101
"resume was set but neither chunks.json nor done.json exist in temporary directory {:?}" ,
102
- & self . args. temp
102
+ & self . args. cache
103
103
) ;
104
104
self . args . resume = false ;
105
105
}
@@ -152,7 +152,7 @@ impl Av1anContext {
152
152
{
153
153
self . vs_script = Some ( match & self . args . input {
154
154
Input :: VapourSynth ( path) => path. clone ( ) ,
155
- Input :: Video ( path) => create_vs_file ( & self . args . temp , path, self . args . chunk_method ) ?,
155
+ Input :: Video ( path) => create_vs_file ( & self . args . cache , path, self . args . chunk_method ) ?,
156
156
} ) ;
157
157
158
158
let vs_script = self . vs_script . clone ( ) . unwrap ( ) ;
@@ -198,8 +198,8 @@ impl Av1anContext {
198
198
if self . args . sc_only {
199
199
debug ! ( "scene detection only" ) ;
200
200
201
- if let Err ( e) = fs:: remove_dir_all ( & self . args . temp ) {
202
- warn ! ( "Failed to delete temp directory: {}" , e) ;
201
+ if let Err ( e) = fs:: remove_dir_all ( & self . args . cache ) {
202
+ warn ! ( "Failed to delete cache directory: {}" , e) ;
203
203
}
204
204
205
205
exit ( 0 ) ;
@@ -227,13 +227,13 @@ impl Av1anContext {
227
227
&& ( !self . args . resume || !get_done ( ) . audio_done . load ( atomic:: Ordering :: SeqCst ) )
228
228
{
229
229
let input = self . args . input . as_video_path ( ) ;
230
- let temp = self . args . temp . as_str ( ) ;
230
+ let cache = self . args . cache . as_str ( ) ;
231
231
let audio_params = self . args . audio_params . as_slice ( ) ;
232
232
Some ( s. spawn ( move |_| {
233
- let audio_output = crate :: ffmpeg:: encode_audio ( input, temp , audio_params) ;
233
+ let audio_output = crate :: ffmpeg:: encode_audio ( input, cache , audio_params) ;
234
234
get_done ( ) . audio_done . store ( true , atomic:: Ordering :: SeqCst ) ;
235
235
236
- let progress_file = Path :: new ( temp ) . join ( "done.json" ) ;
236
+ let progress_file = Path :: new ( cache ) . join ( "done.json" ) ;
237
237
let mut progress_file = File :: create ( progress_file) . unwrap ( ) ;
238
238
progress_file
239
239
. write_all ( serde_json:: to_string ( get_done ( ) ) . unwrap ( ) . as_bytes ( ) )
@@ -329,20 +329,20 @@ impl Av1anContext {
329
329
match self . args . concat {
330
330
ConcatMethod :: Ivf => {
331
331
concat:: ivf (
332
- & Path :: new ( & self . args . temp ) . join ( "encode" ) ,
332
+ & Path :: new ( & self . args . cache ) . join ( "encode" ) ,
333
333
self . args . output_file . as_ref ( ) ,
334
334
) ?;
335
335
}
336
336
ConcatMethod :: MKVMerge => {
337
337
concat:: mkvmerge (
338
- self . args . temp . as_ref ( ) ,
338
+ self . args . cache . as_ref ( ) ,
339
339
self . args . output_file . as_ref ( ) ,
340
340
self . args . encoder ,
341
341
total_chunks,
342
342
) ?;
343
343
}
344
344
ConcatMethod :: FFmpeg => {
345
- concat:: ffmpeg ( self . args . temp . as_ref ( ) , self . args . output_file . as_ref ( ) ) ?;
345
+ concat:: ffmpeg ( self . args . cache . as_ref ( ) , self . args . output_file . as_ref ( ) ) ?;
346
346
}
347
347
}
348
348
@@ -376,12 +376,12 @@ impl Av1anContext {
376
376
377
377
if !Path :: new ( & self . args . output_file ) . exists ( ) {
378
378
warn ! (
379
- "Concatenation failed for unknown reasons! Temp folder will not be deleted: {}" ,
380
- & self . args. temp
379
+ "Concatenation failed for unknown reasons! cache folder will not be deleted: {}" ,
380
+ & self . args. cache
381
381
) ;
382
382
} else if !self . args . keep {
383
- if let Err ( e) = fs:: remove_dir_all ( & self . args . temp ) {
384
- warn ! ( "Failed to delete temp directory: {}" , e) ;
383
+ if let Err ( e) = fs:: remove_dir_all ( & self . args . cache ) {
384
+ warn ! ( "Failed to delete cache directory: {}" , e) ;
385
385
}
386
386
}
387
387
@@ -416,7 +416,7 @@ impl Av1anContext {
416
416
) -> Result < ( ) , ( Box < EncoderCrash > , u64 ) > {
417
417
update_mp_chunk ( worker_id, chunk. index , padding) ;
418
418
419
- let fpf_file = Path :: new ( & chunk. temp )
419
+ let fpf_file = Path :: new ( & chunk. cache )
420
420
. join ( "split" )
421
421
. join ( format ! ( "{}_fpf" , chunk. name( ) ) ) ;
422
422
@@ -767,7 +767,7 @@ impl Av1anContext {
767
767
// scenes.json and return that.
768
768
fn split_routine ( & mut self ) -> anyhow:: Result < Vec < Scene > > {
769
769
let scene_file = self . args . scenes . as_ref ( ) . map_or_else (
770
- || Cow :: Owned ( Path :: new ( & self . args . temp ) . join ( "scenes.json" ) ) ,
770
+ || Cow :: Owned ( Path :: new ( & self . args . cache ) . join ( "scenes.json" ) ) ,
771
771
|path| Cow :: Borrowed ( path. as_path ( ) ) ,
772
772
) ;
773
773
@@ -874,7 +874,7 @@ impl Av1anContext {
874
874
let output_ext = self . args . encoder . output_extension ( ) ;
875
875
876
876
let mut chunk = Chunk {
877
- temp : self . args . temp . clone ( ) ,
877
+ cache : self . args . cache . clone ( ) ,
878
878
index,
879
879
input : Input :: Video ( src_path. to_path_buf ( ) ) ,
880
880
source_cmd : ffmpeg_gen_cmd,
@@ -927,7 +927,7 @@ impl Av1anContext {
927
927
let output_ext = self . args . encoder . output_extension ( ) ;
928
928
929
929
let mut chunk = Chunk {
930
- temp : self . args . temp . clone ( ) ,
930
+ cache : self . args . cache . clone ( ) ,
931
931
index,
932
932
input : Input :: VapourSynth ( vs_script. to_path_buf ( ) ) ,
933
933
source_cmd : vspipe_cmd_gen,
@@ -1001,7 +1001,7 @@ impl Av1anContext {
1001
1001
debug ! ( "Splitting video" ) ;
1002
1002
segment (
1003
1003
input,
1004
- & self . args . temp ,
1004
+ & self . args . cache ,
1005
1005
& scenes
1006
1006
. iter ( )
1007
1007
. skip ( 1 )
@@ -1010,12 +1010,12 @@ impl Av1anContext {
1010
1010
) ;
1011
1011
debug ! ( "Splitting done" ) ;
1012
1012
1013
- let source_path = Path :: new ( & self . args . temp ) . join ( "split" ) ;
1013
+ let source_path = Path :: new ( & self . args . cache ) . join ( "split" ) ;
1014
1014
let queue_files = Self :: read_queue_files ( & source_path) ?;
1015
1015
1016
1016
assert ! (
1017
1017
!queue_files. is_empty( ) ,
1018
- "Error: No files found in temp /split, probably splitting not working"
1018
+ "Error: No files found in cache /split, probably splitting not working"
1019
1019
) ;
1020
1020
1021
1021
let chunk_queue: Vec < Chunk > = queue_files
@@ -1049,10 +1049,10 @@ impl Av1anContext {
1049
1049
. collect ( ) ;
1050
1050
1051
1051
debug ! ( "Segmenting video" ) ;
1052
- segment ( input, & self . args . temp , & to_split[ 1 ..] ) ;
1052
+ segment ( input, & self . args . cache , & to_split[ 1 ..] ) ;
1053
1053
debug ! ( "Segment done" ) ;
1054
1054
1055
- let source_path = Path :: new ( & self . args . temp ) . join ( "split" ) ;
1055
+ let source_path = Path :: new ( & self . args . cache ) . join ( "split" ) ;
1056
1056
let queue_files = Self :: read_queue_files ( & source_path) ?;
1057
1057
1058
1058
let kf_list = to_split
@@ -1127,7 +1127,7 @@ impl Av1anContext {
1127
1127
let num_frames = num_frames ( Path :: new ( file) ) ?;
1128
1128
1129
1129
let mut chunk = Chunk {
1130
- temp : self . args . temp . clone ( ) ,
1130
+ cache : self . args . cache . clone ( ) ,
1131
1131
input : Input :: Video ( PathBuf :: from ( file) ) ,
1132
1132
source_cmd : ffmpeg_gen_cmd,
1133
1133
output_ext : output_ext. to_owned ( ) ,
@@ -1155,7 +1155,7 @@ impl Av1anContext {
1155
1155
/// Returns unfinished chunks and number of total chunks
1156
1156
fn load_or_gen_chunk_queue ( & mut self , splits : & [ Scene ] ) -> anyhow:: Result < ( Vec < Chunk > , usize ) > {
1157
1157
if self . args . resume {
1158
- let mut chunks = read_chunk_queue ( self . args . temp . as_ref ( ) ) ?;
1158
+ let mut chunks = read_chunk_queue ( self . args . cache . as_ref ( ) ) ?;
1159
1159
let num_chunks = chunks. len ( ) ;
1160
1160
1161
1161
let done = get_done ( ) ;
@@ -1167,7 +1167,7 @@ impl Av1anContext {
1167
1167
} else {
1168
1168
let chunks = self . create_encoding_queue ( splits) ?;
1169
1169
let num_chunks = chunks. len ( ) ;
1170
- save_chunk_queue ( & self . args . temp , & chunks) ?;
1170
+ save_chunk_queue ( & self . args . cache , & chunks) ?;
1171
1171
Ok ( ( chunks, num_chunks) )
1172
1172
}
1173
1173
}
0 commit comments