Skip to content

[bugfix] Ignore extra spaces in ffmpeg arguments (#634) - #635

Merged
Breakthrough merged 2 commits into
Breakthrough:mainfrom
leninworld:fix-ffmpeg-args-spaces
Nov 29, 2026
Merged

Breakthrough merged 2 commits into
Breakthrough:mainfrom
leninworld:fix-ffmpeg-args-spaces

Conversation

@leninworld

@leninworld leninworld commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes issue #634.

split_video_ffmpeg built the ffmpeg arguments with arg_override.split(" "), so a doubled, leading, or trailing space produced an empty argument. ffmpeg then failed with Error opening output files: Invalid argument and no scene was written.

The fix drops the empty tokens. It still splits on the ASCII space only, so tabs, newlines, and other Unicode whitespace inside a value reach ffmpeg as before.

Behavior changes (also in the changelog):

  • CLI: an all-space -a is treated like -a "", as if not set, so config-file args and then the built-in defaults apply.
  • API: an empty or all-space arg_override runs ffmpeg with no extra codec or -map arguments instead of failing.
  • A doubled space can no longer be used to pass an empty value to ffmpeg.

Not covered here: quoted values containing spaces are still not supported, and the CLI still logs "Video splitting completed" when ffmpeg returns an error.

Tests: test_split_video_ffmpeg_arg_override_whitespace (8 cases) and test_cli_split_video_empty_args_use_defaults (2 cases); neither runs ffmpeg. With the resources branch, pytest tests --ignore=tests/release gives 763 passed, 3 skipped (macOS, Python 3.12). ruff check and ruff format --check pass, and pyright on the changed files reports 0 errors.

Fixes #634

@Breakthrough Breakthrough left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the changelog as well and call out any breaking behaviours there. Should we normalize it so passing all spaces for -a is also treated as if it was not set, so that we fallback to the default args?

I'm not sure what the right call is here, might be worth seeing if there's any precedent for this in other projects. I mention this because if for some reason someone is evaluating a shell expression to determine the value of -a, if that script or variable evaluates to a space, it might not be expected that the args are cleared from PySceneDetect's defaults. Thoughts?

Thanks for the bug report + PR.

Comment thread tests/test_output.py


@pytest.mark.parametrize(
("arg_override", "expected"),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add cases for "". " ", and " " here (all of which should map to [])?

…kthrough#634)

An all-space -a/--args now behaves like -a "": config-file args and then the
built-in defaults apply. split_video_ffmpeg is unchanged; an empty or all-space
arg_override passes no extra arguments, now documented and tested.
@leninworld

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed 47d8f8f:

Feedback Change
Changelog, with breaking behaviour called out Added a [bugfix] entry under 0.7.4 with two Breaking: sub-bullets (changelog.md).
Treat all-space -a as not set? Done in the CLI (see below).
Cases for "", " ", " " Added to the parametrized test; all three map to [].

On the question: I'd fall back to the defaults on the CLI. The closest precedent is in the command itself: -a "" already counts as unset there (elif not args), so -a " " from a script or variable now does the same, including config-file args. Only ASCII spaces count, matching how the string is split.

I left split_video_ffmpeg as your test comment describes: an explicit empty or all-space arg_override passes no extra arguments, and omitting it uses the default (now in the docstring). If you'd rather have the API fall back too, or the CLI keep passing nothing, it's a small change.

Checks: pytest tests --ignore=tests/release gives 763 passed, 3 skipped (macOS, Python 3.12); the new CLI test fails without the CLI change; ruff check, ruff format --check and pyright on the changed files pass.

@Breakthrough Breakthrough left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@Breakthrough
Breakthrough merged commit 2d8dc34 into Breakthrough:main Nov 29, 2026
27 checks passed
@leninworld

Copy link
Copy Markdown
Contributor Author

Thanks for the PR!

Thank you @Breakthrough

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

Successfully merging this pull request may close these issues.

split-video: extra spaces in -a/--args make ffmpeg fail with "Invalid argument"

2 participants