fix(shotcut): set tractor out= before melt render to avoid 4-hour output#92
Open
jarrodcolburn wants to merge 2 commits intoHKUDS:mainfrom
Open
fix(shotcut): set tractor out= before melt render to avoid 4-hour output#92jarrodcolburn wants to merge 2 commits intoHKUDS:mainfrom
jarrodcolburn wants to merge 2 commits intoHKUDS:mainfrom
Conversation
When clips are added to the timeline, the MLT tractor element is created with out="00:00:00.000" and never updated. The background track defaults to out="04:00:00.000" (a Shotcut convention). Without an explicit tractor out, melt falls back to the longest track and renders a ~4-hour file instead of the actual content duration. Fix: calculate the real content duration from all non-background playlists (summing entry in/out spans and blank lengths), then set out= on the tractor, background playlist entry, and black producer before writing the temp MLT. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Shotcut/MLT exports rendered via melt producing excessively long (≈4-hour) outputs by ensuring the main <tractor> and background elements have a correct out= matching actual timeline content duration.
Changes:
- Added
_set_tractor_out()to compute timeline duration from playlists and settractor out=. - Invoked
_set_tractor_out()before writing the temp.mltused bymelt. - Added
.worktrees/to.gitignore.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
shotcut/agent-harness/cli_anything/shotcut/core/export.py |
Computes/sets tractor and background out= before melt render to avoid 4-hour default background duration. |
shotcut/agent-harness/.gitignore |
Ignores .worktrees/ directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| elif child.tag == "blank": | ||
| try: | ||
| total += timecode_to_frames(child.get("length", "0"), fps_num, fps_den) | ||
| except Exception: |
Comment on lines
+452
to
+465
| if max_frames > 0: | ||
| out_tc = frames_to_timecode(max_frames - 1, fps_num, fps_den) | ||
| tractor.set("out", out_tc) | ||
| # Cap the background track to the same duration so melt doesn't | ||
| # extend the render to the 4-hour background default. | ||
| bg_playlist = mlt_xml.find_element_by_id(session.root, "background") | ||
| if bg_playlist is not None: | ||
| for entry in bg_playlist.findall("entry"): | ||
| entry.set("out", out_tc) | ||
| black_producer = session.root.find(".//producer[@id='black']") | ||
| if black_producer is not None: | ||
| black_producer.set("out", out_tc) | ||
|
|
||
|
|
Comment on lines
+473
to
+476
| # Fix tractor out before rendering — without this melt renders the full | ||
| # 4-hour background track instead of the actual content duration. | ||
| _set_tractor_out(session) | ||
|
|
Comment on lines
+415
to
+421
| def _set_tractor_out(session: Session) -> None: | ||
| """Set tractor out= to actual timeline duration before passing to melt. | ||
|
|
||
| The tractor is created with out="00:00:00.000" and never updated as clips | ||
| are added. Without this fix, melt falls back to the longest track in the | ||
| multitrack — the 4-hour black background — and renders a 4-hour file. | ||
| """ |
Comment on lines
+442
to
+443
| in_f = timecode_to_frames(child.get("in", "0"), fps_num, fps_den) | ||
| out_f = timecode_to_frames(child.get("out", "0"), fps_num, fps_den) |
Collaborator
|
are all items in the test plan passed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
<tractor>element is created without="00:00:00.000"and never updatedout="04:00:00.000"(a Shotcut convention for an open-ended timeline)out,meltfalls back to the longest track and renders a ~4-hour file instead of the actual content durationFix
Added
_set_tractor_out()helper inexport.pythat runs before writing the temp MLT file for melt rendering:entryin/out spans andblanklengths across all non-background playlistsout=on the tractor elementTest Plan
uv run --with pytest python -m pytest cli_anything/shotcut/tests/test_core.py)export renderon a project with a 6-second clip produces a 6-second output (previously produced ~500s)🤖 Generated with Claude Code