refactor(ffmpeg): 拆分 FFmpegTool — 硬件检测 / ffprobe 独立模块#76
Merged
Conversation
P3 后续 — 拆分 FFmpegTool 三职责: - 新增 video_tools/hardware.py: HWAccelType + detect_hw_accel / 各 _check_* / ffmpeg_supports_encoder / get_hw_accel_encoder(FFmpeg 编码器探测经统一 执行器,nvidia-smi/wmic 保留裸 subprocess) - 新增 video_tools/probe.py: run_ffprobe_json + get_duration/resolution/ framerate/bitrate/video_info - ffmpeg_tool.py 瘦身为业务便捷门面(trim/concat/extract_audio 等保留), 硬件/探测方法改薄委托;HWAccelType 从 hardware 再导出 - __init__.py 导出 hardware / probe 子模块 - 向后兼容:FFmpegTool.* 调用面与 HWAccelType 导出不变(测试 patch 底座 SecureExecutor.run,全部照过);新增 2 个测试覆盖拆出模块 回归: ruff 通过, pytest 597 passed / 11 skipped, mypy 改动文件 0 新增错误
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.
概述
P3 当初有意跳过的遗留项:把
FFmpegTool(812 行)的三类职责拆开。改动
video_tools/hardware.py:HWAccelType+ 硬件加速检测(detect_hw_accel/_check_nvidia_smi/_check_vaapi/_check_intel_cpu/ffmpeg_supports_encoder/get_hw_accel_encoder)video_tools/probe.py:ffprobe 元数据(run_ffprobe_json+get_duration/resolution/framerate/bitrate/video_info)ffmpeg_tool.py瘦身为业务便捷门面:trim/concat/extract_audio/缩略图/转码等保留;硬件 + 探测方法改薄委托;HWAccelType从 hardware 再导出向后兼容
FFmpegTool.*调用面与HWAccelType导出完全不变(外部 40+ 处调用、测试 patch 底座SecureExecutor.run全部照过)。验收