Skip to content

Commit

Permalink
wmv's no longer require re-coding. using output seeking instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjay0 committed Nov 14, 2016
1 parent 03957c0 commit d8c86e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ Given the predictions for a frame each second, it takes the argmax of those pred
FFmpeg supports a lot of codecs including: mp4, avi, flv, mkv, wmv, and many more.
*Note: WMVs would stall at the beginning of each piece when cut without recoding, so Miles Deep re-encodes them automatically to MKV. If you know a better solution to this please let me know.*
###Single Frame vs Multiple Frames
This model doesn't make use of any temporal information since it treats each image separately. *Karpathy et al* showed that other models which use multiple frames don't perform much better. They have difficulty dealing with camera movement. It would still be interesting to compare their slow fusion model with the results here.
Expand Down
29 changes: 18 additions & 11 deletions cut_movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ bool queryYesNo()

std::string GetDirectory (const std::string& path)
{
size_t found = path.find_last_of("/\\");
return(path.substr(0, found));
int found = path.find_last_of("/\\");
if(found < 0)
return(".");
else
return(path.substr(0, found));
}


Expand Down Expand Up @@ -199,16 +202,13 @@ void cut( ScoreList score_list, string movie_file, vector<int> target_list, stri
}


//re-encode wmv into mkv to avoid pieces freezing when played
//(TODO:find a way without re-encoding)
string copy_args;
//use output_seek for wmv. fixed bug where cuts would freeze
bool output_seek = false;
if(movie_type == ".wmv" || movie_type == ".WMV" || movie_type == ".Wmv")
{
movie_type = ".mkv";
copy_args = "";
output_seek = true;
}
else
copy_args = " -c copy -avoid_negative_ts 1";


//output a file for each cut in the list
Expand All @@ -220,9 +220,16 @@ void cut( ScoreList score_list, string movie_file, vector<int> target_list, stri
string part_name = temp_path + '.' + to_string(i) + movie_type;
cout << " Creating piece: " << part_name << endl;

string cut_command = "ffmpeg -loglevel 8 -y -ss " + to_string(this_cut.s) +
" -i \"" + movie_file + "\" -t " + to_string(this_cut.e - this_cut.s) +
copy_args + " \"" + part_name + "\"";
string cut_command;
if(output_seek)
cut_command = "ffmpeg -loglevel 8 -y -i \"" + movie_file + "\" -ss " +
to_string(this_cut.s) + " -t " + to_string(this_cut.e - this_cut.s) +
" -c copy \"" + part_name + "\"";
else
cut_command = "ffmpeg -loglevel 8 -y -ss " + to_string(this_cut.s) +
" -i \"" + movie_file + "\" -t " + to_string(this_cut.e - this_cut.s) +
" -c copy -avoid_negative_ts 1 \"" + part_name + "\"";

if(system(cut_command.c_str()))
{
cerr << "Error cutting piece : " << part_name << endl;
Expand Down

0 comments on commit d8c86e0

Please sign in to comment.