@soga/mp4box 1.0.0 → 1.0.1

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.
@@ -0,0 +1,83 @@
1
+ declare function getMp4boxInfo(file_path: string): Promise<{
2
+ duration: number;
3
+ mime: string;
4
+ audios: Mp4boxAudioInfo[];
5
+ videos: Mp4boxVideoInfo[];
6
+ }>;
7
+ type Mp4boxVideoInfo = {
8
+ id: number;
9
+ name?: "VideoHandler";
10
+ references: any[];
11
+ edits: {
12
+ segment_duration: number;
13
+ media_time: number;
14
+ media_rate_integer: number;
15
+ media_rate_fraction: number;
16
+ }[];
17
+ created: string;
18
+ modified: string;
19
+ movie_duration: number;
20
+ movie_timescale: number;
21
+ layer: number;
22
+ alternate_group: number;
23
+ volume: number;
24
+ track_width: number;
25
+ track_height: number;
26
+ timescale: number;
27
+ duration: number;
28
+ samples_duration: number;
29
+ codec: string;
30
+ kind: {
31
+ schemeURI: string;
32
+ value: string;
33
+ };
34
+ language: string;
35
+ nb_samples: number;
36
+ size: number;
37
+ bitrate: number;
38
+ type: "video";
39
+ video: {
40
+ width: number;
41
+ height: number;
42
+ };
43
+ };
44
+ type Mp4boxAudioInfo = {
45
+ id: number;
46
+ name?: "SoundHandler";
47
+ references: any[];
48
+ edits: {
49
+ segment_duration: number;
50
+ media_time: number;
51
+ media_rate_integer: number;
52
+ media_rate_fraction: number;
53
+ }[];
54
+ created: string;
55
+ modified: string;
56
+ movie_duration: number;
57
+ movie_timescale: number;
58
+ layer: number;
59
+ alternate_group: number;
60
+ volume: number;
61
+ track_width: number;
62
+ track_height: number;
63
+ timescale: number;
64
+ duration: number;
65
+ samples_duration: number;
66
+ codec: string;
67
+ kind: {
68
+ schemeURI: string;
69
+ value: string;
70
+ };
71
+ language: string;
72
+ nb_samples: number;
73
+ size: number;
74
+ bitrate: number;
75
+ type: "audio";
76
+ audio: {
77
+ sample_rate: number;
78
+ channel_count: number;
79
+ sample_size: number;
80
+ };
81
+ };
82
+
83
+ export { type Mp4boxAudioInfo, type Mp4boxVideoInfo, getMp4boxInfo };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export declare function getMp4boxInfo(file_path: string): Promise<{
1
+ declare function getMp4boxInfo(file_path: string): Promise<{
2
2
  duration: number;
3
3
  mime: string;
4
4
  audios: Mp4boxAudioInfo[];
5
5
  videos: Mp4boxVideoInfo[];
6
6
  }>;
7
- export type Mp4boxVideoInfo = {
7
+ type Mp4boxVideoInfo = {
8
8
  id: number;
9
9
  name?: "VideoHandler";
10
10
  references: any[];
@@ -41,7 +41,7 @@ export type Mp4boxVideoInfo = {
41
41
  height: number;
42
42
  };
43
43
  };
44
- export type Mp4boxAudioInfo = {
44
+ type Mp4boxAudioInfo = {
45
45
  id: number;
46
46
  name?: "SoundHandler";
47
47
  references: any[];
@@ -79,4 +79,5 @@ export type Mp4boxAudioInfo = {
79
79
  sample_size: number;
80
80
  };
81
81
  };
82
- //# sourceMappingURL=index.d.ts.map
82
+
83
+ export { type Mp4boxAudioInfo, type Mp4boxVideoInfo, getMp4boxInfo };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,n){void 0===n&&(n=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,o)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),__importStar=this&&this.__importStar||function(){var e=function(r){return e=Object.getOwnPropertyNames||function(e){var r=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[r.length]=t);return r},e(r)};return function(r){if(r&&r.__esModule)return r;var t={};if(null!=r)for(var n=e(r),o=0;o<n.length;o++)"default"!==n[o]&&__createBinding(t,r,n[o]);return __setModuleDefault(t,r),t}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.getMp4boxInfo=getMp4boxInfo;const error_1=require("@soga/error"),fs_extra_1=require("fs-extra"),MP4Box=__importStar(require("mp4box"));async function getMp4boxInfo(e){try{const r=await new Promise((r,t)=>{const n=MP4Box.createFile();let o=0;const i=(0,fs_extra_1.createReadStream)(e,{highWaterMark:41943040});i.on("data",e=>{const r=new Uint8Array(e).buffer;r.fileStart=o,o+=e.byteLength,n.appendBuffer(r)}),i.on("end",()=>{n.flush()}),i.on("error",e=>{t(e)}),n.onError=function(e,r){i.destroy(),n.flush(),t(new Error(r))},n.onReady=function(e){i.destroy(),n.flush(),r(e)}}),t=r.tracks.filter(e=>!!e.audio||"SoundHandler"==e.name),n=r.tracks.filter(e=>!!e.video||"VideoHandler"==e.name);return{duration:r.duration,mime:r.mime,audios:t,videos:n}}catch(r){throw(0,error_1.buildDError)(r,{message:"Failed to get MP4 box info",detail:`Error while processing file: ${e}`})}}
1
+ "use strict";var e,r=Object.create,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,a=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,u=(e,r,a,u)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let l of n(r))i.call(e,l)||l===a||t(e,l,{get:()=>r[l],enumerable:!(u=o(r,l))||u.enumerable});return e},l={};((e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})})(l,{getMp4boxInfo:()=>d}),module.exports=(e=l,u(t({},"__esModule",{value:!0}),e));var s=require("@soga/error"),c=require("fs-extra"),f=((e,o,n)=>(n=null!=e?r(a(e)):{},u(!o&&e&&e.__esModule?n:t(n,"default",{value:e,enumerable:!0}),e)))(require("mp4box"));async function d(e){try{const r=await new Promise((r,t)=>{const o=f.createFile();let n=0;const a=(0,c.createReadStream)(e,{highWaterMark:41943040});a.on("data",e=>{const r=new Uint8Array(e).buffer;r.fileStart=n,n+=e.byteLength,o.appendBuffer(r)}),a.on("end",()=>{o.flush()}),a.on("error",e=>{t(e)}),o.onError=function(e,r){a.destroy(),o.flush(),t(new Error(r))},o.onReady=function(e){a.destroy(),o.flush(),r(e)}}),t=r.tracks.filter(e=>!!e.audio||"SoundHandler"==e.name),o=r.tracks.filter(e=>!!e.video||"VideoHandler"==e.name);return{duration:r.duration,mime:r.mime,audios:t,videos:o}}catch(r){throw(0,s.buildDError)(r,{message:"Failed to get MP4 box info",detail:`Error while processing file: ${e}`})}}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{buildDError as r}from"@soga/error";import{createReadStream as e}from"fs-extra";import*as o from"mp4box";async function t(t){try{const r=await new Promise((r,n)=>{const a=o.createFile();let i=0;const s=e(t,{highWaterMark:41943040});s.on("data",r=>{const e=new Uint8Array(r).buffer;e.fileStart=i,i+=r.byteLength,a.appendBuffer(e)}),s.on("end",()=>{a.flush()}),s.on("error",r=>{n(r)}),a.onError=function(r,e){s.destroy(),a.flush(),n(new Error(e))},a.onReady=function(e){s.destroy(),a.flush(),r(e)}}),n=r.tracks.filter(r=>!!r.audio||"SoundHandler"==r.name),a=r.tracks.filter(r=>!!r.video||"VideoHandler"==r.name);return{duration:r.duration,mime:r.mime,audios:n,videos:a}}catch(e){throw r(e,{message:"Failed to get MP4 box info",detail:`Error while processing file: ${t}`})}}export{t as getMp4boxInfo};
package/package.json CHANGED
@@ -3,13 +3,13 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.0",
6
+ "version": "1.0.1",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
10
  "scripts": {
11
11
  "demo": "tsx ./demo/demo.ts",
12
- "build": "rimraf dist && tsc && tsx ./scripts/minify",
12
+ "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts --minify terser",
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "files": [
@@ -1 +0,0 @@
1
- {"version":3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