MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / probeOne

Function probeOne

packages/studio/src/player/lib/mediaProbe.ts:37–65  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

35}
36
37async function probeOne(url: string): Promise<MediaProbeResult | null> {
38 const mb = await loadMediabunny();
39 if (!mb) return null;
40
41 const input = new mb.Input({
42 source: new mb.UrlSource(url),
43 formats: mb.ALL_FORMATS,
44 });
45 try {
46 const duration = await input.getDurationFromMetadata();
47 if (duration == null || !Number.isFinite(duration) || duration <= 0) return null;
48
49 const videoTrack = await input.getPrimaryVideoTrack();
50 const audioTracks = await input.getAudioTracks();
51
52 const result: MediaProbeResult = {
53 duration,
54 width: videoTrack?.displayWidth,
55 height: videoTrack?.displayHeight,
56 hasVideo: videoTrack != null,
57 hasAudio: audioTracks.length > 0,
58 };
59 return result;
60 } catch {
61 return null;
62 } finally {
63 input.dispose();
64 }
65}
66
67function getCachedProbe(url: string): MediaProbeResult | undefined {
68 return cache.get(normalizeUrl(url));

Callers 1

probeMediaUrlFunction · 0.85

Calls 2

loadMediabunnyFunction · 0.85
disposeMethod · 0.65

Tested by

no test coverage detected