MCPcopy
hub / github.com/mifi/editly / readVideoFileInfo

Function readVideoFileInfo

util.js:31–52  ·  view source on GitHub ↗
(ffprobePath, p)

Source from the content-addressed store, hash-verified

29}
30
31export async function readVideoFileInfo(ffprobePath, p) {
32 const streams = await readFileStreams(ffprobePath, p);
33 const stream = streams.find((s) => s.codec_type === 'video'); // TODO
34
35 const duration = await readDuration(ffprobePath, p);
36
37 let rotation = parseInt(stream.tags && stream.tags.rotate, 10);
38
39 // If we can't find rotation, try side_data_list
40 if (Number.isNaN(rotation) && Array.isArray(stream.side_data_list) && stream.side_data_list[0] && stream.side_data_list[0].rotation) {
41 rotation = parseInt(stream.side_data_list[0].rotation, 10);
42 }
43
44 return {
45 // numFrames: parseInt(stream.nb_frames, 10),
46 duration,
47 width: stream.width, // TODO coded_width?
48 height: stream.height,
49 framerateStr: stream.r_frame_rate,
50 rotation: !Number.isNaN(rotation) ? rotation : undefined,
51 };
52}
53
54export async function readAudioFileInfo(ffprobePath, p) {
55 const duration = await readDuration(ffprobePath, p);

Callers 1

parseConfigFunction · 0.90

Calls 2

readFileStreamsFunction · 0.85
readDurationFunction · 0.85

Tested by

no test coverage detected