12
12
#include " cxxopts.hpp"
13
13
#include " loop_video.hpp"
14
14
15
+ using namespace std ;
16
+ using namespace boost ::filesystem;
17
+ using namespace cxxopts ;
18
+
15
19
int main (int argc, char * argv[]) {
16
20
17
- auto rpath = boost::filesystem:: path (argv[0 ]).parent_path ();
21
+ auto rpath = path (argv[0 ]).parent_path ();
18
22
double min_duration, max_duration;
19
23
20
24
try {
21
25
cxxopts::Options options (" animeloop" , " anime loop video generator." );
22
26
23
- std:: string input, output, title ;
27
+ string input, output, episode, series ;
24
28
25
29
options.add_options ()
26
30
(" h,help" , " Show animeloop help" )
27
31
(" v,version" , " Show animeloop version" )
28
- (" title" , " Title of the source video" , cxxopts::value<std::string>(title))
29
- (" i,input" , " Input video file path" , cxxopts::value<std::string>(input))
30
- (" o,output" , " Output video directory path" , cxxopts::value<std::string>(output)->default_value (rpath.string ()))
31
- (" min-duration" , " Minimum duration (second) of loop video" , cxxopts::value<double >(min_duration)->default_value (" 0.8" ))
32
- (" max-duration" , " Maximum duration (second) of loop video" , cxxopts::value<double >(max_duration)->default_value (" 4.0" ))
32
+ (" i,input" , " Input video file path" , value<string>(input))
33
+ (" o,output" , " Output video directory path" , value<string>(output)->default_value (rpath.string ()))
34
+ (" episode" , " Episode name of the source video (default: <filename>)" , value<string>(episode))
35
+ (" series" , " Series name of the source video (default: <filename>)" , value<string>(series))
36
+ (" min-duration" , " Minimum duration (second) of loop video" , value<double >(min_duration)->default_value (" 0.8" ))
37
+ (" max-duration" , " Maximum duration (second) of loop video" , value<double >(max_duration)->default_value (" 4.0" ))
33
38
(" cover" , " Output loop video cover image." )
34
39
;
35
40
36
41
options.parse (argc, argv);
37
42
38
43
if (options.count (" version" )) {
39
- std:: cout << " version: " << al::kVersion << std:: endl;
44
+ cout << " version: " << al::kVersion << endl;
40
45
}
41
46
42
47
if (options.count (" help" )) {
43
- std:: cout << options.help () << std:: endl;
48
+ cout << options.help () << endl;
44
49
}
45
50
46
- if (options.count (" input" ) && options.count (" title" )) {
47
- al::LoopVideo loop_video (title, input, output);
51
+ if (options.count (" input" )) {
52
+ if (episode == " " ) {
53
+ episode = path (input).stem ().string ();
54
+ }
55
+
56
+ if (series == " " ) {
57
+ series = path (input).stem ().string ();
58
+ }
59
+
60
+ al::LoopVideo loop_video (series, episode, input, output);
48
61
loop_video.kMinduration = min_duration;
49
62
loop_video.kMaxduration = max_duration;
50
63
@@ -60,8 +73,8 @@ int main(int argc, char * argv[]) {
60
73
}
61
74
62
75
63
- } catch (const cxxopts:: OptionException& e) {
64
- std:: cout << " error parsing options: " << e.what () << std:: endl;
76
+ } catch (const OptionException& e) {
77
+ cout << " error parsing options: " << e.what () << endl;
65
78
exit (1 );
66
79
}
67
80
0 commit comments