@@ -17,6 +17,7 @@ use rav1e::prelude::*;
17
17
use rav1e:: version;
18
18
use scan_fmt:: scan_fmt;
19
19
20
+ use std:: ffi:: OsString ;
20
21
use std:: fs:: File ;
21
22
use std:: io;
22
23
use std:: io:: prelude:: * ;
@@ -45,8 +46,8 @@ pub struct CliOptions {
45
46
pub benchmark : bool ,
46
47
pub threads : usize ,
47
48
pub metrics_enabled : MetricsEnabled ,
48
- pub pass1file_name : Option < String > ,
49
- pub pass2file_name : Option < String > ,
49
+ pub pass1file_name : Option < OsString > ,
50
+ pub pass2file_name : Option < OsString > ,
50
51
pub save_config : Option < String > ,
51
52
pub slots : usize ,
52
53
}
@@ -108,6 +109,7 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
108
109
. help ( "Uncompressed YUV4MPEG2 video input" )
109
110
. required_unless_present ( "FULLHELP" )
110
111
. index ( 1 )
112
+ . allow_invalid_utf8 ( true )
111
113
)
112
114
. arg (
113
115
Arg :: new ( "OUTPUT" )
@@ -116,19 +118,22 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
116
118
. long ( "output" )
117
119
. required_unless_present ( "FULLHELP" )
118
120
. takes_value ( true )
121
+ . allow_invalid_utf8 ( true )
119
122
)
120
123
// ENCODING SETTINGS
121
124
. arg (
122
125
Arg :: new ( "FIRST_PASS" )
123
126
. help ( "Perform the first pass of a two-pass encode, saving the pass data to the specified file for future passes" )
124
127
. long ( "first-pass" )
125
128
. takes_value ( true )
129
+ . allow_invalid_utf8 ( true )
126
130
)
127
131
. arg (
128
132
Arg :: new ( "SECOND_PASS" )
129
133
. help ( "Perform the second pass of a two-pass encode, reading the pass data saved from a previous pass from the specified file" )
130
134
. long ( "second-pass" )
131
135
. takes_value ( true )
136
+ . allow_invalid_utf8 ( true )
132
137
)
133
138
. arg (
134
139
Arg :: new ( "LIMIT" )
@@ -373,6 +378,7 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
373
378
. long ( "reconstruction" )
374
379
. short ( 'r' )
375
380
. takes_value ( true )
381
+ . allow_invalid_utf8 ( true )
376
382
)
377
383
. arg (
378
384
Arg :: new ( "OVERWRITE" )
@@ -464,23 +470,25 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
464
470
}
465
471
}
466
472
467
- let rec = match matches. value_of ( "RECONSTRUCTION" ) {
473
+ let rec = match matches. value_of_os ( "RECONSTRUCTION" ) {
468
474
Some ( f) => Some ( Box :: new (
469
475
File :: create ( & f)
470
476
. map_err ( |e| e. context ( "Cannot create reconstruction file" ) ) ?,
471
477
) as Box < dyn Write + Send > ) ,
472
478
None => None ,
473
479
} ;
474
480
481
+ let os_input = matches. value_of_os ( "INPUT" ) . unwrap ( ) ;
475
482
let io = EncoderIO {
476
- input : match matches. value_of ( "INPUT" ) . unwrap ( ) {
477
- "-" => Box :: new ( io:: stdin ( ) ) as Box < dyn Read + Send > ,
478
- f => Box :: new (
479
- File :: open ( & f) . map_err ( |e| e. context ( "Cannot open input file" ) ) ?,
483
+ input : match os_input. to_str ( ) {
484
+ Some ( "-" ) => Box :: new ( io:: stdin ( ) ) as Box < dyn Read + Send > ,
485
+ _ => Box :: new (
486
+ File :: open ( os_input)
487
+ . map_err ( |e| e. context ( "Cannot open input file" ) ) ?,
480
488
) as Box < dyn Read + Send > ,
481
489
} ,
482
490
output : create_muxer (
483
- matches. value_of ( "OUTPUT" ) . unwrap ( ) ,
491
+ matches. value_of_os ( "OUTPUT" ) . unwrap ( ) ,
484
492
matches. is_present ( "OVERWRITE" ) ,
485
493
) ?,
486
494
rec,
@@ -528,8 +536,8 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
528
536
benchmark : matches. is_present ( "BENCHMARK" ) ,
529
537
verbose,
530
538
threads,
531
- pass1file_name : matches. value_of ( "FIRST_PASS" ) . map ( |s| s. to_owned ( ) ) ,
532
- pass2file_name : matches. value_of ( "SECOND_PASS" ) . map ( |s| s. to_owned ( ) ) ,
539
+ pass1file_name : matches. value_of_os ( "FIRST_PASS" ) . map ( |s| s. to_owned ( ) ) ,
540
+ pass2file_name : matches. value_of_os ( "SECOND_PASS" ) . map ( |s| s. to_owned ( ) ) ,
533
541
save_config,
534
542
slots,
535
543
} )
0 commit comments