Enhance FFmpeg option handling and add new flexibility #41
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.
Overview
This refactor introduces enhanced flexibility in the
audioconv
module by refining the way options are handled and applied within theconvertAudio
function. The changes allow users to specify minimal configurations while still leveraging the full capabilities offfmpeg
.Changes Made
Enhanced
resolveOptions
Logic:resolveOptions
function now returnsdefaultOptions
if the input is either an empty object or a non-object. This improvement ensures a more robust handling of edge cases where invalid or empty options are passed.useDefault
are now set tofalse
for compatibility with minimal FFmpeg options.Selective Application of FFmpeg Audio Options:
convertAudio
function has been updated to apply audio options (bitrate
,codec
,channels
,frequency
) only if they are explicitly provided by the user. This enhancement allows users to convert audio files with just the necessary settings, reducing the need for redundant configurations and prevent an error thrown byffmpeg
due toundefined
option has given.Benefits
resolveOptions
enhances the module’s robustness, avoiding potential issues from invalid inputs.It's now possible to convert an audio file by specifying only the output format, for examples:
Using
ytmp3
CLI:Using
convertAudio
API function: