Skip to content

Conversation

@seajaysec
Copy link

@seajaysec seajaysec commented Oct 7, 2024

I really liked the original sample-shrinker.sh and wanted to improve its performance by adding parallel processing. Since managing parallelization in Bash is tricky, I decided to rewrite the script in Python.

What’s included:

  • Python Port: I’ve ported the entire Bash script into Python, keeping all the original functionality like bit-depth reduction, auto-mono conversion, and channel adjustments.
  • Parallel Processing (-j option): Added support for running multiple jobs in parallel, which significantly speeds up the conversion process, especially for directories with lots of files.
  • Performance Improvements: The Python version performs much faster than the original Bash script, especially when using the -j flag with multiple jobs. In testing, it handles large directories more efficiently.
  • Consistent Behavior: I’ve run both the Bash and Python versions on the same directories, and they produce identical results, except where certain malformed wav files produced errors. There is now automatic correction logic in place that attempts to fix those, then fails over to leaving them as-is if they cannot be fixed easily.
  • Logging & Error Handling: The Python script includes more detailed logging and improved error handling, including automatic handling of certain audio format issues with malformed wav files that could cause failures in the Bash version.

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.

1 participant