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

[in#0 @ 0000013f512fcfc0] Error opening input: Invalid argument #24

Open
Skyknight47 opened this issue Feb 18, 2024 · 3 comments
Open

Comments

@Skyknight47
Copy link

Skyknight47 commented Feb 18, 2024

Getting this error. Tried with both .png and .jpg images.

  1. Yes the file path is correct
  2. Yes the file exists in said path.
  3. Yes it's a valid image.
Error opening input file 'Path/to/my/image.jpg'.
Error opening input files: Invalid argument

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  code: 4294967274,
  killed: false,
  signal: null,
  cmd: "path/to/ffmpeg/folder/ffmpeg.exe -y -i 'path/to/image.jpg' -vf scale=w=512:h=512:force_original_aspect_ratio=decrease:interl=1 -qscale:v 6 'path/to/output/image_compressed.jpg'"
imgSqueezer.load();
imgSqueezer.setBin('path/to/ffmpeg/folder/ffmpeg.exe');
imgSqueezer.setSourceFilePath(`path/to/results/folder`);

              // Provide the output file path of the compressed image.
              imgSqueezer.setOutputFilePath(`path/to/output/folder`);
               imgSqueezer.setCompressionLevel(FFMPegCompression.COMPRESSION_LEVEL_HIGH);

              imgSqueezer.build();
               let resultImage = await imgSqueezer.compress();

Any idea what is causing this?

@LordDashMe
Copy link
Owner

Hello @Skyknight47, thanks for raising this concern. To further assist with this matter, I would like to know the exact file path you've used for the setOutputFilePath

@Skyknight47
Copy link
Author

Skyknight47 commented Feb 22, 2024

Hey there.

I tried both the relative path;
imgSqueezer.setOutputFilePath(`/results/output-${attachment.name}_compressed\`);
and the full path;
imgSqueezer.setOutputFilePath(`C:/Users/mikeu/Desktop/Coding/AlphaBleeder/results/output-${attachment.name}_compressed`);

Regardless, I've managed to resolve this issue by using my own Shell Argument Escape function.
The issue apparently lies (at least I think so, as that's the only explanation I've got for it) is the fact that it doesn't remove the (single) quotation marks. nor the ` mark.

I fixed it by using the full path, with single quotation marks for both the input and output path, i.c.w my custom function which simply removes the marks before executing the shell command;

escapeShellArg(arg) {
        return arg.replace("'", "");
    }

Anyway, I've stumbled upon a new issue. When testing, I noticed my file size is bigger after compression.
See the screenshot for more info.
I was wondering what is causing this?
I've tried to compress on all 3 levels, all giving me fluctuating but all larger output files, rather than compressed, smaller size.

image

@LordDashMe
Copy link
Owner

Hey @Skyknight47, I would like to know what's the version of ffmpeg you're using when doing the compression?

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

2 participants