Skip to content

Conversation

@lucemia
Copy link
Contributor

@lucemia lucemia commented Jun 25, 2025

This pull request refactors the handling of codec and muxer options in the ffmpeg module to simplify the code and improve consistency. The most significant changes include removing the kwargs parameter from FFMpegMuxerOption and directly passing merged options, as well as updating related functions to reflect this change.

Refactoring of codec and muxer options:

  • src/ffmpeg/codecs/schema.py: Removed the @dataclass decorator from FFMpegEncoderOption and FFMpegDecoderOption, simplifying their definitions.
  • src/ffmpeg/dag/io/_input.py: Updated the input function to pass decoder_options and demuxer_options directly instead of accessing their kwargs attributes.
  • src/ffmpeg/dag/io/_output.py: Updated the output function to pass encoder_options and muxer_options directly instead of accessing their kwargs attributes. [1] [2]

Simplification of FFMpegMuxerOption:

  • src/ffmpeg/formats/muxers.py: Removed the kwargs parameter from FFMpegMuxerOption in multiple functions, directly passing merged options instead. This change affects functions such as _3g2, _3gp, a64, ac3, ac4, and many others. [1] [2] [3] [4] [5] and more)

@lucemia lucemia requested a review from Copilot June 25, 2025 17:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how FFmpeg option groups are represented (moving from dataclass/kwargs to a dict subclass) and updates all call sites, templates, and snapshots accordingly.

  • Replace Serializable/FrozenDict‐based option groups with dict[str, Any] subclasses.
  • Update function calls and Jinja templates to use positional merge(...) rather than kwargs=merge(...) or accessing .kwargs.
  • Refresh test snapshots to match the new merge signatures.

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ffmpeg/schema.py Convert FFMpegOptionGroup from a dataclass to dict subclass.
src/ffmpeg/formats/schema.py / src/ffmpeg/codecs/schema.py Remove dataclass wrappers for muxer/encoder/decoder options.
All src/ffmpeg/formats/*.py and src/ffmpeg/codecs/*.py Change FFMpeg*Option(kwargs=merge(...)) to FFMpeg*Option(merge(...)).
src/ffmpeg/dag/io/*.py Replace *.options.kwargs if ... else {} with passing the object directly.
src/scripts/code_gen/templates/**/*.jinja Update templates to generate the new positional merge calls.
src/scripts/code_gen/tests/snapshots Update snapshots to reflect removed .kwargs usage.
Comments suppressed due to low confidence (1)

src/ffmpeg/dag/io/output_args.py:344

  • Passing encoder_options directly to merge may pass None if no options were provided, causing a runtime error. Consider using encoder_options or {} (and similarly for muxer_options) so that merge always receives a mapping.
                encoder_options,

@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 1.76991% with 111 lines in your changes missing coverage. Please review.

Project coverage is 80.60%. Comparing base (d7b1e2d) to head (7c43eb1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/ffmpeg/formats/muxers.py 0.00% 111 Missing ⚠️

❌ Your patch status has failed because the patch coverage (1.76%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project status has failed because the head coverage (78.49%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #733      +/-   ##
==========================================
- Coverage   80.63%   80.60%   -0.03%     
==========================================
  Files          67       67              
  Lines        4410     4404       -6     
==========================================
- Hits         3556     3550       -6     
  Misses        854      854              
Flag Coverage Δ
3.10 78.49% <1.76%> (-0.04%) ⬇️
3.11 78.46% <1.76%> (-0.04%) ⬇️
3.12 78.46% <1.76%> (?)
backend 78.49% <1.76%> (-0.04%) ⬇️
python 78.49% <1.76%> (-0.04%) ⬇️
python-3.10 86.85% <ø> (ø)
scripts 86.85% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/ffmpeg/codecs/schema.py 100.00% <ø> (ø)
src/ffmpeg/dag/io/_input.py 100.00% <ø> (ø)
src/ffmpeg/dag/io/_output.py 100.00% <ø> (ø)
src/ffmpeg/dag/io/output_args.py 100.00% <ø> (ø)
src/ffmpeg/formats/demuxers.py 50.34% <ø> (ø)
src/ffmpeg/formats/schema.py 100.00% <ø> (ø)
src/ffmpeg/schema.py 100.00% <100.00%> (ø)
src/ffmpeg/formats/muxers.py 50.67% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lucemia lucemia marked this pull request as ready for review June 25, 2025 17:11
@lucemia lucemia merged commit a66556d into main Jun 25, 2025
9 of 11 checks passed
@lucemia lucemia deleted the refactor-option-group branch June 25, 2025 17:11
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.

2 participants