NickVerri commited on
Commit
db959eb
·
verified ·
1 Parent(s): 1c34fec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -15
app.py CHANGED
@@ -114,10 +114,9 @@ def generate_cmx_edl(edl_title, segments, source_name, fps=25):
114
  return "\n".join(edl_lines)
115
 
116
  def generate_xml(sequence_name, segments, source_name, fps=25):
117
- """Constructs a Premiere-Safe Final Cut Pro 7 XML."""
118
 
119
- # Generate a persistent ID for the source file
120
- master_id = f"master-{uuid.uuid4()}"
121
 
122
  lines = []
123
  lines.append('<?xml version="1.0" encoding="UTF-8"?>')
@@ -152,7 +151,10 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
152
 
153
  tl_start = timeline_head_frames
154
  tl_end = tl_start + duration_frames
155
- clip_note = seg.get('note', 'Junior Editor Selection')
 
 
 
156
 
157
  lines.append(f'\t\t\t\t<clipitem id="clipitem-v-{i}">')
158
  lines.append(f'\t\t\t\t\t<name>{clip_note}</name>')
@@ -164,12 +166,26 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
164
  lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
165
  lines.append(f'\t\t\t\t\t<masterclipid>{master_id}</masterclipid>')
166
 
167
- # File Reference (Clean for Premiere/Resolve)
168
  lines.append(f'\t\t\t\t\t<file id="{master_id}">')
169
  lines.append(f'\t\t\t\t\t\t<name>{source_name}</name>')
170
  lines.append(f'\t\t\t\t\t\t<rate><timebase>{int(fps)}</timebase></rate>')
 
 
171
  lines.append(f'\t\t\t\t\t\t<timecode><string>00:00:00:00</string><displayformat>NDF</displayformat></timecode>')
 
 
 
 
 
 
 
 
 
 
172
  lines.append(f'\t\t\t\t\t</file>')
 
 
173
  lines.append(f'\t\t\t\t</clipitem>')
174
 
175
  gap_seconds = seg.get('gap', 0.0)
@@ -181,13 +197,6 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
181
 
182
  # --- AUDIO TRACK ---
183
  lines.append('\t\t<audio>')
184
- lines.append('\t\t\t<numOutputChannels>2</numOutputChannels>')
185
- lines.append('\t\t\t<format>')
186
- lines.append('\t\t\t\t<samplecharacteristics>')
187
- lines.append('\t\t\t\t\t<depth>16</depth>')
188
- lines.append('\t\t\t\t\t<samplerate>48000</samplerate>')
189
- lines.append('\t\t\t\t</samplecharacteristics>')
190
- lines.append('\t\t\t</format>')
191
  lines.append('\t\t\t<track>')
192
 
193
  timeline_head_frames = 0
@@ -198,7 +207,9 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
198
 
199
  tl_start = timeline_head_frames
200
  tl_end = tl_start + duration_frames
201
- clip_note = seg.get('note', 'Junior Editor Selection')
 
 
202
 
203
  lines.append(f'\t\t\t\t<clipitem id="clipitem-a-{i}">')
204
  lines.append(f'\t\t\t\t\t<name>{clip_note}</name>')
@@ -210,9 +221,10 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
210
  lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
211
  lines.append(f'\t\t\t\t\t<masterclipid>{master_id}</masterclipid>')
212
 
 
213
  lines.append(f'\t\t\t\t\t<file id="{master_id}"/>')
214
 
215
- # SOURCE TRACK MAPPING
216
  lines.append('\t\t\t\t\t<sourcetrack>')
217
  lines.append('\t\t\t\t\t\t<mediatype>audio</mediatype>')
218
  lines.append('\t\t\t\t\t\t<trackindex>1</trackindex>')
@@ -279,7 +291,7 @@ st.markdown("""
279
  * Set your timeline FPS and transcription quality.
280
  * Junior Editor will transcribe and separate speakers. You can then instruct it to find engaging bits or construct a narrative.
281
  * It will create an EDL or XML to import back into your editing software (Resolve, Premiere).
282
- * **For Multicam Workflows:** Use the **XML** option in the sidebar and enter the **exact name** of your Multicam Sequence. Uncheck "**Automatically import source clips into media pool**" when importing into DaVinci Resolve.
283
  """)
284
 
285
  st.divider()
 
114
  return "\n".join(edl_lines)
115
 
116
  def generate_xml(sequence_name, segments, source_name, fps=25):
117
+ """Constructs a Premiere/Resolve Compatible XML."""
118
 
119
+ master_id = f"masterfile-1"
 
120
 
121
  lines = []
122
  lines.append('<?xml version="1.0" encoding="UTF-8"?>')
 
151
 
152
  tl_start = timeline_head_frames
153
  tl_end = tl_start + duration_frames
154
+
155
+ # Truncate clip names for Premiere safety (max 80 chars)
156
+ raw_note = seg.get('note', 'Junior Editor Selection')
157
+ clip_note = (raw_note[:75] + '..') if len(raw_note) > 75 else raw_note
158
 
159
  lines.append(f'\t\t\t\t<clipitem id="clipitem-v-{i}">')
160
  lines.append(f'\t\t\t\t\t<name>{clip_note}</name>')
 
166
  lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
167
  lines.append(f'\t\t\t\t\t<masterclipid>{master_id}</masterclipid>')
168
 
169
+ # --- FILE DEFINITION (Crucial for Premiere) ---
170
  lines.append(f'\t\t\t\t\t<file id="{master_id}">')
171
  lines.append(f'\t\t\t\t\t\t<name>{source_name}</name>')
172
  lines.append(f'\t\t\t\t\t\t<rate><timebase>{int(fps)}</timebase></rate>')
173
+ # Fake duration (24 hours) allows Premiere to accept any timecode range
174
+ lines.append(f'\t\t\t\t\t\t<duration>8640000</duration>')
175
  lines.append(f'\t\t\t\t\t\t<timecode><string>00:00:00:00</string><displayformat>NDF</displayformat></timecode>')
176
+ # Define Media structure explicitly
177
+ lines.append(f'\t\t\t\t\t\t<media>')
178
+ lines.append(f'\t\t\t\t\t\t\t<video>')
179
+ lines.append(f'\t\t\t\t\t\t\t\t<samplecharacteristics><width>1920</width><height>1080</height></samplecharacteristics>')
180
+ lines.append(f'\t\t\t\t\t\t\t</video>')
181
+ lines.append(f'\t\t\t\t\t\t\t<audio>')
182
+ lines.append(f'\t\t\t\t\t\t\t\t<samplecharacteristics><depth>16</depth><samplerate>48000</samplerate></samplecharacteristics>')
183
+ lines.append(f'\t\t\t\t\t\t\t\t<channelcount>2</channelcount>')
184
+ lines.append(f'\t\t\t\t\t\t\t</audio>')
185
+ lines.append(f'\t\t\t\t\t\t</media>')
186
  lines.append(f'\t\t\t\t\t</file>')
187
+ # -----------------------
188
+
189
  lines.append(f'\t\t\t\t</clipitem>')
190
 
191
  gap_seconds = seg.get('gap', 0.0)
 
197
 
198
  # --- AUDIO TRACK ---
199
  lines.append('\t\t<audio>')
 
 
 
 
 
 
 
200
  lines.append('\t\t\t<track>')
201
 
202
  timeline_head_frames = 0
 
207
 
208
  tl_start = timeline_head_frames
209
  tl_end = tl_start + duration_frames
210
+
211
+ raw_note = seg.get('note', 'Junior Editor Selection')
212
+ clip_note = (raw_note[:75] + '..') if len(raw_note) > 75 else raw_note
213
 
214
  lines.append(f'\t\t\t\t<clipitem id="clipitem-a-{i}">')
215
  lines.append(f'\t\t\t\t\t<name>{clip_note}</name>')
 
221
  lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
222
  lines.append(f'\t\t\t\t\t<masterclipid>{master_id}</masterclipid>')
223
 
224
+ # REUSE File ID (Do not redefine)
225
  lines.append(f'\t\t\t\t\t<file id="{master_id}"/>')
226
 
227
+ # SOURCE TRACK MAPPING (Simple Mono)
228
  lines.append('\t\t\t\t\t<sourcetrack>')
229
  lines.append('\t\t\t\t\t\t<mediatype>audio</mediatype>')
230
  lines.append('\t\t\t\t\t\t<trackindex>1</trackindex>')
 
291
  * Set your timeline FPS and transcription quality.
292
  * Junior Editor will transcribe and separate speakers. You can then instruct it to find engaging bits or construct a narrative.
293
  * It will create an EDL or XML to import back into your editing software (Resolve, Premiere).
294
+ * **For Multicam Workflows:** Use the **XML** option in the sidebar and enter the **exact name** of your Multicam Sequence. **Uncheck "Automatically import source clips into media pool" when importing into DaVinci Resolve.**
295
  """)
296
 
297
  st.divider()