refactor: centralize constants and de-duplicate processor.py (#4, #5, #6) - #4
Open
rsmxingu wants to merge 1 commit into
Open
refactor: centralize constants and de-duplicate processor.py (#4, #5, #6)#4rsmxingu wants to merge 1 commit into
rsmxingu wants to merge 1 commit into
Conversation
Three related cleanups in the processing pipeline, behavior-preserving (the generated ffmpeg/auto-editor command strings are unchanged): rsd#4 — Speed is no longer hardcoded and is read from config The 1.2x speedup was a literal in two places (two-pass and single-pass) and could not be changed without editing code. Added module-level constants (DEFAULT_SPEED, DEFAULT_CRF, DEFAULT_PRESET, DEFAULT_MARGIN, DEFAULT_THRESHOLD, AUDIO_BITRATE, INTRO_OVERLAY_SECONDS, DYNAUDNORM_FILTER) and made run() read speed_val from config (falling back to DEFAULT_SPEED), so the value is now configurable end-to-end. The same constants replace the magic numbers that previously had to be edited in several spots (e.g. recent commits that bumped CRF in multiple places). rsd#5 — De-duplicate clip speed parsing in build_filtergraph The "parse speed: effect + resolve target speed" block was copy-pasted three times (duration calc, video clips, audio clips). Extracted _clip_speed() and _target_speed() helpers; malformed effects now also tolerate IndexError, not just ValueError. rsd#6 — De-duplicate ffmpeg command construction The identical H.265 video + AAC audio argument block (two-pass and single-pass) is now built by _append_encode_args(). The two-pass intro-overlay branch no longer repeats the overlay filter string for the boost/no-boost cases. Tests: - Add TestClipSpeedHelpers covering _clip_speed / _target_speed (including the malformed-effect and speedup-disabled cases). - Existing build_filtergraph / run tests pass unchanged, confirming the generated filter and command strings are identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three related, behavior-preserving cleanups in
processor.py. The generated ffmpeg/auto-editor command and filter strings are byte-for-byte unchanged (verified by the existing tests).#4 — Speed is no longer hardcoded; defaults are centralized
The 1.2x speedup was a literal in two places and could not be changed without editing code. Added module-level constants and made
run()readspeed_valfromconfig(defaultDEFAULT_SPEED), so the value is configurable end-to-end.These replace magic numbers/strings that previously had to be edited in several spots (e.g. recent commits that bumped CRF in multiple places).
#5 — De-duplicate clip-speed parsing in
build_filtergraphThe "parse
speed:effect + resolve target speed" block was copy-pasted three times (duration calc, video clips, audio clips). Extracted_clip_speed()and_target_speed()helpers. Malformed effects now tolerateIndexErrorin addition toValueError.#6 — De-duplicate ffmpeg command construction
The identical H.265 video + AAC audio argument block (two-pass and single-pass) is now built by
_append_encode_args(). The two-pass intro-overlay branch no longer repeats the overlay filter string across the boost / no-boost cases.Tests
TestClipSpeedHelperscovering_clip_speed/_target_speed(no-effect, explicit speed, malformed effect, speedup-disabled).build_filtergraph/runtests pass unchanged → confirms identical generated strings.python3 -m unittest tests.test_processor→ 14 passed (no tkinter needed for this module).🤖 Generated with Claude Code