A pure Python library for creating, modifying, and parsing MLT XML files compatible with Kdenlive.
- Pure Python - No MLT framework dependency, direct XML manipulation
- Timecode API - All public methods accept
HH:MM:SS:FFformat - Frame Alignment - Library automatically converts timecodes to frame numbers
- Media Management - Add/modify/delete audio/video files in the bin
- Timeline Editing - Add clips, tracks, filters, and transitions
- Subtitle Support - External SRT file references
- Kdenlive Compatible - Generates XML that Kdenlive can open
uv pip install mlt-pythonpip install mlt-pythongit clone https://github.com/gpapp/mlt-python.git
cd mlt-python
uv syncfrom mlt_python import MLTProject
# Create a new project
project = MLTProject(profile="hd1080_30")
# Add media to bin
video = project.add_producer("video.mp4", id="vid1")
# Add a video track
track = project.add_track("video", id="playlist0")
# Add a clip using timecodes
project.add_clip(
track_id="playlist0",
producer_id="vid1",
start="00:00:00:00",
duration="00:00:10:00"
)
# Add subtitles from SRT file
project.add_subtitle("subtitles.srt", track=0, start="00:00:00:00")
# Save to file
project.save("project.kdenlive.xml")add_producer()- Add video/audio/image to binremove_producer()- Remove from binget_producer()- Get producer by ID
add_track()- Add video/audio trackremove_track()- Remove trackadd_clip()- Add clip to track using timecodes
add_filter()- Add filter to project/track- Built-in filters:
Filters.greyscale(),Filters.volume(),Filters.watermark()
add_transition()- Add transition between tracks- Built-in transitions:
Transitions.luma(),Transitions.mix(),Transitions.composite()
add_subtitle()- Add subtitles from SRT fileSRTFile- Utility class for reading/writing SRT files
hd1080_30- Full HD 1080p @ 30fpshd1080_2997- Full HD 1080p @ 29.97fpshd1080_25- Full HD 1080p @ 25fps (PAL)hd1080_24- Full HD 1080p @ 24fpshd720_30- HD 720p @ 30fpsuhd_30- 4K UHD @ 30fpsuhd_24- 4K UHD @ 24fpssdtv_ntsc- SD NTSC 480isdtv_pal- SD PAL 576i
See examples/example.py for a complete example showing:
- Multiple video/audio tracks
- B-roll with transitions
- Audio mixing
- Subtitle integration
- Filter effects
uv run pytest tests/ -vMIT License - see LICENSE file for details