mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 19:52:44 +01:00
parent
2364edad7f
commit
6ac77c5eea
@ -95,6 +95,59 @@ Array [
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`parses xmeml - with multiple tracks 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"end": 11,
|
||||
"start": 0,
|
||||
},
|
||||
Object {
|
||||
"end": 4.08,
|
||||
"start": 0.96,
|
||||
},
|
||||
Object {
|
||||
"end": 3.88,
|
||||
"start": 1.12,
|
||||
},
|
||||
Object {
|
||||
"end": 4.32,
|
||||
"start": 0.84,
|
||||
},
|
||||
Object {
|
||||
"end": 3.36,
|
||||
"start": 0.36,
|
||||
},
|
||||
Object {
|
||||
"end": 6.24,
|
||||
"start": 0.36,
|
||||
},
|
||||
Object {
|
||||
"end": 4.52,
|
||||
"start": 0.24,
|
||||
},
|
||||
Object {
|
||||
"end": 2.48,
|
||||
"start": 0.48,
|
||||
},
|
||||
Object {
|
||||
"end": 2.36,
|
||||
"start": 0.48,
|
||||
},
|
||||
Object {
|
||||
"end": 1.36,
|
||||
"start": 0.36,
|
||||
},
|
||||
Object {
|
||||
"end": 1.36,
|
||||
"start": 0.36,
|
||||
},
|
||||
Object {
|
||||
"end": 1.04,
|
||||
"start": 0.36,
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`parses xmeml 1 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
|
@ -6,7 +6,6 @@ import csvStringify from 'csv-stringify/lib/browser';
|
||||
import pify from 'pify';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { formatDuration } from './util/duration';
|
||||
import { invertSegments, sortSegments } from './segments';
|
||||
|
||||
@ -138,15 +137,22 @@ export function parseXmeml(xmlStr) {
|
||||
if (!xmeml) throw Error('Root element <xmeml> not found in file');
|
||||
|
||||
let sequence;
|
||||
if (_.property('project.children.sequence.media.video.track.clipitem')(xmeml)) {
|
||||
|
||||
if (xmeml.project?.children?.sequence) {
|
||||
sequence = xmeml.project.children.sequence;
|
||||
} else if (_.property('sequence.media.video.track.clipitem')(xmeml)) {
|
||||
} else if (xmeml.sequence) {
|
||||
sequence = xmeml.sequence;
|
||||
} else {
|
||||
throw Error('No <clipitem> elements found in file');
|
||||
throw new Error('No <sequence> element found');
|
||||
}
|
||||
|
||||
return sequence.media.video.track.clipitem.map((item) => ({ start: item.in / item.rate.timebase, end: item.out / item.rate.timebase }));
|
||||
if (!sequence?.media?.video?.track) {
|
||||
throw new Error('No <track> element found');
|
||||
}
|
||||
|
||||
const mainTrack = Array.isArray(sequence.media.video.track) ? sequence.media.video.track[0] : sequence.media.video.track;
|
||||
|
||||
return mainTrack.clipitem.map((item) => ({ start: item.in / item.rate.timebase, end: item.out / item.rate.timebase }));
|
||||
}
|
||||
|
||||
export function parseYouTube(str) {
|
||||
|
@ -159,6 +159,11 @@ it('parses xmeml 2', async () => {
|
||||
expect(await parseXmeml(await readFixture('Final Cut Pro XMEML 2.xml'))).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// see https://github.com/mifi/lossless-cut/issues/1195
|
||||
it('parses xmeml - with multiple tracks', async () => {
|
||||
expect(await parseXmeml(await readFixture('Final Cut Pro XMEML 3.xml'))).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// https://github.com/mifi/lossless-cut/issues/1024
|
||||
const csvFramesStr = `\
|
||||
0,155,EP106_SQ010_SH0010
|
||||
|
Loading…
Reference in New Issue
Block a user