Skip to content

Commit e8dcd12

Browse files
committed
minor fix
1 parent 9579362 commit e8dcd12

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

animeloop-cli/main.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "cxxopts.hpp"
1515
#include "loop_video.hpp"
16+
#include "utils.hpp"
1617

1718
using namespace std;
1819
using namespace boost::filesystem;
@@ -55,13 +56,7 @@ int main(int argc, char * argv[]) {
5556
cout << endl;
5657
cout << ":: detecting external program..." << endl;
5758

58-
#ifdef _WIN32
59-
string find_ffmpeg_command = "where /q ffmpeg";
60-
#else
61-
string find_ffmpeg_command = "which ffmpeg &> /dev/null";
62-
#endif
63-
64-
if (system(find_ffmpeg_command.c_str()) == 0) {
59+
if (detect_ffmpeg()) {
6560
cout << "[o] detected ffmpeg." << endl;
6661
} else {
6762
cout << "[x] not detect ffmpeg." << endl;

animeloop-cli/utils.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void al::resize_video(path input_filepath, path output_filepath, Size size) {
5252

5353
auto if_exists = exists(output_filepath);
5454
if (!if_exists) {
55-
if (system("where /q ffmpeg") == 0) {
55+
if (detect_ffmpeg()) {
5656
cout << ":: resizing video..." << endl;
5757
const string i = input_filepath.string();
5858
const string s = (to_string(size.width) + "x" + to_string(size.height));
@@ -308,4 +308,14 @@ std::string al::time_string(double seconds) {
308308
auto ms = boost::posix_time::milliseconds(seconds * 1000);
309309
auto time = boost::posix_time::time_duration(ms);
310310
return boost::posix_time::to_simple_string(time);
311+
}
312+
313+
bool detect_ffmpeg() {
314+
#ifdef _WIN32
315+
string find_ffmpeg_command = "where /q ffmpeg";
316+
#else
317+
string find_ffmpeg_command = "which ffmpeg &> /dev/null";
318+
#endif
319+
320+
return system(find_ffmpeg_command.c_str()) == 0;
311321
}

animeloop-cli/utils.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ namespace al {
5757
std::string time_string(double seconds);
5858
}
5959

60+
bool detect_ffmpeg();
61+
6062
#endif /* utils_hpp */

0 commit comments

Comments
 (0)