@remotion/media-parser 4.0.239 → 4.0.240

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.
@@ -1,2 +1,2 @@
1
- export declare const measureEBMLVarInt: (value: number) => 1 | 2 | 3 | 4 | 5 | 6;
1
+ export declare const measureEBMLVarInt: (value: number) => 3 | 1 | 2 | 4 | 6 | 5;
2
2
  export declare const getVariableInt: (value: number, minWidth: number | null) => Uint8Array;
@@ -7,11 +7,12 @@ const get_dimensions_1 = require("./get-dimensions");
7
7
  const get_duration_1 = require("./get-duration");
8
8
  const get_fps_1 = require("./get-fps");
9
9
  const get_is_hdr_1 = require("./get-is-hdr");
10
+ const get_location_1 = require("./get-location");
10
11
  const get_tracks_1 = require("./get-tracks");
11
12
  const get_video_codec_1 = require("./get-video-codec");
12
13
  const get_metadata_1 = require("./metadata/get-metadata");
13
14
  const emitAvailableInfo = ({ hasInfo, parseResult, moreFields, state, returnValue, contentLength, name, }) => {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
15
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
15
16
  const keys = Object.keys(hasInfo);
16
17
  for (const key of keys) {
17
18
  if (key === 'structure') {
@@ -162,6 +163,16 @@ const emitAvailableInfo = ({ hasInfo, parseResult, moreFields, state, returnValu
162
163
  }
163
164
  continue;
164
165
  }
166
+ if (key === 'location') {
167
+ if (returnValue.location === undefined &&
168
+ hasInfo.location &&
169
+ parseResult) {
170
+ const location = (0, get_location_1.getLocation)(parseResult.segments);
171
+ (_q = moreFields.onLocation) === null || _q === void 0 ? void 0 : _q.call(moreFields, location);
172
+ returnValue.location = location;
173
+ }
174
+ continue;
175
+ }
165
176
  throw new Error(`Unhandled key: ${key}`);
166
177
  }
167
178
  };
@@ -1366,7 +1366,7 @@ var createIsoBaseMediaFtyp = ({
1366
1366
  };
1367
1367
 
1368
1368
  // src/version.ts
1369
- var VERSION = "4.0.239";
1369
+ var VERSION = "4.0.240";
1370
1370
 
1371
1371
  // src/create/iso-base-media/create-ilst.ts
1372
1372
  var createIlst = (items) => {
@@ -6168,6 +6168,39 @@ var hasHdr = (boxes, state) => {
6168
6168
  return hasTracks(boxes, state);
6169
6169
  };
6170
6170
 
6171
+ // src/get-location.ts
6172
+ function parseLocation(locationString) {
6173
+ const locationPattern = /^([+-]\d{2}\.?\d{0,10})([+-]\d{3}\.?\d{0,10})([+-]\d+(\.\d+)?)?\/$/;
6174
+ const match = locationString.match(locationPattern);
6175
+ if (!match) {
6176
+ return null;
6177
+ }
6178
+ const latitude = parseFloat(match[1]);
6179
+ const longitude = parseFloat(match[2]);
6180
+ const altitude = match[3] ? parseFloat(match[3]) : null;
6181
+ return {
6182
+ latitude,
6183
+ longitude,
6184
+ altitude
6185
+ };
6186
+ }
6187
+ var getLocation = (structure) => {
6188
+ const metadata = getMetadata(structure);
6189
+ const locationEntry = metadata.find((entry) => entry.key === "com.apple.quicktime.location.ISO6709");
6190
+ const horizontalAccuracy = metadata.find((entry) => entry.key === "com.apple.quicktime.location.accuracy.horizontal");
6191
+ if (locationEntry) {
6192
+ const parsed = parseLocation(locationEntry.value);
6193
+ if (parsed === null) {
6194
+ return null;
6195
+ }
6196
+ return {
6197
+ ...parsed,
6198
+ horizontalAccuracy: horizontalAccuracy?.value ? parseFloat(String(horizontalAccuracy.value)) : null
6199
+ };
6200
+ }
6201
+ return null;
6202
+ };
6203
+
6171
6204
  // src/emit-available-info.ts
6172
6205
  var emitAvailableInfo = ({
6173
6206
  hasInfo,
@@ -6306,6 +6339,14 @@ var emitAvailableInfo = ({
6306
6339
  }
6307
6340
  continue;
6308
6341
  }
6342
+ if (key === "location") {
6343
+ if (returnValue.location === undefined && hasInfo.location && parseResult) {
6344
+ const location = getLocation(parseResult.segments);
6345
+ moreFields.onLocation?.(location);
6346
+ returnValue.location = location;
6347
+ }
6348
+ continue;
6349
+ }
6309
6350
  throw new Error(`Unhandled key: ${key}`);
6310
6351
  }
6311
6352
  };
@@ -6351,7 +6392,7 @@ var getAvailableInfo = (options, structure, state) => {
6351
6392
  if (key === "container") {
6352
6393
  return Boolean(structure && hasContainer(structure));
6353
6394
  }
6354
- if (key === "metadata") {
6395
+ if (key === "metadata" || key === "location") {
6355
6396
  return false;
6356
6397
  }
6357
6398
  throw new Error(`Unknown key: ${key}`);
@@ -10981,7 +11022,8 @@ var needsTracksField = {
10981
11022
  tracks: true,
10982
11023
  unrotatedDimensions: true,
10983
11024
  videoCodec: true,
10984
- metadata: true
11025
+ metadata: true,
11026
+ location: true
10985
11027
  };
10986
11028
  var makeCanSkipTracksState = ({
10987
11029
  hasAudioTrackHandlers,
@@ -0,0 +1,13 @@
1
+ import type { Structure } from './parse-result';
2
+ export type MediaParserLocation = {
3
+ latitude: number;
4
+ longitude: number;
5
+ altitude: number | null;
6
+ horizontalAccuracy: number | null;
7
+ };
8
+ export declare function parseLocation(locationString: string): {
9
+ latitude: number;
10
+ longitude: number;
11
+ altitude: number | null;
12
+ } | null;
13
+ export declare const getLocation: (structure: Structure) => MediaParserLocation | null;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLocation = void 0;
4
+ exports.parseLocation = parseLocation;
5
+ const get_metadata_1 = require("./metadata/get-metadata");
6
+ function parseLocation(locationString) {
7
+ const locationPattern = /^([+-]\d{2}\.?\d{0,10})([+-]\d{3}\.?\d{0,10})([+-]\d+(\.\d+)?)?\/$/;
8
+ const match = locationString.match(locationPattern);
9
+ if (!match) {
10
+ return null;
11
+ }
12
+ // Extract latitude, longitude, and altitude
13
+ const latitude = parseFloat(match[1]);
14
+ const longitude = parseFloat(match[2]);
15
+ const altitude = match[3] ? parseFloat(match[3]) : null;
16
+ return {
17
+ latitude,
18
+ longitude,
19
+ altitude,
20
+ };
21
+ }
22
+ const getLocation = (structure) => {
23
+ const metadata = (0, get_metadata_1.getMetadata)(structure);
24
+ const locationEntry = metadata.find((entry) => entry.key === 'com.apple.quicktime.location.ISO6709');
25
+ const horizontalAccuracy = metadata.find((entry) => entry.key === 'com.apple.quicktime.location.accuracy.horizontal');
26
+ if (locationEntry) {
27
+ const parsed = parseLocation(locationEntry.value);
28
+ if (parsed === null) {
29
+ return null;
30
+ }
31
+ return {
32
+ ...parsed,
33
+ horizontalAccuracy: (horizontalAccuracy === null || horizontalAccuracy === void 0 ? void 0 : horizontalAccuracy.value)
34
+ ? parseFloat(String(horizontalAccuracy.value))
35
+ : null,
36
+ };
37
+ }
38
+ return null;
39
+ };
40
+ exports.getLocation = getLocation;
@@ -51,7 +51,7 @@ const getAvailableInfo = (options, structure, state) => {
51
51
  if (key === 'container') {
52
52
  return Boolean(structure && (0, get_container_1.hasContainer)(structure));
53
53
  }
54
- if (key === 'metadata') {
54
+ if (key === 'metadata' || key === 'location') {
55
55
  return false;
56
56
  }
57
57
  throw new Error(`Unknown key: ${key}`);
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { parseMedia } from './parse-media';
9
9
  export { AudioOrVideoSample, OnAudioSample, OnAudioTrack, OnVideoSample, OnVideoTrack, } from './webcodec-sample-types';
10
10
  export type { MediaFn } from './create/media-fn';
11
11
  export { Dimensions } from './get-dimensions';
12
+ export { MediaParserLocation } from './get-location';
12
13
  export type { ReaderInterface } from './readers/reader';
13
14
  export declare const MediaParserInternals: {
14
15
  createMatroskaMedia: ({ writer, onBytesProgress, onMillisecondsProgress, filename, logLevel, progressTracker, }: import("./create/media-fn").MediaFnGeneratorInput) => Promise<import("./create/media-fn").MediaFn>;
package/dist/options.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Dimensions } from './get-dimensions';
2
+ import type { MediaParserLocation } from './get-location';
2
3
  import type { AudioTrack, MediaParserAudioCodec, MediaParserVideoCodec, VideoTrack } from './get-tracks';
3
4
  import type { LogLevel } from './log';
4
5
  import type { MetadataEntry } from './metadata/get-metadata';
@@ -23,6 +24,7 @@ export type ParseMediaFields = {
23
24
  container: boolean;
24
25
  isHdr: boolean;
25
26
  metadata: boolean;
27
+ location: boolean;
26
28
  };
27
29
  export type AllParseMediaFields = {
28
30
  dimensions: true;
@@ -40,6 +42,7 @@ export type AllParseMediaFields = {
40
42
  container: true;
41
43
  isHdr: true;
42
44
  metadata: true;
45
+ location: true;
43
46
  };
44
47
  export type Options<Fields extends ParseMediaFields> = {
45
48
  dimensions?: Fields['dimensions'];
@@ -57,6 +60,7 @@ export type Options<Fields extends ParseMediaFields> = {
57
60
  container?: Fields['container'];
58
61
  isHdr?: Fields['isHdr'];
59
62
  metadata?: Fields['metadata'];
63
+ location?: Fields['location'];
60
64
  };
61
65
  export type TracksField = {
62
66
  videoTracks: VideoTrack[];
@@ -81,6 +85,8 @@ export type ParseMediaCallbacks<Fields extends Options<ParseMediaFields>> = (Fie
81
85
  onRotation?: (rotation: number | null) => void;
82
86
  } : {}) & (Fields['metadata'] extends true ? {
83
87
  onMetadata?: (metadata: MetadataEntry[]) => void;
88
+ } : {}) & (Fields['location'] extends true ? {
89
+ onLocation?: (location: MediaParserLocation | null) => void;
84
90
  } : {}) & (Fields['unrotatedDimensions'] extends true ? {
85
91
  onUnrotatedDimensions?: (dimensions: Dimensions) => void;
86
92
  } : {}) & (Fields['isHdr'] extends true ? {
@@ -118,6 +124,8 @@ export type ParseMediaResult<Fields extends Options<ParseMediaFields>> = (Fields
118
124
  name: string;
119
125
  } : {}) & (Fields['metadata'] extends true ? {
120
126
  metadata: MetadataEntry[];
127
+ } : {}) & (Fields['location'] extends true ? {
128
+ location: MediaParserLocation | null;
121
129
  } : {}) & (Fields['container'] extends true ? {
122
130
  container: ParseMediaContainer;
123
131
  } : {});
@@ -17,6 +17,7 @@ const needsTracksField = {
17
17
  unrotatedDimensions: true,
18
18
  videoCodec: true,
19
19
  metadata: true,
20
+ location: true,
20
21
  };
21
22
  const makeCanSkipTracksState = ({ hasAudioTrackHandlers, fields, hasVideoTrackHandlers, }) => {
22
23
  return {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.239";
1
+ export declare const VERSION = "4.0.240";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.239';
5
+ exports.VERSION = '4.0.240';
package/package.json CHANGED
@@ -3,14 +3,14 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-parser"
4
4
  },
5
5
  "name": "@remotion/media-parser",
6
- "version": "4.0.239",
6
+ "version": "4.0.240",
7
7
  "main": "dist/index.js",
8
8
  "sideEffects": false,
9
9
  "devDependencies": {
10
10
  "@types/wicg-file-system-access": "2023.10.5",
11
11
  "eslint": "9.14.0",
12
- "@remotion/example-videos": "4.0.239",
13
- "@remotion/eslint-config-internal": "4.0.239"
12
+ "@remotion/example-videos": "4.0.240",
13
+ "@remotion/eslint-config-internal": "4.0.240"
14
14
  },
15
15
  "publishConfig": {
16
16
  "access": "public"