Skip to content

Conversation

Masterain98
Copy link
Contributor

Context

According to MKVToolNix's documentation, the exit codes are as follows:

0: Muxing completed successfully.
1: Muxing completed with at least one warning. The user is urged to review the warning and resulting file.
2: An error occurred, and mkvmerge aborted.

In my recently usage, I found some media resource failed to mux with exit code 1, and never has a detailed error message.

error_details = err.decode()

I extracted the command line for the task and ran it directly in PowerShell with no errors. Whereas subprocess must return exit code 1 which in turn causes pymkv to raise an error and end the task prematurely, the fact is that there is nothing wrong with the output. So I decide to ignore the warning.

What's Changed

Previously, the mux method raised an exception for any non-zero exit code, including warnings. This behavior was overly restrictive for scenarios where warnings are acceptable, prompting the need for a more flexible implementation.

In this PR, when ignore_warning is set to True and mkvmerge exits with code 1 (warnings), the method will:

  1. Log a warning message indicating that warnings were ignored.
  2. Return the exit code without raising an exception.

For exit codes other than 0 or 1, the method raises a ValueError with detailed error output.

ignore_warning is set as False in default.

add `ignore_warning` parameter to `mux` function
@GitBib
Copy link
Owner

GitBib commented Dec 3, 2024

Great job! I'll review it.

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 66.73%. Comparing base (d0ef1cd) to head (3b939c5).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pymkv/MKVFile.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
- Coverage   66.84%   66.73%   -0.11%     
==========================================
  Files          10       10              
  Lines         947      950       +3     
==========================================
+ Hits          633      634       +1     
- Misses        314      316       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GitBib GitBib merged commit 756e079 into GitBib:master Dec 6, 2024
16 of 18 checks passed
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