Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WilliamConant opened this issue Dec 17, 2024 · 0 comments

Comments

@WilliamConant
Copy link

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));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant