Skip to content

Commit

Permalink
Fix for #59 cut video - duration not adjusted
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekmotyl committed Jul 30, 2022
1 parent 33d26be commit ea1a578
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/SimpleVideoCutter/FFmpegNET/FFmpegArgumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,41 @@ public static string BuildArgumentsSingleCutOperation(string inputFileFullPath,
if (lossless)
{
// Maybe also use -noaccurate_seek ?
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0:0.000} ", start.TotalSeconds);
if (VideoCutterSettings.Instance.LosslessInputSeeking)
{
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0:0.000} ", start.TotalSeconds);
}
commandBuilder.AppendFormat(" -i \"{0}\" ", inputFileFullPath);
commandBuilder.AppendFormat(" -codec copy -copyts ");
if (VideoCutterSettings.Instance.LosslessOutputSeeking && !VideoCutterSettings.Instance.LosslessInputSeeking)
{
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0:0.000} ", start.TotalSeconds);
}
commandBuilder.AppendFormat(" -codec copy ");
commandBuilder.AppendFormat(" -copyts ");
commandBuilder.AppendFormat(" -avoid_negative_ts make_zero ");

commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -to {0:0.000} ", end.TotalSeconds);
commandBuilder.AppendFormat(" -map 0:v -map 0:a ");
}
else
{
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0:0.000} ", start.TotalSeconds);
if (VideoCutterSettings.Instance.LossyInputSeeking)
{
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0:0.000} ", start.TotalSeconds);
}
commandBuilder.AppendFormat(" -i \"{0}\" ", inputFileFullPath);
if (VideoCutterSettings.Instance.LossyOutputSeeking && !VideoCutterSettings.Instance.LossyInputSeeking)
{
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0:0.000} ", start.TotalSeconds);
}
commandBuilder.AppendFormat(" -copyts ");
commandBuilder.AppendFormat(" -avoid_negative_ts make_zero ");
commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -to {0:0.000} ", end.TotalSeconds);
commandBuilder.AppendFormat(" -map 0:v -map 0:a ");
}

return commandBuilder.AppendFormat(" \"{0}\" ", outputFileFullPath).ToString();
var cmd = commandBuilder.AppendFormat(" \"{0}\" ", outputFileFullPath).ToString();
return cmd;
}
}
}
5 changes: 5 additions & 0 deletions src/SimpleVideoCutter/VideoCutterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class VideoCutterSettings
public Rectangle MainWindowLocation { get; set; } = Rectangle.Empty;
public bool MainWindowMaximized { get; set; } = false;
public bool RestoreToolbarsLayout { get; set; } = true;

public bool LosslessInputSeeking { get; set; } = true;
public bool LosslessOutputSeeking { get; set; } = false;
public bool LossyInputSeeking { get; set; } = true;
public bool LossyOutputSeeking { get; set; } = false;

public string ConfigVersion { get; set; } = "0.0.0";

Expand Down

0 comments on commit ea1a578

Please sign in to comment.