@remotion/media-parser 4.0.272 → 4.0.273

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,5 @@
1
+ import type { SamplePosition } from '../../get-sample-positions';
2
+ import type { IsoBaseMediaSeekingInfo, SeekingInfo } from '../../seeking-info';
3
+ import type { ParserState } from '../../state/parser-state';
4
+ export declare const getSeekingInfoFromMp4: (state: ParserState) => SeekingInfo | null;
5
+ export declare const getSeekingByteFromIsoBaseMedia: (info: IsoBaseMediaSeekingInfo, time: number) => SamplePosition;
@@ -0,0 +1,50 @@
1
+ import { getTracksFromMoovBox } from '../../get-tracks';
2
+ import { getSamplePositionsFromTrack } from './get-sample-positions-from-track';
3
+ import { getMoofBoxes, getMoovBoxFromState } from './traversal';
4
+ export const getSeekingInfoFromMp4 = (state) => {
5
+ const structure = state.getIsoStructure();
6
+ const moovAtom = getMoovBoxFromState(state);
7
+ const moofBoxes = getMoofBoxes(structure.boxes);
8
+ if (!moovAtom) {
9
+ return null;
10
+ }
11
+ return {
12
+ type: 'iso-base-media-seeking-info',
13
+ moovBox: moovAtom,
14
+ moofBoxes,
15
+ };
16
+ };
17
+ export const getSeekingByteFromIsoBaseMedia = (info, time) => {
18
+ const tracks = getTracksFromMoovBox(info.moovBox);
19
+ const allTracks = [
20
+ ...tracks.videoTracks,
21
+ ...tracks.audioTracks,
22
+ ...tracks.otherTracks,
23
+ ];
24
+ let byte = 0;
25
+ let sam = null;
26
+ for (const t of allTracks) {
27
+ const { timescale: ts, type } = t;
28
+ if (type !== 'video') {
29
+ continue;
30
+ }
31
+ const samplePositions = getSamplePositionsFromTrack({
32
+ trakBox: t.trakBox,
33
+ moofBoxes: info.moofBoxes,
34
+ });
35
+ for (const sample of samplePositions) {
36
+ const timestamp = sample.cts / ts;
37
+ if (timestamp <= time &&
38
+ byte < sample.offset &&
39
+ type === 'video' &&
40
+ sample.isKeyframe) {
41
+ byte = sample.offset;
42
+ sam = sample;
43
+ }
44
+ }
45
+ }
46
+ if (!sam) {
47
+ throw new Error('No sample found');
48
+ }
49
+ return sam;
50
+ };
@@ -13001,7 +13001,7 @@ var downloadAndParseMedia = async (options) => {
13001
13001
  return returnValue;
13002
13002
  };
13003
13003
  // src/version.ts
13004
- var VERSION = "4.0.272";
13004
+ var VERSION = "4.0.273";
13005
13005
 
13006
13006
  // src/index.ts
13007
13007
  var MediaParserInternals = {
@@ -0,0 +1,63 @@
1
+ export type ParseMediaFields = {
2
+ dimensions: boolean;
3
+ durationInSeconds: boolean;
4
+ slowDurationInSeconds: boolean;
5
+ structure: boolean;
6
+ fps: boolean;
7
+ slowFps: boolean;
8
+ videoCodec: boolean;
9
+ audioCodec: boolean;
10
+ tracks: boolean;
11
+ rotation: boolean;
12
+ unrotatedDimensions: boolean;
13
+ internalStats: boolean;
14
+ size: boolean;
15
+ name: boolean;
16
+ container: boolean;
17
+ isHdr: boolean;
18
+ metadata: boolean;
19
+ location: boolean;
20
+ mimeType: boolean;
21
+ keyframes: boolean;
22
+ slowKeyframes: boolean;
23
+ slowNumberOfFrames: boolean;
24
+ slowVideoBitrate: boolean;
25
+ slowAudioBitrate: boolean;
26
+ images: boolean;
27
+ sampleRate: boolean;
28
+ numberOfAudioChannels: boolean;
29
+ m3uStreams: boolean;
30
+ seekingInfo: boolean;
31
+ };
32
+ export type AllOptions<Fields extends ParseMediaFields> = {
33
+ dimensions: Fields['dimensions'];
34
+ durationInSeconds: Fields['durationInSeconds'];
35
+ slowDurationInSeconds: Fields['slowDurationInSeconds'];
36
+ slowFps: Fields['slowFps'];
37
+ structure: Fields['structure'];
38
+ fps: Fields['fps'];
39
+ videoCodec: Fields['videoCodec'];
40
+ audioCodec: Fields['audioCodec'];
41
+ tracks: Fields['tracks'];
42
+ rotation: Fields['rotation'];
43
+ unrotatedDimensions: Fields['unrotatedDimensions'];
44
+ internalStats: Fields['internalStats'];
45
+ size: Fields['size'];
46
+ name: Fields['name'];
47
+ container: Fields['container'];
48
+ isHdr: Fields['isHdr'];
49
+ metadata: Fields['metadata'];
50
+ location: Fields['location'];
51
+ mimeType: Fields['mimeType'];
52
+ keyframes: Fields['keyframes'];
53
+ slowKeyframes: Fields['slowKeyframes'];
54
+ slowNumberOfFrames: Fields['slowNumberOfFrames'];
55
+ images: Fields['images'];
56
+ sampleRate: Fields['sampleRate'];
57
+ numberOfAudioChannels: Fields['numberOfAudioChannels'];
58
+ slowVideoBitrate: Fields['slowVideoBitrate'];
59
+ slowAudioBitrate: Fields['slowAudioBitrate'];
60
+ m3uStreams: Fields['m3uStreams'];
61
+ seekingInfo: Fields['seekingInfo'];
62
+ };
63
+ export type Options<Fields extends ParseMediaFields> = Partial<AllOptions<Fields>>;
package/dist/fields.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { SeekingInfo } from './seeking-info';
2
+ import type { ParserState } from './state/parser-state';
3
+ export declare const getSeekingInfo: (state: ParserState) => SeekingInfo | null;
4
+ export declare const hasSeekingInfo: (state: ParserState) => boolean;
5
+ export declare const getSeekingByte: (info: SeekingInfo, time: number) => number;
@@ -0,0 +1,24 @@
1
+ import { getSeekingByteFromIsoBaseMedia, getSeekingInfoFromMp4, } from './containers/iso-base-media/get-seeking-from-mp4';
2
+ export const getSeekingInfo = (state) => {
3
+ const structure = state.getStructureOrNull();
4
+ if (!structure) {
5
+ return null;
6
+ }
7
+ if (structure.type === 'iso-base-media') {
8
+ return getSeekingInfoFromMp4(state);
9
+ }
10
+ return null;
11
+ };
12
+ export const hasSeekingInfo = (state) => {
13
+ const structure = state.getStructureOrNull();
14
+ if (structure && structure.type === 'iso-base-media') {
15
+ return Boolean(getSeekingInfoFromMp4(state));
16
+ }
17
+ return false;
18
+ };
19
+ export const getSeekingByte = (info, time) => {
20
+ if (info.type === 'iso-base-media-seeking-info') {
21
+ return getSeekingByteFromIsoBaseMedia(info, time).offset;
22
+ }
23
+ throw new Error(`Unknown seeking info type: ${info.type}`);
24
+ };
@@ -0,0 +1,8 @@
1
+ import type { IsoBaseMediaBox } from './containers/iso-base-media/base-media-box';
2
+ import type { MoovBox } from './containers/iso-base-media/moov/moov';
3
+ export type IsoBaseMediaSeekingInfo = {
4
+ type: 'iso-base-media-seeking-info';
5
+ moovBox: MoovBox;
6
+ moofBoxes: IsoBaseMediaBox[];
7
+ };
8
+ export type SeekingInfo = IsoBaseMediaSeekingInfo;
@@ -0,0 +1 @@
1
+ export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.272";
1
+ export declare const VERSION = "4.0.273";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Automatically generated on publish
2
- export const VERSION = '4.0.272';
2
+ export const VERSION = '4.0.273';
package/package.json CHANGED
@@ -3,15 +3,15 @@
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.272",
6
+ "version": "4.0.273",
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.19.0",
12
12
  "@types/bun": "1.2.0",
13
- "@remotion/example-videos": "4.0.272",
14
- "@remotion/eslint-config-internal": "4.0.272"
13
+ "@remotion/eslint-config-internal": "4.0.273",
14
+ "@remotion/example-videos": "4.0.273"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"