Skip to content

Commit

Permalink
Fix for issue Alkl58#47
Browse files Browse the repository at this point in the history
  • Loading branch information
youer-mam authored May 31, 2022
1 parent 8559358 commit 7a4a20c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion NotEnoughAV1Encodes/Video/VideoSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,31 @@ private void PySceneDetectParse()
// Iterates over the list of time codes and creates the args for ffmpeg
foreach (string sc in scenes)
{
FFmpegArgs.Add("-ss " + previousScene + " -to " + sc);
// ffmpeg will sometimes output an extra frame when segment end
// time is the same as the start time of the next segment.
// decrementing end by 1 ms seems to fix this

// parse tc to int ms and decrement
string[] code = sc.Split(":");
int hour = Int32.Parse(code[0]);
int min = Int32.Parse(code[1]);
string[] code2 = code[2].Split(".");
int sec = Int32.Parse(code2[0]);
int ms = Int32.Parse(code2[1]);
int ms_tc = ((((((hour * 60) + min) * 60) + sec) * 1000) + ms) - 1;

// back to tc
// note that ffmpeg will take seconds so we could probably
// just as easily pass ms_tc / 1000.0 (untested)
ms = ms_tc % 1000;
ms_tc /= 1000;
sec = ms_tc % 60;
ms_tc /= 60;
min = ms_tc % 60;
hour = ms_tc / 60;
string endScene = string.Format("{0:00}:{1:00}:{2:00}.{3:000}", hour, min, sec, ms);

FFmpegArgs.Add("-ss " + previousScene + " -to " + endScene);
previousScene = sc;
}

Expand Down

0 comments on commit 7a4a20c

Please sign in to comment.