You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m trying to get the users metadata of a video (comment notably). I tried to do something like that:
<!DOCTYPE html>
<html>
<head>
<title>MP4 Metadata Extraction</title>
</head>
<body>
<input type="file" id="fileInput" accept=".mp4">
<div id="metadataDisplay"></div>
<script src="mp4box.all.js"></script>
<script>
document.getElementById("fileInput").addEventListener("change", function (e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function (e) {
const arrayBuffer = e.target.result;
// Initialize mp4box
const mp4boxFile = MP4Box.createFile();
mp4boxFile.onReady = (info) => {
console.log("READY");
console.log(info);
};
mp4boxFile.onError = () => {
console.log("Error");
};
// Create a Blob from the ArrayBuffer
/* const blob = new Blob([arrayBuffer]);
*/
console.log("created blob");
// Read the Blob using mp4box
arrayBuffer.fileStart = 0;
mp4boxFile.appendBuffer(arrayBuffer);
// Get metadata, ilst is inside udta, and seems to be the one with comments (maybe others could as well?)
/* const udtaBoxes = mp4boxFile.getBoxes("udta"); */
const ilstBoxes = mp4boxFile.getBoxes("ilst");
const decoder = new TextDecoder('utf-8');
ilstBoxes.forEach( (ilstBox) => {
console.log(decoder.decode(ilstBox.data));
});
};
reader.readAsArrayBuffer(file);
}
});
</script>
</body>
</html>
and I’m close enough to get the content, but I’m not sure how to parse it further, and I’m not sure if this is the only box that can contain user content. Is there a simpler way to get user metadata, like comments?
The text was updated successfully, but these errors were encountered:
I’m trying to get the users metadata of a video (comment notably). I tried to do something like that:
and I’m close enough to get the content, but I’m not sure how to parse it further, and I’m not sure if this is the only box that can contain user content. Is there a simpler way to get user metadata, like comments?
The text was updated successfully, but these errors were encountered: