modules.addons.convert

Audio File Converter using FFmpeg

A flexible audio conversion tool that supports multiple input formats and provides various conversion options including output format selection, metadata preservation, bitrate adjustment, and bit depth selection.

Functions

main()

Main function for the audio converter.

parse_arguments()

Parse command line arguments.

Classes

AudioConverter(options)

Audio file converter using FFmpeg to convert between various audio formats with options for metadata preservation, bitrate, bit depth, and other settings.

class modules.addons.convert.AudioConverter(options: Dict[str, Any])[source]

Bases: object

Audio file converter using FFmpeg to convert between various audio formats with options for metadata preservation, bitrate, bit depth, and other settings.

Initialize the AudioConverter with the specified options.

Parameters:

options (dict) – Dictionary of conversion options

__init__(options: Dict[str, Any])[source]

Initialize the AudioConverter with the specified options.

Parameters:

options (dict) – Dictionary of conversion options

get_file_info(filepath: str) Dict[str, Any][source]

Get detailed information about an audio file using FFprobe.

Parameters:

filepath (str) – Path to the audio file

Returns:

Dictionary containing file information

Return type:

dict

display_file_info(filepath: str)[source]

Display detailed information about an audio file.

Parameters:

filepath (str) – Path to the audio file

build_ffmpeg_command(input_file: str, output_file: str) List[str][source]

Build the FFmpeg command for audio conversion based on the options.

Parameters:
  • input_file (str) – Path to the input file

  • output_file (str) – Path to the output file

Returns:

FFmpeg command as a list of arguments

Return type:

list

convert_file(input_file: str, output_dir: str | None = None) bool[source]

Convert a single audio file to the specified format.

Parameters:
  • input_file (str) – Path to the input file

  • output_dir (str, optional) – Output directory. If None, use the input directory.

Returns:

True if conversion was successful, False otherwise

Return type:

bool

convert_directory(input_dir: str, output_dir: str | None = None) Tuple[int, int][source]

Convert all audio files in a directory to the specified format.

Parameters:
  • input_dir (str) – Input directory containing audio files

  • output_dir (str, optional) – Output directory. If None, use the input directory.

Returns:

(number of successful conversions, total number of files attempted)

Return type:

tuple

modules.addons.convert.parse_arguments()[source]

Parse command line arguments.

Returns:

Parsed arguments

Return type:

argparse.Namespace

modules.addons.convert.main()[source]

Main function for the audio converter.