Permalink
Browse files

added option to keep cuts instead of concatenating. Also to not ask t…

…o replace original movie.
  • Loading branch information...
1 parent b062a42 commit 832f0b854a64c03142796e35cd4ac780a99e0675 @ryanjay0 committed Nov 16, 2016
Showing with 41 additions and 12 deletions.
  1. +26 −9 cut_movie.cpp
  2. +2 −1 cut_movie.hpp
  3. +13 −2 miles-deep.cpp
View
@@ -179,7 +179,7 @@ void TagTargets( ScoreList score_list, string movie_file, string output_dir,
void CutMovie( ScoreList score_list, string movie_file, vector<int> target_list,
string output_dir, string temp_dir, int total_targets, int min_cut, int max_gap,
- float threshold, float min_coverage)
+ float threshold, float min_coverage, bool do_concat, bool remove_original)
{
//path stuff with movie file
@@ -284,15 +284,32 @@ void CutMovie( ScoreList score_list, string movie_file, vector<int> target_list,
output_dir = movie_directory;
- cout << "Concatenating parts in " << part_file_path << endl;
- cout << "Final output: " << output_dir << sep << cut_movie << movie_type << endl;
+ if(do_concat)
+ {
+ cout << "Concatenating parts in " << part_file_path << endl;
+ cout << "Final output: " << output_dir << sep << cut_movie << movie_type << endl;
- string concat_command = "ffmpeg -loglevel 16 -f concat -safe 0 -i " + part_file_path +
- " -c copy \"" + output_dir + sep + cut_movie + movie_type + "\"";
- if(system(concat_command.c_str()))
+ string concat_command = "ffmpeg -loglevel 16 -f concat -safe 0 -i " + part_file_path +
+ " -c copy \"" + output_dir + sep + cut_movie + movie_type + "\"";
+ if(system(concat_command.c_str()))
+ {
+ cerr << "Didn't concatenate pieces from: " << part_file_path << endl;
+ did_concat = false;
+ }
+ }
+ else
{
- cerr << "Didn't concatenate pieces from: " << part_file_path << endl;
- did_concat = false;
+ //copy cut directory to output_dir instead of concatenating
+ cout << "Final cut directory: " << output_dir << sep << cut_movie << endl;
+ string copy_directory_cmd = "cp -r " + temp_dir + sep + "cuts/ \"" +
+ output_dir + sep + cut_movie + "\"";
+ if(system(copy_directory_cmd.c_str()))
+ {
+ cerr << "Can't copy cut directory to: "
+ << output_dir << sep << cut_movie << endl;
+ //dont exit so we still clear cut directory
+ did_concat = false;
+ }
}
}
@@ -304,7 +321,7 @@ void CutMovie( ScoreList score_list, string movie_file, vector<int> target_list,
//ask about removing original and only keeping cut
- if(did_concat && queryYesNo())
+ if(remove_original && did_concat && queryYesNo())
{
string rm_cmd = "rm -rf \"" + movie_file + "\"";
if(system(rm_cmd.c_str()))
View
@@ -27,7 +27,8 @@ typedef vector<Cut> CutList;
void CutMovie( ScoreList score_list, string movie_file, vector<int> target_list,
string output_dir="", string temp_dir="/tmp", int total_targets = 6, int min_cut=5,
- int max_gap=2, float threshold=0.5, float min_coverage=0.4 );
+ int max_gap=2, float threshold=0.5, float min_coverage=0.4, bool do_concat=true,
+ bool remove_original = true);
void TagTargets( ScoreList score_list, string movie_file, string output_dir, vector<string> labels,
int total_targets, int min_cut, int max_gap, float threshold, float min_coverage);
View
@@ -190,6 +190,8 @@ void PrintHelp()
cout << "-g\tMax Gap (default: 2)- the largest section of non-target frames in a cut" << endl;
cout << "-s\tMinimum Score (default: 0.5) - minimum value considered a match [0-1]" << endl;
cout << "-v\tMinimum coVerage of target frames in a cut (default: 0.4) [0-1]" << endl;
+ cout << "-c\tDon't Concatenate. Output cut directory (default: off)" << endl;
+ cout << "-n\tDoN't ask to remove original movie file (default: off)" << endl;
cout << endl;
cout << "Model Options" << endl;
cout << "-m\tMean file .binaryproto" << endl;
@@ -379,6 +381,8 @@ int main(int argc, char** argv)
string output_directory = "";
string temp_directory = "/tmp";
bool auto_tag = false;
+ bool do_concat = true;
+ bool remove_original = true;
@@ -387,12 +391,15 @@ int main(int argc, char** argv)
//parse command line flags
int opt;
bool set_all_but_other = false;
- while ((opt = getopt(argc, argv, "at:b:d:o:m:g:s:hxp:w:u:l:")) != -1)
+ while ((opt = getopt(argc, argv, "act:b:d:o:m:ng:s:hxp:w:u:l:")) != -1)
{
switch (opt) {
case 'a':
auto_tag = true;
break;
+ case 'c':
+ do_concat = false;
+ break;
case 't':
target_list = Split(optarg,',');
break;
@@ -429,6 +436,9 @@ int main(int argc, char** argv)
case 'l':
label_file = optarg;
break;
+ case 'n':
+ remove_original = false;
+ break;
case 'h':
PrintHelp();
exit(0);
@@ -562,7 +572,8 @@ int main(int argc, char** argv)
target_ints.push_back(target_idx);
}
CutMovie( score_list, movie_file, target_ints, output_directory, temp_directory,
- classifier.labels_.size(), min_cut, max_gap, min_score, min_coverage );
+ classifier.labels_.size(), min_cut, max_gap, min_score,
+ min_coverage, do_concat, remove_original );
}
//clean up screenshots

0 comments on commit 832f0b8

Please sign in to comment.