@soga/mediainfo 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +61 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +17 -6
- package/src/index.ts +0 -238
- package/tsconfig.json +0 -8
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare function parseMediaRaw(media_path: string): Promise<any>;
|
|
2
|
+
declare function parseMediaInfo(media_path: string): Promise<{
|
|
3
|
+
audio: AudioTrackInfo[];
|
|
4
|
+
video: VideoTrackInfo[];
|
|
5
|
+
text: TextTrackInfo[];
|
|
6
|
+
general: GeneralInfo;
|
|
7
|
+
}>;
|
|
8
|
+
type GeneralInfo = {
|
|
9
|
+
audioCount: number;
|
|
10
|
+
videoCount: number;
|
|
11
|
+
textCount: number;
|
|
12
|
+
fileSize: number;
|
|
13
|
+
codec: string;
|
|
14
|
+
title: string;
|
|
15
|
+
duration: number;
|
|
16
|
+
extra?: {
|
|
17
|
+
duration: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type AudioTrackInfo = {
|
|
21
|
+
is_default: boolean;
|
|
22
|
+
order: number;
|
|
23
|
+
codec: string;
|
|
24
|
+
bitrate: number;
|
|
25
|
+
framerate: number;
|
|
26
|
+
sample_rate: number;
|
|
27
|
+
channels: number;
|
|
28
|
+
duration: number;
|
|
29
|
+
lossless: boolean;
|
|
30
|
+
};
|
|
31
|
+
type VideoTrackInfo = {
|
|
32
|
+
is_default: boolean;
|
|
33
|
+
order: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
codec: string;
|
|
37
|
+
profile: string;
|
|
38
|
+
framerate: number;
|
|
39
|
+
bitrate: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
bitdepth: number;
|
|
42
|
+
format_profile: string;
|
|
43
|
+
format_tier: string;
|
|
44
|
+
};
|
|
45
|
+
type TextTrackInfo = {
|
|
46
|
+
is_default: boolean;
|
|
47
|
+
codec: string;
|
|
48
|
+
order: number;
|
|
49
|
+
duration: number;
|
|
50
|
+
language?: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
is_vtt?: boolean;
|
|
53
|
+
};
|
|
54
|
+
type Mediainfo = {
|
|
55
|
+
general?: GeneralInfo;
|
|
56
|
+
audio?: AudioTrackInfo[];
|
|
57
|
+
video?: VideoTrackInfo[];
|
|
58
|
+
text?: TextTrackInfo[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { type AudioTrackInfo, type GeneralInfo, type Mediainfo, type TextTrackInfo, type VideoTrackInfo, parseMediaInfo, parseMediaRaw };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare function parseMediaRaw(media_path: string): Promise<any>;
|
|
2
|
+
declare function parseMediaInfo(media_path: string): Promise<{
|
|
3
|
+
audio: AudioTrackInfo[];
|
|
4
|
+
video: VideoTrackInfo[];
|
|
5
|
+
text: TextTrackInfo[];
|
|
6
|
+
general: GeneralInfo;
|
|
7
|
+
}>;
|
|
8
|
+
type GeneralInfo = {
|
|
9
|
+
audioCount: number;
|
|
10
|
+
videoCount: number;
|
|
11
|
+
textCount: number;
|
|
12
|
+
fileSize: number;
|
|
13
|
+
codec: string;
|
|
14
|
+
title: string;
|
|
15
|
+
duration: number;
|
|
16
|
+
extra?: {
|
|
17
|
+
duration: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type AudioTrackInfo = {
|
|
21
|
+
is_default: boolean;
|
|
22
|
+
order: number;
|
|
23
|
+
codec: string;
|
|
24
|
+
bitrate: number;
|
|
25
|
+
framerate: number;
|
|
26
|
+
sample_rate: number;
|
|
27
|
+
channels: number;
|
|
28
|
+
duration: number;
|
|
29
|
+
lossless: boolean;
|
|
30
|
+
};
|
|
31
|
+
type VideoTrackInfo = {
|
|
32
|
+
is_default: boolean;
|
|
33
|
+
order: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
codec: string;
|
|
37
|
+
profile: string;
|
|
38
|
+
framerate: number;
|
|
39
|
+
bitrate: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
bitdepth: number;
|
|
42
|
+
format_profile: string;
|
|
43
|
+
format_tier: string;
|
|
44
|
+
};
|
|
45
|
+
type TextTrackInfo = {
|
|
46
|
+
is_default: boolean;
|
|
47
|
+
codec: string;
|
|
48
|
+
order: number;
|
|
49
|
+
duration: number;
|
|
50
|
+
language?: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
is_vtt?: boolean;
|
|
53
|
+
};
|
|
54
|
+
type Mediainfo = {
|
|
55
|
+
general?: GeneralInfo;
|
|
56
|
+
audio?: AudioTrackInfo[];
|
|
57
|
+
video?: VideoTrackInfo[];
|
|
58
|
+
text?: TextTrackInfo[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { type AudioTrackInfo, type GeneralInfo, type Mediainfo, type TextTrackInfo, type VideoTrackInfo, parseMediaInfo, parseMediaRaw };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,s=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let u of o(t))n.call(e,u)||u===i||r(e,u,{get:()=>t[u],enumerable:!(s=a(t,u))||s.enumerable});return e},u={};((e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})})(u,{parseMediaInfo:()=>m,parseMediaRaw:()=>c}),module.exports=(e=u,s(r({},"__esModule",{value:!0}),e));var d=require("fs-extra"),l=((e,a,o)=>(o=null!=e?t(i(e)):{},s(!a&&e&&e.__esModule?o:r(o,"default",{value:e,enumerable:!0}),e)))(require("mediainfo.js")),f=require("@soga/error");async function c(e){try{const t=await(0,l.default)({format:"JSON"}),r="string"==typeof e?[e]:e;let a=0;const o=[];for await(const[e,t]of r.entries()){const{size:r}=await(0,d.stat)(t);o.push({index:e,start:a,end:a+r-1,size:r,file_path:t}),a+=r}const i=async(e,t)=>{if(!e)return new Uint8Array(0);const r=t,a=t+e-1,i=o.find(e=>e.start<=r&&e.end>=r),n=o.find(e=>e.start<=a&&e.end>=a);if(!i||!n)return new Uint8Array(0);const s=[];if(i.index===n.index)s.push({index:i.index,file_path:i.file_path,from:r-i.start,to:a-i.start});else{s.push({index:i.index,file_path:i.file_path,from:r-i.start,to:i.end});for(let e=i.index+1;e<n.index;e++){const t=o[e];t&&s.push({index:t.index,file_path:t.file_path,from:0,to:t.size-1})}s.push({index:n.index,file_path:n.file_path,from:0,to:a-n.start})}const u=[];for await(const e of s){const{file_path:t,from:r,to:a}=e,o=(0,d.createReadStream)(t,{start:r,end:a});for await(const e of o)u.push(e);o.close()}return Buffer.concat(u)},n=await t.analyzeData(()=>a,i);try{return JSON.parse(n)}catch(e){const t=n.replace(',"":{}]}]}',',"":{}}]}');return JSON.parse(t)}}catch(t){throw console.log("statck:"),console.log(t.stack),(0,f.buildDError)(t,{message:"Failed to parse raw mediainfo",detail:`Failed to parse raw mediainfo: ${e}`})}}async function m(e){try{const t=await c(e),r=t.media.track,a={audio:[],video:[],text:[],general:{}};let o=0,i=0,n=0;return r.forEach(e=>{const t=e["@type"];"Audio"===t?a.audio.push({is_default:"Yes"===e.Default,codec:e.Format.toLowerCase(),order:o++,bitrate:Number(e.BitRate),framerate:Number(e.FrameRate),sample_rate:Number(e.SamplingRate),duration:Number(e.Duration),channels:Number(e.Channels),lossless:"Lossless"===e.Compression_Mode}):"Text"===t?a.text.push({is_default:"Yes"===e.Default,codec:e.Format.toLowerCase(),order:n++,duration:Number(e.Duration),title:e.Title||e.Language,language:e.Language}):"Video"===t?a.video.push({is_default:"Yes"===e.Default,codec:e.Format.toLowerCase(),order:i++,width:Number(e.Width),height:Number(e.Height),profile:e.Format_Profile,bitrate:Number(e.BitRate),framerate:Number(e.FrameRate)?Math.round(Number(e.FrameRate)):0,duration:Number(e.Duration),bitdepth:Number(e.BitDepth),format_profile:e.Format_Profile,format_tier:e.Format_Tier}):"General"===t&&(a.general={audioCount:Number(e.AudioCount),textCount:Number(e.TextCount)||0,videoCount:Number(e.VideoCount),fileSize:Number(e.FileSize),title:e.Title||"",duration:Number(e.Duration),codec:e.Format},!a.general.duration&&e.extra?.duration&&(a.general.duration=Number(e.extra.duration)))}),a}catch(t){throw(0,f.buildDError)(t,{message:"Failed to parse mediainfo",detail:`Failed to parse mediainfo: ${e}`})}}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createReadStream as e,stat as t}from"fs-extra";import a from"mediainfo.js";import{buildDError as r}from"@soga/error";async function o(o){try{const r=await a({format:"JSON"}),i="string"==typeof o?[o]:o;let n=0;const s=[];for await(const[e,a]of i.entries()){const{size:r}=await t(a);s.push({index:e,start:n,end:n+r-1,size:r,file_path:a}),n+=r}const u=async(t,a)=>{if(!t)return new Uint8Array(0);const r=a,o=a+t-1,i=s.find(e=>e.start<=r&&e.end>=r),n=s.find(e=>e.start<=o&&e.end>=o);if(!i||!n)return new Uint8Array(0);const u=[];if(i.index===n.index)u.push({index:i.index,file_path:i.file_path,from:r-i.start,to:o-i.start});else{u.push({index:i.index,file_path:i.file_path,from:r-i.start,to:i.end});for(let e=i.index+1;e<n.index;e++){const t=s[e];t&&u.push({index:t.index,file_path:t.file_path,from:0,to:t.size-1})}u.push({index:n.index,file_path:n.file_path,from:0,to:o-n.start})}const d=[];for await(const t of u){const{file_path:a,from:r,to:o}=t,i=e(a,{start:r,end:o});for await(const e of i)d.push(e);i.close()}return Buffer.concat(d)},d=await r.analyzeData(()=>n,u);try{return JSON.parse(d)}catch(e){const t=d.replace(',"":{}]}]}',',"":{}}]}');return JSON.parse(t)}}catch(e){throw console.log("statck:"),console.log(e.stack),r(e,{message:"Failed to parse raw mediainfo",detail:`Failed to parse raw mediainfo: ${o}`})}}async function i(e){try{const t=await o(e),a=t.media.track,r={audio:[],video:[],text:[],general:{}};let i=0,n=0,s=0;return a.forEach(e=>{const t=e["@type"];"Audio"===t?r.audio.push({is_default:"Yes"===e.Default,codec:e.Format.toLowerCase(),order:i++,bitrate:Number(e.BitRate),framerate:Number(e.FrameRate),sample_rate:Number(e.SamplingRate),duration:Number(e.Duration),channels:Number(e.Channels),lossless:"Lossless"===e.Compression_Mode}):"Text"===t?r.text.push({is_default:"Yes"===e.Default,codec:e.Format.toLowerCase(),order:s++,duration:Number(e.Duration),title:e.Title||e.Language,language:e.Language}):"Video"===t?r.video.push({is_default:"Yes"===e.Default,codec:e.Format.toLowerCase(),order:n++,width:Number(e.Width),height:Number(e.Height),profile:e.Format_Profile,bitrate:Number(e.BitRate),framerate:Number(e.FrameRate)?Math.round(Number(e.FrameRate)):0,duration:Number(e.Duration),bitdepth:Number(e.BitDepth),format_profile:e.Format_Profile,format_tier:e.Format_Tier}):"General"===t&&(r.general={audioCount:Number(e.AudioCount),textCount:Number(e.TextCount)||0,videoCount:Number(e.VideoCount),fileSize:Number(e.FileSize),title:e.Title||"",duration:Number(e.Duration),codec:e.Format},!r.general.duration&&e.extra?.duration&&(r.general.duration=Number(e.extra.duration)))}),r}catch(t){throw r(t,{message:"Failed to parse mediainfo",detail:`Failed to parse mediainfo: ${e}`})}}export{i as parseMediaInfo,o as parseMediaRaw};
|
package/package.json
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soga/mediainfo",
|
|
3
|
-
"
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.0.0",
|
|
4
7
|
"main": "./dist/index.js",
|
|
5
8
|
"module": "./dist/index.mjs",
|
|
6
9
|
"types": "./dist/index.d.ts",
|
|
7
10
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
11
|
+
"demo": "tsx ./demo/demo.ts",
|
|
12
|
+
"build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts --minify terser",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
10
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
11
18
|
"keywords": [],
|
|
12
19
|
"author": "",
|
|
13
20
|
"license": "ISC",
|
|
14
21
|
"description": "",
|
|
15
22
|
"dependencies": {
|
|
23
|
+
"@soga/error": "^1.0.6",
|
|
16
24
|
"fs-extra": "^11.3.0",
|
|
17
|
-
"mediainfo.js": "^0.3.5"
|
|
18
|
-
"tsup": "^8.5.0"
|
|
25
|
+
"mediainfo.js": "^0.3.5"
|
|
19
26
|
},
|
|
20
27
|
"devDependencies": {
|
|
21
|
-
"@types/fs-extra": "^11.0.4"
|
|
28
|
+
"@types/fs-extra": "^11.0.4",
|
|
29
|
+
"rimraf": "^6.0.1",
|
|
30
|
+
"terser": "^5.43.1",
|
|
31
|
+
"tsup": "^8.5.0",
|
|
32
|
+
"tsx": "^4.20.3"
|
|
22
33
|
}
|
|
23
34
|
}
|
package/src/index.ts
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { createReadStream } from "fs-extra";
|
|
2
|
-
import { stat } from "fs/promises";
|
|
3
|
-
import getMediainfo, { FormatType, MediaInfo } from "mediainfo.js";
|
|
4
|
-
|
|
5
|
-
export async function parseMediaRaw(media_path: string) {
|
|
6
|
-
const mediainfo: MediaInfo<FormatType> = await getMediainfo({
|
|
7
|
-
format: "JSON" as FormatType,
|
|
8
|
-
});
|
|
9
|
-
const fileList = typeof media_path === "string" ? [media_path] : media_path;
|
|
10
|
-
let total = 0;
|
|
11
|
-
const arr = [] as {
|
|
12
|
-
index: number;
|
|
13
|
-
start: number;
|
|
14
|
-
end: number;
|
|
15
|
-
size: number;
|
|
16
|
-
file_path: string;
|
|
17
|
-
}[];
|
|
18
|
-
for await (const [index, file_path] of fileList.entries()) {
|
|
19
|
-
const { size } = await stat(file_path);
|
|
20
|
-
arr.push({
|
|
21
|
-
index,
|
|
22
|
-
start: total,
|
|
23
|
-
end: total + size - 1,
|
|
24
|
-
size,
|
|
25
|
-
file_path,
|
|
26
|
-
});
|
|
27
|
-
total += size;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const getBuffer = async (size: number, offset: number) => {
|
|
31
|
-
if (!size) {
|
|
32
|
-
return new Uint8Array(0);
|
|
33
|
-
}
|
|
34
|
-
const start = offset;
|
|
35
|
-
const end = offset + size - 1;
|
|
36
|
-
const first = arr.find((item) => item.start <= start && item.end >= start);
|
|
37
|
-
const last = arr.find((item) => item.start <= end && item.end >= end);
|
|
38
|
-
if (!first || !last) {
|
|
39
|
-
return new Uint8Array(0);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const list = [] as {
|
|
43
|
-
index: number;
|
|
44
|
-
file_path: string;
|
|
45
|
-
from: number;
|
|
46
|
-
to: number;
|
|
47
|
-
}[];
|
|
48
|
-
if (first.index === last.index) {
|
|
49
|
-
list.push({
|
|
50
|
-
index: first.index,
|
|
51
|
-
file_path: first.file_path,
|
|
52
|
-
from: start - first.start,
|
|
53
|
-
to: end - first.start,
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
list.push({
|
|
57
|
-
index: first.index,
|
|
58
|
-
file_path: first.file_path,
|
|
59
|
-
from: start - first.start,
|
|
60
|
-
to: first.end,
|
|
61
|
-
});
|
|
62
|
-
for (let i = first.index + 1; i < last.index; i++) {
|
|
63
|
-
const item = arr[i];
|
|
64
|
-
if (item) {
|
|
65
|
-
list.push({
|
|
66
|
-
index: item.index,
|
|
67
|
-
file_path: item.file_path,
|
|
68
|
-
from: 0,
|
|
69
|
-
to: item.size - 1,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
list.push({
|
|
74
|
-
index: last.index,
|
|
75
|
-
file_path: last.file_path,
|
|
76
|
-
from: 0,
|
|
77
|
-
to: end - last.start,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const buffers = [] as Buffer[];
|
|
81
|
-
for await (const item of list) {
|
|
82
|
-
const { file_path, from, to } = item;
|
|
83
|
-
const stream = createReadStream(file_path, { start: from, end: to });
|
|
84
|
-
for await (const data of stream) {
|
|
85
|
-
buffers.push(data);
|
|
86
|
-
}
|
|
87
|
-
stream.close();
|
|
88
|
-
}
|
|
89
|
-
const buffer = Buffer.concat(buffers);
|
|
90
|
-
return buffer;
|
|
91
|
-
};
|
|
92
|
-
const data = await mediainfo.analyzeData(() => total, getBuffer);
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
const rawJson = JSON.parse(data as string);
|
|
96
|
-
return rawJson;
|
|
97
|
-
} catch (err) {
|
|
98
|
-
// const text = (data as string).replace(
|
|
99
|
-
// '"Menu","":{}]}]}',
|
|
100
|
-
// '"Menu","":{}}]}',
|
|
101
|
-
// );
|
|
102
|
-
const text = (data as string).replace(',"":{}]}]}', ',"":{}}]}');
|
|
103
|
-
const rawJson = JSON.parse(text);
|
|
104
|
-
return rawJson;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export async function parseMediaInfo(media_path: string) {
|
|
109
|
-
const raw = await parseMediaRaw(media_path);
|
|
110
|
-
const rawMediainfo = raw.media;
|
|
111
|
-
const list = rawMediainfo.track;
|
|
112
|
-
const info = {
|
|
113
|
-
audio: [] as AudioTrackInfo[],
|
|
114
|
-
video: [] as VideoTrackInfo[],
|
|
115
|
-
text: [] as TextTrackInfo[],
|
|
116
|
-
general: {} as GeneralInfo,
|
|
117
|
-
};
|
|
118
|
-
let audioOrder = 0;
|
|
119
|
-
let videoOrder = 0;
|
|
120
|
-
let textOrder = 0;
|
|
121
|
-
list.forEach((item: any) => {
|
|
122
|
-
const type = item["@type"];
|
|
123
|
-
if (type === "Audio") {
|
|
124
|
-
info.audio.push({
|
|
125
|
-
is_default: item.Default === "Yes",
|
|
126
|
-
codec: item.Format.toLowerCase(),
|
|
127
|
-
// order: Number(item.StreamOrder),
|
|
128
|
-
order: audioOrder++,
|
|
129
|
-
// size: Number(item.StreamSize),
|
|
130
|
-
bitrate: Number(item.BitRate),
|
|
131
|
-
framerate: Number(item.FrameRate),
|
|
132
|
-
sample_rate: Number(item.SamplingRate),
|
|
133
|
-
duration: Number(item.Duration),
|
|
134
|
-
channels: Number(item.Channels),
|
|
135
|
-
lossless: item.Compression_Mode === "Lossless",
|
|
136
|
-
});
|
|
137
|
-
} else if (type === "Text") {
|
|
138
|
-
info.text.push({
|
|
139
|
-
is_default: item.Default === "Yes",
|
|
140
|
-
codec: item.Format.toLowerCase(),
|
|
141
|
-
// order: Number(item.StreamOrder),
|
|
142
|
-
order: textOrder++,
|
|
143
|
-
duration: Number(item.Duration),
|
|
144
|
-
title: item.Title || item.Language,
|
|
145
|
-
language: item.Language,
|
|
146
|
-
});
|
|
147
|
-
} else if (type === "Video") {
|
|
148
|
-
info.video.push({
|
|
149
|
-
is_default: item.Default === "Yes",
|
|
150
|
-
codec: item.Format.toLowerCase(),
|
|
151
|
-
order: videoOrder++,
|
|
152
|
-
width: Number(item.Width),
|
|
153
|
-
height: Number(item.Height),
|
|
154
|
-
profile: item.Format_Profile,
|
|
155
|
-
bitrate: Number(item.BitRate),
|
|
156
|
-
framerate: Number(item.FrameRate)
|
|
157
|
-
? Math.round(Number(item.FrameRate))
|
|
158
|
-
: 0,
|
|
159
|
-
// sample_rate: Number(item.SamplingRate),
|
|
160
|
-
duration: Number(item.Duration),
|
|
161
|
-
bitdepth: Number(item.BitDepth),
|
|
162
|
-
format_profile: item.Format_Profile,
|
|
163
|
-
format_tier: item.Format_Tier,
|
|
164
|
-
});
|
|
165
|
-
} else if (type === "General") {
|
|
166
|
-
info.general = {
|
|
167
|
-
audioCount: Number(item.AudioCount),
|
|
168
|
-
textCount: Number(item.TextCount) || 0,
|
|
169
|
-
videoCount: Number(item.VideoCount),
|
|
170
|
-
fileSize: Number(item.FileSize),
|
|
171
|
-
title: item.Title || "",
|
|
172
|
-
duration: Number(item.Duration),
|
|
173
|
-
codec: item.Format,
|
|
174
|
-
};
|
|
175
|
-
if (!info.general.duration && item.extra?.duration) {
|
|
176
|
-
info.general.duration = Number(item.extra.duration);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
return info;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export type GeneralInfo = {
|
|
185
|
-
audioCount: number;
|
|
186
|
-
videoCount: number;
|
|
187
|
-
textCount: number;
|
|
188
|
-
fileSize: number;
|
|
189
|
-
codec: string;
|
|
190
|
-
title: string;
|
|
191
|
-
duration: number;
|
|
192
|
-
extra?: {
|
|
193
|
-
duration: string;
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
export type AudioTrackInfo = {
|
|
197
|
-
is_default: boolean;
|
|
198
|
-
order: number;
|
|
199
|
-
codec: string;
|
|
200
|
-
bitrate: number;
|
|
201
|
-
framerate: number;
|
|
202
|
-
sample_rate: number;
|
|
203
|
-
channels: number;
|
|
204
|
-
duration: number;
|
|
205
|
-
lossless: boolean;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export type VideoTrackInfo = {
|
|
209
|
-
is_default: boolean;
|
|
210
|
-
order: number;
|
|
211
|
-
width: number;
|
|
212
|
-
height: number;
|
|
213
|
-
codec: string;
|
|
214
|
-
profile: string;
|
|
215
|
-
framerate: number;
|
|
216
|
-
bitrate: number;
|
|
217
|
-
duration: number;
|
|
218
|
-
bitdepth: number;
|
|
219
|
-
format_profile: string;
|
|
220
|
-
format_tier: string;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export type TextTrackInfo = {
|
|
224
|
-
is_default: boolean;
|
|
225
|
-
codec: string;
|
|
226
|
-
order: number;
|
|
227
|
-
duration: number;
|
|
228
|
-
language?: string;
|
|
229
|
-
title?: string;
|
|
230
|
-
is_vtt?: boolean;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
export type Mediainfo = {
|
|
234
|
-
general?: GeneralInfo;
|
|
235
|
-
audio?: AudioTrackInfo[];
|
|
236
|
-
video?: VideoTrackInfo[];
|
|
237
|
-
text?: TextTrackInfo[];
|
|
238
|
-
};
|