diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 5f513f4f2f1..e63f8bb940a 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -1223,8 +1223,8 @@ function App() { const loadEdlFile = useCallback(async ({ path, type, append }: { path: string, type: EdlFileType, append?: boolean }) => { console.log('Loading EDL file', type, path, append); - loadCutSegments(await readEdlFile({ type, path }), append); - }, [loadCutSegments]); + loadCutSegments(await readEdlFile({ type, path, fps: detectedFps }), append); + }, [detectedFps, loadCutSegments]); const loadSubtitleTrackToSegments = useCallback(async (streamId: number) => { invariant(filePath != null); diff --git a/src/renderer/src/cmx3600.ts b/src/renderer/src/cmx3600.ts index b1fbdf70cc6..2caa3ffdf89 100644 --- a/src/renderer/src/cmx3600.ts +++ b/src/renderer/src/cmx3600.ts @@ -10,10 +10,11 @@ export interface EDLEvent { } export default function parseCmx3600(edlContent: string) { - const lines = edlContent.split('\n'); + const [firstLine, ...lines] = edlContent.split('\n'); const events: EDLEvent[] = []; - for (const line of lines) { + // trim BOM from first line. + for (const line of [...(firstLine ? [firstLine.trim()] : []), ...lines]) { if (/^\d+\s+/.test(line)) { const parts = line.trim().split(/\s+/); if (parts.length >= 8) { diff --git a/src/renderer/src/edlFormats.ts b/src/renderer/src/edlFormats.ts index dcfcb6b113b..92caf4e65d6 100644 --- a/src/renderer/src/edlFormats.ts +++ b/src/renderer/src/edlFormats.ts @@ -184,7 +184,8 @@ export async function parseEdlCmx3600(text: string, fps: number) { } export async function parseEdl(text: string, fps: number) { - if (text.startsWith('TITLE: ')) return parseEdlCmx3600(text, fps); + // trim because it might have a BOM + if (text.trim().startsWith('TITLE: ')) return parseEdlCmx3600(text, fps); return parseMplayerEdl(text); } diff --git a/src/renderer/src/edlStore.ts b/src/renderer/src/edlStore.ts index a02e6b7f6e8..c21a6a723fe 100644 --- a/src/renderer/src/edlStore.ts +++ b/src/renderer/src/edlStore.ts @@ -105,11 +105,12 @@ export async function loadLlcProject(path: string) { }; } -export async function readEdlFile({ type, path, fps }: { type: EdlFileType, path: string, fps?: number | undefined }) { +export async function readEdlFile({ type, path, fps }: { type: EdlFileType, path: string, fps: number | undefined }) { if (type === 'csv') return loadCsvSeconds(path); - if (type === 'csv-frames') { + if (type === 'csv-frames' || type === 'edl') { invariant(fps != null, 'The loaded media has an unknown framerate'); - return loadCsvFrames(path, fps); + if (type === 'csv-frames') return loadCsvFrames(path, fps); + if (type === 'edl') return loadEdl(path, fps); } if (type === 'cutlist') return loadCutlistSeconds(path); if (type === 'xmeml') return loadXmeml(path); @@ -117,10 +118,6 @@ export async function readEdlFile({ type, path, fps }: { type: EdlFileType, path if (type === 'dv-analyzer-summary-txt') return loadDvAnalyzerSummaryTxt(path); if (type === 'cue') return loadCue(path); if (type === 'pbf') return loadPbf(path); - if (type === 'edl') { - invariant(fps != null, 'The loaded media has an unknown framerate'); - return loadEdl(path, fps); - } if (type === 'srt') return loadSrt(path); if (type === 'llc') { const project = await loadLlcProject(path);