有没有办法通过 javascript 获取 webm 的框架宽度和框架高度属性?

Is there a way to get the frame width and frame height properties of a webm via javascript?

以下是我尝试访问的属性:

propertyHelp001

我看过 mediainfo.js (https://github.com/buzz/mediainfo.js?files=1),老实说我想不出来。

我也看到有人提到可以使用 'media info' (https://mediaarea.net/en/MediaInfo) CLI 来完成此操作,但我找不到有关如何完成此操作的任何说明。

我也试过像这样使用 wmic:

var exec = require('child_process').exec
exec('wmic datafile where name="C:\\some_path\\MyTestCourse\\test_conversion\\testProject001\\videos\\video0.webm" get NaturalVideoWidth ', function(err, stdout, stderr){
        if(!err){
            console.log(stdout)
        };
    });

但我认为它无法访问我正在寻找的内容。

我需要能够在终端中 运行 作为我正在执行的视频批量转换的一部分。我正在使用 nodejs 和一个批处理文件来完成这个。

非常感谢任何见解或建议。

这是 Node.js 中的一个工作(在我的机器上工作™️)脚本。希望能帮助到你。我使用来自 https://www.webmfiles.org/demo-files/

的测试视频
const { promises } = require("fs");
const MediaInfoFactory = require("mediainfo.js");

function getReadChunkFunction(fileHandle) {
  async function readChunk(size, offset) {
    const buffer = new Uint8Array(size);
    await fileHandle.read(buffer, 0, size, offset);
    return buffer;
  }

  return readChunk;
}

async function readMetaData(filepath) {
  const mediaInfo = await MediaInfoFactory({ format: "JSON", coverData: true });
  const fileHandle = await promises.open(filepath, "r");
  const fileSize = (await fileHandle.stat()).size;
  const readChunk = getReadChunkFunction(fileHandle);
  const result = await mediaInfo.analyzeData(() => fileSize, readChunk);
  return result;
}

// Usage example:

readMetaData(__dirname + "/big-buck-bunny_trailer.webm").then((result) => {
  const data = JSON.parse(result);
  const videoMetaData = data.media.track.find((item) => item["@type"] === "Video");
  const { Width, Height } = videoMetaData;

  console.log("Width", Width);
  console.log("Height", Height);
});

mediainfo 的原始输出如下所示,展开代码段进行检查。

{
  "media": {
    "@ref": "",
    "track": [
      {
        "@type": "General",
        "UniqueID": "94077224337973666327274415816295077565",
        "VideoCount": "1",
        "AudioCount": "1",
        "Format": "WebM",
        "Format_Version": "1",
        "FileSize": "2165175",
        "Duration": "32.480",
        "OverallBitRate_Mode": "VBR",
        "OverallBitRate": "533294",
        "FrameRate": "25.000",
        "FrameCount": "812",
        "StreamSize": "121714",
        "IsStreamable": "Yes",
        "Encoded_Date": "UTC 2010-05-20 08:21:12",
        "Encoded_Application": "Sorenson Squeeze",
        "Encoded_Library": "http://sourceforge.net/projects/yamka"
      },
      {
        "@type": "Video",
        "StreamOrder": "0",
        "ID": "1",
        "UniqueID": "38308775201223106",
        "Format": "VP8",
        "CodecID": "V_VP8",
        "Duration": "32.480",
        "BitRate": "439316",
        "Width": "640",
        "Height": "360",
        "PixelAspectRatio": "1.000",
        "DisplayAspectRatio": "1.778",
        "FrameRate_Mode": "CFR",
        "FrameRate": "25.000",
        "FrameCount": "812",
        "Compression_Mode": "Lossy",
        "Delay": "0.000",
        "StreamSize": "1783621",
        "Language": "en",
        "Default": "Yes",
        "Forced": "No"
      },
      {
        "@type": "Audio",
        "StreamOrder": "1",
        "ID": "2",
        "UniqueID": "110618262945856186",
        "Format": "Vorbis",
        "Format_Settings_Floor": "1",
        "CodecID": "A_VORBIS",
        "Duration": "32.480",
        "BitRate_Mode": "VBR",
        "BitRate": "64000",
        "Channels": "1",
        "SamplingRate": "44100",
        "SamplingCount": "1432368",
        "Compression_Mode": "Lossy",
        "Delay": "0.000",
        "Delay_Source": "Container",
        "StreamSize": "259840",
        "StreamSize_Proportion": "0.12001",
        "Encoded_Library": "Xiph.Org libVorbis I 20100325 (Everywhere)",
        "Encoded_Library_Name": "libVorbis",
        "Encoded_Library_Version": "(Everywhere)",
        "Encoded_Library_Date": "20100325 (Everywhere)",
        "Language": "en",
        "Default": "Yes",
        "Forced": "No"
      }
    ]
  }
}