Skip to main content

A python tool based on ffmpeg that makes converting between different formats/codecs a whole lot easier for the inexperienced

Project description

MPEG-Convert

A highly customizable1 terminal-based Python wrapper for FFmpeg that provides a humanized approach to conversions between different multimedia formats.

FFmpeg is a powerful multimedia tool, but its many options2 can be especially overwhelming for new users. This wrapper aims to simplify the process of working with the FFmpeg engine to convert between different video/audio formats for the folks who doesn't want to memorize twenty options to use FFmpeg. This program is not, however, a complete replacement for FFmpeg in any way. For that purpose, you should look look into other software such as Handbrake or DaVinci Resolve.

This project is now hosted on PyPi, however legacy releases can still be found on the right.

Features

  • Simplified commands: MPEG-Convert provides a straightforward interface for commonly used FFmpeg functionalities, making it easy for both beginners and experienced users to perform tasks such as codec conversion, audio extraction, video compression, and much more.

  • Configurability: While MPEG-Convert is designed for simplicity, it also provides room for customization1. You can tweak advanced settings by specifying additional FFmpeg options in the script or during script execution, ensuring flexibility for more sophisticated multimedia processing needs.

demo

Installation

Make sure you have Python 3 and FFmpeg installed.

pip install --upgrade mpeg-convert
mpeg-convert --help

Customizing

Interactive

You can customize the interactive mode of the script by changing the questions variable VIDEO_OPTIONS and AUDIO_OPTIONS in mpeg-convert to your liking. This can be achieved using the --customize option, which will open the correct file for you in your default text editor.

The two variables represents the list of questions asked during video options and audio options sections of the script respectively. The properties of each question is represented as a dictionary in python, and will be shown to the user in order. The dictionaries' format is shown below:

[
    {
        "type": <str>,
        "title": <str>,
        "option": <str>,
        "default": <int>,
        "choices": <list[tuple]>
    }
]
  • type: The type of the question

    • Valid values:
      • choice: Multiple choice
      • input: Input field
  • title: The text shown to the console when displaying the question during the execution of the program

  • option: The corresponding option in FFmpeg. This option will be inserted to the list of arguments passed to FFmpeg

  • default: The default option that is used when the input field is empty. Has no effect if question type is input.

  • choices: A list of choices that will be shown to the console during the execution of the program. The choices will be in tuples where the first index will be what is displayed, and the second index is what is actually entered as a value for the particular FFmpeg option. Has no effect if question type is input.

An example of a custom question is below:

[
    {
        "type": "choice",
        "title": "Select an encoding preset",
        "option": "-preset",
        "default": 3,
        "choices": [
            ("Faster/lower quality", "veryfast"),
            ("Normal/medium quality", "medium"),
            ("Slower/best quality", "veryslow")
        ]
    }
]



Presets

Presets are different predetermined flags and options of FFmpeg options that mpeg-convert uses when you specify the name of the preset. Presets can be activated by specifying the name of the preset as a positional flag. You can customize them by modifying the PRESETS variable also located in customization.py.

The preset's format is shown below:

{
    "name": {
        "option": <str>,
        "option": <str>,
        "option": <str>,
        ...
    }
}
  • name: The name that is used to activate the preset

  • option: A command-line option to be inserted to the list of arguments passed to FFmpeg. The option should be stripped of the dash (-) symbol at the front. If the FFmpeg option does not take any value, put None after the colon. There can be more than one option in each preset.

An example of a custom preset is below:

{
    "flac-audio": {
        "vn": None,
        "ar": "96000",
        "codec:a": "flac",
        "sample_fmt": "s24",
    }
}

Troubleshooting

  • Do you have python installed?
  • Do you have ffmpeg installed?
  • Common pitfalls:
    • Does the output file have an extension?
    • Does the extension match the codec?
      • HEVC with .mp4
      • ALAC with .m4a
    • Is the encoder installed on your system?

Resources

Contributions are welcome! If you encounter any problems or find any bugs, please feel free to open an issue. In the meantime, happy converting!

--

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpeg-convert-0.1.0.tar.gz (18.1 kB view hashes)

Uploaded Source

Built Distribution

mpeg_convert-0.1.0-py3-none-any.whl (18.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page