Capítulo 679 de 988
:::warning We are phasing out Media Parser and are moving to Mediabunny!
// Some fields only require the first few bytes of the file to be read:
const result = await parseMedia({
src: 'https://remotion.media/video.mp4',
fields: {
size: true,
container: true,
internalStats: true,
},
});
console.log(result.internalStats.finalCursorOffset); // 12
// Reading the metadata of the video will only require the metadata section to be parsed.
// You can also use onVideoTrack() and return null to retrieve track information but to not get the samples.
const result2 = await parseMedia({
src: 'https://remotion.media/video.mp4',
fields: {
durationInSeconds: true,
dimensions: true,
internalStats: true,
},
onVideoTrack: ({track}) => {
console.log(track);
return null;
},
});
console.log(result2.internalStats.finalCursorOffset); // 4000
console.log(result2.dimensions);
// Asking for all video samples requires parsing the whole file
const result3 = await parseMedia({
src: 'https://remotion.media/video.mp4',
fields: {
internalStats: true,
},
onVideoTrack: () => {
return (videoSample) => console.log(videoSample);
},
});
console.log(result3.internalStats.finalCursorOffset); // 1870234802