Skip to content

66 Bug/Enhancement: check_sp_output hangs indefinitely on frozen FFmpeg streams#67

Merged
abhiTronix merged 7 commits into
devfrom
66-bugenhancement-check_sp_output-hangs-indefinitely-on-frozen-ffmpeg-streams-2
May 9, 2026
Merged

66 Bug/Enhancement: check_sp_output hangs indefinitely on frozen FFmpeg streams#67
abhiTronix merged 7 commits into
devfrom
66-bugenhancement-check_sp_output-hangs-indefinitely-on-frozen-ffmpeg-streams-2

Conversation

@abhiTronix
Copy link
Copy Markdown
Owner

@abhiTronix abhiTronix commented May 5, 2026

Brief Description

The check_sp_output function should accept a timeout argument (via kwargs) to prevent indefinite hanging. If the timeout is reached, it should cleanly catch the subprocess.TimeoutExpired exception, terminate the process, flush the remaining buffer, and return the captured output without raising a CalledProcessError.

Requirements / Checklist

  • I have read the DeFFcode PR Guidelines.
  • I have read the DeFFcode Documentation.
  • I have updated the documentation files accordingly(if required).

Related Issue

#66

Context

This PR introduces timeout argument (via kwargs) to prevent indefinite hanging in check_sp_output function

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Miscellaneous (if available):

abhiTronix added 3 commits May 6, 2026 00:36
Add `DEFAULT_TIMEOUT_SUBPROCESS` env var and timeout handling in
`check_sp_output` with graceful process kill on expiry. Pass timeout
to device detection subprocess calls.
@abhiTronix abhiTronix added this to the v0.2.8 milestone May 5, 2026
@abhiTronix abhiTronix self-assigned this May 5, 2026
@abhiTronix abhiTronix added the Enhancement ⚡ New feature Issue/Request enhancing DeFFcode APIs. label May 5, 2026
@abhiTronix abhiTronix linked an issue May 5, 2026 that may be closed by this pull request
3 tasks
@abhiTronix abhiTronix added the WIP 🏗️ Work in Progress label May 5, 2026
@abhiTronix abhiTronix added the Bug Fix 🐛 💣 Bug fix in progress !!! label May 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0cbee028-25d9-4ce4-ae95-2d177f4ce7d5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces environment-configurable subprocess timeouts, refactors check_sp_output() to handle timeout expiry by terminating and re-communicating with subprocesses, updates device discovery and metadata probing to use explicit timeouts, modifies pixel-format extraction regex logic, and bumps the version to 0.2.8 alongside documentation updates.

Changes

Subprocess Timeout Support & Device Discovery Enhancement

Layer / File(s) Summary
Configuration Constants
deffcode/ffhelper.py
Added DEFAULT_TIMEOUT_SUBPROCESS (env-driven, default 3.0s) and converted DEFAULT_TIMEOUT to float sourced from environment variables.
Subprocess Timeout Handling
deffcode/ffhelper.py
Refactored check_sp_output() to accept optional timeout kwarg; on TimeoutExpired, kills subprocess and re-communicates to retrieve partial output; error handling adapted based on timeout occurrence.
FFmpeg Binary Download
deffcode/ffhelper.py
Updated HTTP adapter retry timeout to use DEFAULT_TIMEOUT_SUBPROCESS instead of hardcoded value in download_ffmpeg_binaries().
Device Discovery Integration
deffcode/ffhelper.py
Updated extract_device_n_demuxer() to pass timeout=DEFAULT_TIMEOUT_SUBPROCESS to all device-detection check_sp_output() calls; expanded Linux v4l2-ctl failure predicate.
Metadata Probing Integration
deffcode/sourcer.py
Imported DEFAULT_TIMEOUT_SUBPROCESS; updated metadata-probing check_sp_output() invocation in __validate_source() to explicitly pass timeout argument; added timeout to device enumeration validation calls.
Pixel Format Extraction Logic
deffcode/sourcer.py
Changed __extract_video_pixfmt() regex from Video:-prefix matching to comma-delimited codec/format token matching, altering the source of extracted pixel-format values.
Tests & Versioning
tests/test_ffhelper.py, deffcode/version.py
Updated test_check_sp_output() to pass explicit timeout=2.0 argument; incremented version from 0.2.7 to 0.2.8.
Documentation
README.md, docs/overrides/main.html
Updated webcam documentation link reference in README "Highly Adaptive" section and reformatted announcement link construction in template.

Possibly Related Issues

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Timeouts tamed with patient care,
Subprocesses caught mid-air,
Enviroment whispers, 3 seconds passed,
Device discovery fast, at last!
From 0.2.7 we leap with grace!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding configurable subprocess timeouts to prevent check_sp_output from hanging indefinitely on frozen FFmpeg streams.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 66-bugenhancement-check_sp_output-hangs-indefinitely-on-frozen-ffmpeg-streams-2

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@abhiTronix abhiTronix changed the base branch from master to dev May 5, 2026 19:12
@abhiTronix abhiTronix moved this to In Progress in VidGear + Deffcode May 5, 2026
@abhiTronix abhiTronix added the CI : Skipped 🎲 Skip Continuous Integration checks for this PR. label May 5, 2026
abhiTronix added 4 commits May 9, 2026 16:12
Increase default timeout value from 3.0 to 10.0 seconds and rename the
constant to better reflect its purpose as a maximum allowed timeout.
Replace immediate `process.kill()` with a SIGTERM-first approach,
waiting `TERMINATE_TIMEOUT_SUBPROCESS` seconds before escalating to
SIGKILL. Adds `TERMINATE_TIMEOUT_SUBPROCESS` env-configurable constant
(default 2s) and improves docstrings throughout `check_sp_output`.
@abhiTronix abhiTronix merged commit 210cb16 into dev May 9, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in VidGear + Deffcode May 9, 2026
@abhiTronix abhiTronix deleted the 66-bugenhancement-check_sp_output-hangs-indefinitely-on-frozen-ffmpeg-streams-2 branch May 9, 2026 11:45
@abhiTronix abhiTronix added Solved 🥅 Final goal achieved. and removed WIP 🏗️ Work in Progress labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix 🐛 💣 Bug fix in progress !!! CI : Skipped 🎲 Skip Continuous Integration checks for this PR. Enhancement ⚡ New feature Issue/Request enhancing DeFFcode APIs. Solved 🥅 Final goal achieved.

Projects

Development

Successfully merging this pull request may close these issues.

Bug/Enhancement: check_sp_output hangs indefinitely on frozen FFmpeg streams

1 participant