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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -114,9 +114,10 @@ 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/Resolve Compatible XML."""
118
 
119
- master_id = f"masterfile-1"
 
120
 
121
  lines = []
122
  lines.append('<?xml version="1.0" encoding="UTF-8"?>')
@@ -166,25 +167,23 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
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
 
@@ -221,7 +220,7 @@ def generate_xml(sequence_name, segments, source_name, fps=25):
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)
@@ -424,7 +423,8 @@ if uploaded_file:
424
 
425
  if "transcript" in st.session_state:
426
  st.divider()
427
- with st.expander("Transcript Preview", expanded=True):
 
428
  for seg in st.session_state.transcript:
429
  st.markdown(f"**{seg['speaker']}:** {seg['text']}")
430
 
@@ -448,5 +448,8 @@ if uploaded_file:
448
  ext = "xml"
449
 
450
  st.subheader("Ready for Import")
451
- st.code(final_output, language="xml" if ext == "xml" else "text")
 
 
 
452
  st.download_button(f"Download .{ext.upper()}", data=final_output, file_name=f"junior_editor_cut.{ext}")
 
114
  return "\n".join(edl_lines)
115
 
116
  def generate_xml(sequence_name, segments, source_name, fps=25):
117
+ """Constructs a Hybrid XML compatible with both Premiere and Resolve."""
118
 
119
+ # Static UUID to ensure linking
120
+ master_id = "masterfile-1"
121
 
122
  lines = []
123
  lines.append('<?xml version="1.0" encoding="UTF-8"?>')
 
167
  lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
168
  lines.append(f'\t\t\t\t\t<masterclipid>{master_id}</masterclipid>')
169
 
170
+ # --- HYBRID FILE DEFINITION ---
171
+ # 1. <pathurl>: Used by Resolve.
172
+ # 2. <duration>: Used by Premiere (avoids "0 length" error).
173
+ # 3. NO <media> block: Avoids confusing Resolve.
174
  lines.append(f'\t\t\t\t\t<file id="{master_id}">')
175
  lines.append(f'\t\t\t\t\t\t<name>{source_name}</name>')
176
+ lines.append(f'\t\t\t\t\t\t<pathurl>file://localhost/{source_name}.mov</pathurl>')
177
  lines.append(f'\t\t\t\t\t\t<rate><timebase>{int(fps)}</timebase></rate>')
178
+ lines.append(f'\t\t\t\t\t\t<duration>8640000</duration>') # Fake 24h Duration
179
+ lines.append(f'\t\t\t\t\t\t<timecode>')
180
+ lines.append(f'\t\t\t\t\t\t\t<rate><timebase>{int(fps)}</timebase></rate>')
181
+ lines.append(f'\t\t\t\t\t\t\t<string>00:00:00:00</string>')
182
+ lines.append(f'\t\t\t\t\t\t\t<frame>0</frame>')
183
+ lines.append(f'\t\t\t\t\t\t\t<displayformat>NDF</displayformat>')
184
+ lines.append(f'\t\t\t\t\t\t</timecode>')
 
 
 
 
 
 
185
  lines.append(f'\t\t\t\t\t</file>')
186
+ # -------------------------------
187
 
188
  lines.append(f'\t\t\t\t</clipitem>')
189
 
 
220
  lines.append(f'\t\t\t\t\t<out>{src_out_frames}</out>')
221
  lines.append(f'\t\t\t\t\t<masterclipid>{master_id}</masterclipid>')
222
 
223
+ # Reuse same file definition
224
  lines.append(f'\t\t\t\t\t<file id="{master_id}"/>')
225
 
226
  # SOURCE TRACK MAPPING (Simple Mono)
 
423
 
424
  if "transcript" in st.session_state:
425
  st.divider()
426
+ # --- COLLAPSED DEFAULT ---
427
+ with st.expander("Transcript Preview", expanded=False):
428
  for seg in st.session_state.transcript:
429
  st.markdown(f"**{seg['speaker']}:** {seg['text']}")
430
 
 
448
  ext = "xml"
449
 
450
  st.subheader("Ready for Import")
451
+ # --- COLLAPSED DEFAULT ---
452
+ with st.expander("Show XML/EDL Code", expanded=False):
453
+ st.code(final_output, language="xml" if ext == "xml" else "text")
454
+
455
  st.download_button(f"Download .{ext.upper()}", data=final_output, file_name=f"junior_editor_cut.{ext}")