Repository navigation
[bugfix] Ignore extra spaces in ffmpeg arguments (#634) - #635
Conversation
Breakthrough
left a comment
There was a problem hiding this comment.
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.
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("arg_override", "expected"), |
There was a problem hiding this comment.
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.
|
Thanks for the review. Pushed 47d8f8f:
On the question: I'd fall back to the defaults on the CLI. The closest precedent is in the command itself: I left Checks: |
Thank you @Breakthrough |
This PR fixes issue #634.
split_video_ffmpegbuilt the ffmpeg arguments witharg_override.split(" "), so a doubled, leading, or trailing space produced an empty argument. ffmpeg then failed withError opening output files: Invalid argumentand 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):
-ais treated like-a "", as if not set, so config-fileargsand then the built-in defaults apply.arg_overrideruns ffmpeg with no extra codec or-maparguments instead of failing.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) andtest_cli_split_video_empty_args_use_defaults(2 cases); neither runs ffmpeg. With the resources branch,pytest tests --ignore=tests/releasegives 763 passed, 3 skipped (macOS, Python 3.12).ruff checkandruff format --checkpass, andpyrighton the changed files reports 0 errors.Fixes #634