Skip to content

Bug identified in BaseSubVideo(...) with output filename, causing output to be placed in subdirectory with filename #554

Description

@WilliamConant

2 issues:

  1. The extension comparison should be case-insensitive, so ".MP4" == ".mp4"
  2. When the extensions don't match, the Path.Combine(...) puts the output filename w/o extension as a subdirectory of the output directory, instead of as the filename. I.E. for output = "C:\Temp\FooBar.MP4" and input extension = ".mp4", the output file is set to "C:\Temp\FooBar.mp4" instead of "C:\Temp\FooBar.mp4". An exception occurs, because the new subdirectory "FooBar" doesn't exist.

Code snippet shown below.

private static FFMpegArgumentProcessor BaseSubVideo(string input, string output, TimeSpan startTime, TimeSpan endTime)
{
if (Path.GetExtension(input) != Path.GetExtension(output))
{
output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output), Path.GetExtension(input));
}
.
.
.
}

private static FFMpegArgumentProcessor BaseSubVideo(string input, string output, TimeSpan startTime, TimeSpan endTime) { if (Path.GetExtension(input) != Path.GetExtension(output)) { output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output), Path.GetExtension(input)); } . . . }

The code snippet should look like this (although invariant versions could be used)):

if (Path.GetExtension(input).ToLower() != Path.GetExtension(output).ToLower())
{
output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output) + Path.GetExtension(input));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions