Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Dec 21, 2024
1 parent fe76825 commit 59f117a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/src/cmx3600.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/edlFormats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
11 changes: 4 additions & 7 deletions src/renderer/src/edlStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,19 @@ 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);
if (type === 'fcpxml') return loadFcpXml(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);
Expand Down

0 comments on commit 59f117a

Please sign in to comment.