Update app.py
Browse files
app.py
CHANGED
|
@@ -127,7 +127,10 @@ def generate_cmx_edl(edl_title, segments, source_name, fps=25):
|
|
| 127 |
return "\n".join(edl_lines)
|
| 128 |
|
| 129 |
def generate_xml(sequence_name, segments, source_name, fps=25):
|
| 130 |
-
"""Constructs a
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
# FPS Logic
|
| 133 |
timebase = int(round(fps))
|
|
@@ -168,10 +171,8 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
|
|
| 168 |
tl_end = tl_start + duration_frames
|
| 169 |
|
| 170 |
raw_note = seg.get('note', 'Junior Editor Selection')
|
| 171 |
-
# Truncate for safety
|
| 172 |
clip_note = (raw_note[:75] + '..') if len(raw_note) > 75 else raw_note
|
| 173 |
|
| 174 |
-
# Unique ID for every single clip item to prevent "Master Clip" logic grouping
|
| 175 |
clip_id = f"clip-v-{i}-{uuid.uuid4()}"
|
| 176 |
|
| 177 |
lines.append(f'\t\t\t\t<clipitem id="{clip_id}">')
|
|
@@ -183,9 +184,11 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
|
|
| 183 |
lines.append(f'\t\t\t\t\t<in>{src_in_frames}</in>')
|
| 184 |
lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
|
| 185 |
|
| 186 |
-
#
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
| 189 |
lines.append(f'\t\t\t\t\t\t<name>{source_name}</name>')
|
| 190 |
lines.append(f'\t\t\t\t\t\t<rate><timebase>{timebase}</timebase></rate>')
|
| 191 |
lines.append(f'\t\t\t\t\t\t<duration>8640000</duration>')
|
|
@@ -195,7 +198,6 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
|
|
| 195 |
lines.append(f'\t\t\t\t\t\t\t<frame>0</frame>')
|
| 196 |
lines.append(f'\t\t\t\t\t\t\t<displayformat>NDF</displayformat>')
|
| 197 |
lines.append(f'\t\t\t\t\t\t</timecode>')
|
| 198 |
-
# Reel name helps Resolve link if file name fails
|
| 199 |
lines.append(f'\t\t\t\t\t\t<reel><name>{source_name}</name></reel>')
|
| 200 |
lines.append(f'\t\t\t\t\t\t<media>')
|
| 201 |
lines.append(f'\t\t\t\t\t\t\t<video>')
|
|
@@ -207,7 +209,7 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
|
|
| 207 |
lines.append(f'\t\t\t\t\t\t\t</audio>')
|
| 208 |
lines.append(f'\t\t\t\t\t\t</media>')
|
| 209 |
lines.append(f'\t\t\t\t\t</file>')
|
| 210 |
-
# -------------------------------
|
| 211 |
|
| 212 |
lines.append(f'\t\t\t\t</clipitem>')
|
| 213 |
|
|
@@ -234,7 +236,6 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
|
|
| 234 |
raw_note = seg.get('note', 'Junior Editor Selection')
|
| 235 |
clip_note = (raw_note[:75] + '..') if len(raw_note) > 75 else raw_note
|
| 236 |
|
| 237 |
-
# Unique ID for audio clip too
|
| 238 |
clip_id = f"clip-a-{i}-{uuid.uuid4()}"
|
| 239 |
|
| 240 |
lines.append(f'\t\t\t\t<clipitem id="{clip_id}">')
|
|
@@ -246,28 +247,8 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
|
|
| 246 |
lines.append(f'\t\t\t\t\t<in>{src_in_frames}</in>')
|
| 247 |
lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
|
| 248 |
|
| 249 |
-
#
|
| 250 |
-
lines.append(f'\t\t\t\t\t<file id="
|
| 251 |
-
lines.append(f'\t\t\t\t\t\t<name>{source_name}</name>')
|
| 252 |
-
lines.append(f'\t\t\t\t\t\t<rate><timebase>{timebase}</timebase></rate>')
|
| 253 |
-
lines.append(f'\t\t\t\t\t\t<duration>8640000</duration>')
|
| 254 |
-
lines.append(f'\t\t\t\t\t\t<timecode>')
|
| 255 |
-
lines.append(f'\t\t\t\t\t\t\t<rate><timebase>{timebase}</timebase></rate>')
|
| 256 |
-
lines.append(f'\t\t\t\t\t\t\t<string>00:00:00:00</string>')
|
| 257 |
-
lines.append(f'\t\t\t\t\t\t\t<frame>0</frame>')
|
| 258 |
-
lines.append(f'\t\t\t\t\t\t\t<displayformat>NDF</displayformat>')
|
| 259 |
-
lines.append(f'\t\t\t\t\t\t</timecode>')
|
| 260 |
-
lines.append(f'\t\t\t\t\t\t<reel><name>{source_name}</name></reel>')
|
| 261 |
-
lines.append(f'\t\t\t\t\t\t<media>')
|
| 262 |
-
lines.append(f'\t\t\t\t\t\t\t<video>')
|
| 263 |
-
lines.append(f'\t\t\t\t\t\t\t\t<samplecharacteristics><width>1920</width><height>1080</height></samplecharacteristics>')
|
| 264 |
-
lines.append(f'\t\t\t\t\t\t\t</video>')
|
| 265 |
-
lines.append(f'\t\t\t\t\t\t\t<audio>')
|
| 266 |
-
lines.append(f'\t\t\t\t\t\t\t\t<samplecharacteristics><depth>16</depth><samplerate>48000</samplerate></samplecharacteristics>')
|
| 267 |
-
lines.append(f'\t\t\t\t\t\t\t\t<channelcount>2</channelcount>')
|
| 268 |
-
lines.append(f'\t\t\t\t\t\t\t</audio>')
|
| 269 |
-
lines.append(f'\t\t\t\t\t\t</media>')
|
| 270 |
-
lines.append(f'\t\t\t\t\t</file>')
|
| 271 |
|
| 272 |
# SOURCE TRACK MAPPING
|
| 273 |
lines.append('\t\t\t\t\t<sourcetrack>')
|
|
@@ -340,7 +321,7 @@ st.markdown("""
|
|
| 340 |
* It will create an EDL or XML to import back into your editing software (Resolve, Premiere).
|
| 341 |
* **For Multicam Workflows:** Use the **XML** option in the sidebar and enter the **exact name** of your Multicam Sequence.
|
| 342 |
* **Resolve Users:** Uncheck "Automatically import source clips into media pool" during import.
|
| 343 |
-
* **Premiere Users:** Import the XML.
|
| 344 |
""")
|
| 345 |
|
| 346 |
st.divider()
|
|
|
|
| 127 |
return "\n".join(edl_lines)
|
| 128 |
|
| 129 |
def generate_xml(sequence_name, segments, source_name, fps=25):
|
| 130 |
+
"""Constructs a Clean XML with SINGLE Source for clean Bin import."""
|
| 131 |
+
|
| 132 |
+
# 1. SHARED SOURCE ID (Crucial for Single Bin Item)
|
| 133 |
+
unified_file_id = "unified-source-1"
|
| 134 |
|
| 135 |
# FPS Logic
|
| 136 |
timebase = int(round(fps))
|
|
|
|
| 171 |
tl_end = tl_start + duration_frames
|
| 172 |
|
| 173 |
raw_note = seg.get('note', 'Junior Editor Selection')
|
|
|
|
| 174 |
clip_note = (raw_note[:75] + '..') if len(raw_note) > 75 else raw_note
|
| 175 |
|
|
|
|
| 176 |
clip_id = f"clip-v-{i}-{uuid.uuid4()}"
|
| 177 |
|
| 178 |
lines.append(f'\t\t\t\t<clipitem id="{clip_id}">')
|
|
|
|
| 184 |
lines.append(f'\t\t\t\t\t<in>{src_in_frames}</in>')
|
| 185 |
lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
|
| 186 |
|
| 187 |
+
# NOTE: NO <masterclipid> here. This prevents the "Reset to Start" bug.
|
| 188 |
+
|
| 189 |
+
# --- UNIFIED FILE DEFINITION ---
|
| 190 |
+
# We reuse the exact same file ID. This forces one bin item.
|
| 191 |
+
lines.append(f'\t\t\t\t\t<file id="{unified_file_id}">')
|
| 192 |
lines.append(f'\t\t\t\t\t\t<name>{source_name}</name>')
|
| 193 |
lines.append(f'\t\t\t\t\t\t<rate><timebase>{timebase}</timebase></rate>')
|
| 194 |
lines.append(f'\t\t\t\t\t\t<duration>8640000</duration>')
|
|
|
|
| 198 |
lines.append(f'\t\t\t\t\t\t\t<frame>0</frame>')
|
| 199 |
lines.append(f'\t\t\t\t\t\t\t<displayformat>NDF</displayformat>')
|
| 200 |
lines.append(f'\t\t\t\t\t\t</timecode>')
|
|
|
|
| 201 |
lines.append(f'\t\t\t\t\t\t<reel><name>{source_name}</name></reel>')
|
| 202 |
lines.append(f'\t\t\t\t\t\t<media>')
|
| 203 |
lines.append(f'\t\t\t\t\t\t\t<video>')
|
|
|
|
| 209 |
lines.append(f'\t\t\t\t\t\t\t</audio>')
|
| 210 |
lines.append(f'\t\t\t\t\t\t</media>')
|
| 211 |
lines.append(f'\t\t\t\t\t</file>')
|
| 212 |
+
# -------------------------------
|
| 213 |
|
| 214 |
lines.append(f'\t\t\t\t</clipitem>')
|
| 215 |
|
|
|
|
| 236 |
raw_note = seg.get('note', 'Junior Editor Selection')
|
| 237 |
clip_note = (raw_note[:75] + '..') if len(raw_note) > 75 else raw_note
|
| 238 |
|
|
|
|
| 239 |
clip_id = f"clip-a-{i}-{uuid.uuid4()}"
|
| 240 |
|
| 241 |
lines.append(f'\t\t\t\t<clipitem id="{clip_id}">')
|
|
|
|
| 247 |
lines.append(f'\t\t\t\t\t<in>{src_in_frames}</in>')
|
| 248 |
lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
|
| 249 |
|
| 250 |
+
# REUSE UNIFIED FILE ID
|
| 251 |
+
lines.append(f'\t\t\t\t\t<file id="{unified_file_id}"/>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
# SOURCE TRACK MAPPING
|
| 254 |
lines.append('\t\t\t\t\t<sourcetrack>')
|
|
|
|
| 321 |
* It will create an EDL or XML to import back into your editing software (Resolve, Premiere).
|
| 322 |
* **For Multicam Workflows:** Use the **XML** option in the sidebar and enter the **exact name** of your Multicam Sequence.
|
| 323 |
* **Resolve Users:** Uncheck "Automatically import source clips into media pool" during import.
|
| 324 |
+
* **Premiere Users:** Import the XML. A **single** offline clip will appear in your bin. Hold **Alt (Win) / Option (Mac)** and drag your Multicam Sequence from the bin onto this **single** offline clip to link the entire timeline instantly.
|
| 325 |
""")
|
| 326 |
|
| 327 |
st.divider()
|