This is a Python script that converts MKV video files to MP4 format with no quality loss.
It utilizes ffmpeg
, a powerful multimedia processing tool, to perform the conversion.
This script provides a simple and efficient way to convert video formats while preserving the original quality.
- Lossless Conversion: Converts MKV to MP4 without re-encoding, preserving the original quality.
- User-Friendly: Clear command-line interface with colored output for better readability.
- Error Handling: Graceful error reporting and handling.
By default, the script uses the copy
codec for both video and audio, meaning that no re-encoding occurs.
However, you can specify different video and audio codecs as needed.
copy
: Directly copies the video stream without re-encoding (lossless).libx264
: Popular for MP4 output; provides excellent compression while maintaining quality.libx265
: More efficient compression compared to libx264, but may require more processing power.mpeg4
: An older codec, but compatible with many devices.
copy
: Directly copies the audio stream without re-encoding (lossless).aac
: Commonly used with MP4 files and provides good quality at lower bitrates.mp3
: Widely compatible, but lower quality compared to AAC for the same bitrate.ac3
: Often used for surround sound systems (Dolby Digital).
You can specify custom video and audio codecs when running the script. For example:
python main.py <input_file> <output_file> <video_codec> <audio_codec>
python main.py /home/test/file.mkv /home/test/file.mp4 libx264 aac
python main.py /home/test/file.mkv /home/test/file.mp4 copy copy
python main.py /home/test/file.mkv /home/test/file.mp4 libx265 mp3
python main.py /home/test/file.mkv /home/test/file.mp4 mpeg4 ac3
In each case, replace the placeholders <input_file>
, <output_file>
, <video_codec>
, and <audio_codec>
with the appropriate file paths and codec names.
Python 3.x
: Make sure you havePython3.x
installed.ffmpeg
: The script relies onffmpeg
for video processing.
- Clone the Repository:
git clone https://github.com/dragonGR/PyMKV2MP4.git
cd PyMKV2MP4
Ensure ffmpeg
is installed on your system.
To convert an MKV video file to MP4, use the following command:
python main.py <input_file> <output_file>
Replace <input_file>
with the path to your MKV file and <output_file>
with the desired path for the MP4 output.
python main.py /home/test/file.mkv /home/test/file.mp4