@soga/mediainfo 0.0.2 → 0.0.4
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/main.d.ts +2 -0
- package/dist/main.js +1 -1
- package/dist/mp4box.d.ts +7 -0
- package/dist/mp4box.js +1 -0
- package/dist/mp4box.types.d.ts +75 -0
- package/dist/mp4box.types.js +1 -0
- package/dist/resolution.d.ts +6 -0
- package/dist/resolution.js +1 -0
- package/dist/resolution.types.d.ts +11 -0
- package/dist/resolution.types.js +1 -0
- package/package.json +3 -2
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__exportStar=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||__createBinding(t,e,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./mediainfo"),exports),__exportStar(require("./mediainfo.types"),exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__exportStar=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||__createBinding(t,e,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./mediainfo"),exports),__exportStar(require("./mediainfo.types"),exports),__exportStar(require("./mp4box"),exports),__exportStar(require("./mp4box.types"),exports);
|
package/dist/mp4box.d.ts
ADDED
package/dist/mp4box.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getMp4boxInfo=getMp4boxInfo;const fs_extra_1=require("fs-extra"),mp4box_1=__importDefault(require("mp4box"));async function getMp4boxInfo(e){const t=await(0,fs_extra_1.readFile)(e),r=new Uint8Array(t).buffer;r.fileStart=0;const o=await new Promise(((e,t)=>{const o=mp4box_1.default.createFile();o.onError=function(e){t(e)},o.onReady=function(t){e(t)},o.appendBuffer(r),o.flush()})),n=o.tracks.filter((e=>!!e.audio||"SoundHandler"==e.name)),a=o.tracks.filter((e=>!!e.video||"VideoHandler"==e.name));return{duration:o.duration,mime:o.mime,audios:n,videos:a}}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export type Mp4boxVideoInfo = {
|
|
2
|
+
id: number;
|
|
3
|
+
name?: 'VideoHandler';
|
|
4
|
+
references: any[];
|
|
5
|
+
edits: {
|
|
6
|
+
segment_duration: number;
|
|
7
|
+
media_time: number;
|
|
8
|
+
media_rate_integer: number;
|
|
9
|
+
media_rate_fraction: number;
|
|
10
|
+
}[];
|
|
11
|
+
created: string;
|
|
12
|
+
modified: string;
|
|
13
|
+
movie_duration: number;
|
|
14
|
+
movie_timescale: number;
|
|
15
|
+
layer: number;
|
|
16
|
+
alternate_group: number;
|
|
17
|
+
volume: number;
|
|
18
|
+
track_width: number;
|
|
19
|
+
track_height: number;
|
|
20
|
+
timescale: number;
|
|
21
|
+
duration: number;
|
|
22
|
+
samples_duration: number;
|
|
23
|
+
codec: string;
|
|
24
|
+
kind: {
|
|
25
|
+
schemeURI: string;
|
|
26
|
+
value: string;
|
|
27
|
+
};
|
|
28
|
+
language: string;
|
|
29
|
+
nb_samples: number;
|
|
30
|
+
size: number;
|
|
31
|
+
bitrate: number;
|
|
32
|
+
type: 'video';
|
|
33
|
+
video: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type Mp4boxAudioInfo = {
|
|
39
|
+
id: number;
|
|
40
|
+
name?: 'SoundHandler';
|
|
41
|
+
references: any[];
|
|
42
|
+
edits: {
|
|
43
|
+
segment_duration: number;
|
|
44
|
+
media_time: number;
|
|
45
|
+
media_rate_integer: number;
|
|
46
|
+
media_rate_fraction: number;
|
|
47
|
+
}[];
|
|
48
|
+
created: string;
|
|
49
|
+
modified: string;
|
|
50
|
+
movie_duration: number;
|
|
51
|
+
movie_timescale: number;
|
|
52
|
+
layer: number;
|
|
53
|
+
alternate_group: number;
|
|
54
|
+
volume: number;
|
|
55
|
+
track_width: number;
|
|
56
|
+
track_height: number;
|
|
57
|
+
timescale: number;
|
|
58
|
+
duration: number;
|
|
59
|
+
samples_duration: number;
|
|
60
|
+
codec: string;
|
|
61
|
+
kind: {
|
|
62
|
+
schemeURI: string;
|
|
63
|
+
value: string;
|
|
64
|
+
};
|
|
65
|
+
language: string;
|
|
66
|
+
nb_samples: number;
|
|
67
|
+
size: number;
|
|
68
|
+
bitrate: number;
|
|
69
|
+
type: 'audio';
|
|
70
|
+
audio: {
|
|
71
|
+
sample_rate: number;
|
|
72
|
+
channel_count: number;
|
|
73
|
+
sample_size: number;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StandardItem } from './resolution.types';
|
|
2
|
+
export declare function getVideoStandard(width: number, height: number): {
|
|
3
|
+
standard: StandardItem;
|
|
4
|
+
adapts: StandardItem[];
|
|
5
|
+
};
|
|
6
|
+
export declare const getStandardInfo: (width: number, height: number) => StandardItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStandardInfo=void 0,exports.getVideoStandard=getVideoStandard;const resolutionMap=new Map,horizontal_resolutions=[{key:"h_p360",is_horizontal:!0,width:640,height:360,label:"360p",tag:"",edge:"width",codec:"libx264"},{key:"h_p540",is_horizontal:!0,width:960,height:540,label:"540p",tag:"",edge:"width",codec:"libx264"},{key:"h_p720",is_horizontal:!0,width:1280,height:720,label:"720p",tag:"",edge:"width",codec:"libx264"},{key:"h_p1080",is_horizontal:!0,width:1920,height:1080,label:"1080p",tag:"HD",edge:"width",codec:"libx264"},{key:"h_p1440",is_horizontal:!0,width:2560,height:1440,label:"1440p",tag:"HD",edge:"width",codec:"libx265"},{key:"h_k4",is_horizontal:!0,width:3840,height:2160,label:"2160p",tag:"4K",edge:"width",codec:"libx265"},{key:"h_k8",is_horizontal:!0,width:7680,height:4320,label:"4320p",tag:"8K",edge:"width",codec:"libx265"},{key:"h_k16",is_horizontal:!0,width:15360,height:8640,label:"16K",tag:"",edge:"width",codec:"libx265"},{key:"h_k32",is_horizontal:!0,width:30720,height:17280,label:"32K",tag:"32K",edge:"width",codec:"libx265"},{key:"h_k32plus",is_horizontal:!0,width:61440,height:34560,label:"64K",tag:"",edge:"width",codec:"libx265"}],vertical_resolutions=[{key:"v_p360",is_horizontal:!1,height:640,width:360,label:"360p",tag:"",edge:"height",codec:"libx264"},{key:"v_p540",is_horizontal:!1,height:960,width:540,label:"540p",tag:"",edge:"height",codec:"libx264"},{key:"v_p720",is_horizontal:!1,height:1280,width:720,label:"720p",tag:"",edge:"height",codec:"libx264"},{key:"v_p1080",is_horizontal:!1,height:1920,width:1080,label:"1080p",tag:"HD",edge:"height",codec:"libx264"},{key:"v_p1440",is_horizontal:!1,height:2560,width:1440,label:"1440p",tag:"HD",edge:"height",codec:"libx265"},{key:"v_k4",is_horizontal:!1,height:3840,width:2160,label:"2160p",tag:"4K",edge:"height",codec:"libx265"},{key:"v_k8",is_horizontal:!1,height:7680,width:4320,label:"4320p",tag:"8K",edge:"height",codec:"libx265"},{key:"v_k16",is_horizontal:!1,height:15360,width:8640,label:"16K",tag:"",edge:"height",codec:"libx265"},{key:"v_k32",is_horizontal:!1,height:30720,width:17280,label:"32K",tag:"32K",edge:"height",codec:"libx265"},{key:"v_k32plus",is_horizontal:!1,height:61440,width:34560,label:"64K",tag:"",edge:"height",codec:"libx265"}];function getVideoStandard(e,t){if(e<t){const i=[],h=[],{length:o}=vertical_resolutions;for(let l=0;l<o;l++){const o=vertical_resolutions[l],a=t>=.9*vertical_resolutions[l].height,d=e>=.9*vertical_resolutions[l].width;if(a&&i.unshift({...o,edge:"height"}),d&&h.unshift({...o,edge:"width"}),!a&&!d)break}const l=i.shift()??vertical_resolutions[0],a=h.shift()??vertical_resolutions[0],d=l.height>a.height;return{standard:d?l:a,adapts:d?i:h}}{const i=[],h=[],{length:o}=horizontal_resolutions;for(let l=0;l<o;l++){const o=horizontal_resolutions[l],a=e>=.9*horizontal_resolutions[l].width,d=t>=.9*horizontal_resolutions[l].height;if(a&&i.unshift({...o,edge:"width"}),d&&h.unshift({...o,edge:"height"}),!a&&!d)break}const l=i.shift()??horizontal_resolutions[0],a=h.shift()??horizontal_resolutions[0],d=l.width>a.width;return{standard:d?l:a,adapts:d?i:h}}}horizontal_resolutions.forEach((e=>{resolutionMap.set(`horizontal_${e.width}`,e)})),vertical_resolutions.forEach((e=>{resolutionMap.set(`vertical_${e.height}`,e)}));const getStandardInfo=(e,t)=>{const{standard:i}=getVideoStandard(e,t);return i};exports.getStandardInfo=getStandardInfo;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type StandardKey = 'h_p360' | 'h_p540' | 'h_p720' | 'h_p1080' | 'h_p1440' | 'h_k4' | 'h_k8' | 'h_k16' | 'h_k32' | 'h_k32plus' | 'v_p360' | 'v_p540' | 'v_p720' | 'v_p1080' | 'v_p1440' | 'v_k4' | 'v_k8' | 'v_k16' | 'v_k32' | 'v_k32plus';
|
|
2
|
+
export type StandardItem = {
|
|
3
|
+
key: StandardKey;
|
|
4
|
+
is_horizontal: boolean;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
label: string;
|
|
8
|
+
tag: string;
|
|
9
|
+
edge: 'width' | 'height';
|
|
10
|
+
codec: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soga/mediainfo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"license": "ISC",
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"fs-extra": "^11.2.0",
|
|
47
|
-
"mediainfo.js": "^0.3.4"
|
|
47
|
+
"mediainfo.js": "^0.3.4",
|
|
48
|
+
"mp4box": "^0.5.3"
|
|
48
49
|
}
|
|
49
50
|
}
|