首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Kagami/ffmpeg.js webm to images无法为'%04d.jpg‘错误找到合适的输出格式

Kagami/ffmpeg.js webm to images无法为'%04d.jpg‘错误找到合适的输出格式
EN

Stack Overflow用户
提问于 2020-07-17 16:32:02
回答 1查看 335关注 0票数 3

以下是版本:

节点v12.9.1,npm 6.10.2,ffmpeg.js@4.2.9003

存储库:https://github.com/Kagami/ffmpeg.js

decode.js代码如下:

代码语言:javascript
运行
复制
const fs = require('fs');
const ffmpeg = require('ffmpeg.js');

const testData = new Uint8Array(fs.readFileSync("test/test.webm"));
const result = ffmpeg({
    MEMFS: [{ name: "test.webm", data: testData }],
    arguments: ["-i", "test.webm",  "-hide_banner", "%04d.jpg" ],
});

node decode.js,然后我得到了错误:

代码语言:javascript
运行
复制
[vp8 @ 0x6a9850] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x6ac650] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'test.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:00:03.95, start: 0.000000, bitrate: 798 kb/s
    Stream #0:0: Video: vp8, yuv420p, 854x480, SAR 1:1 DAR 427:240, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Stream #0:2(eng): Subtitle: webvtt
[NULL @ 0x6ae530] Unable to find a suitable output format for '%04d.jpg'
%04d.jpg: Invalid argument
EN

回答 1

Stack Overflow用户

发布于 2020-07-21 17:28:58

这是因为使用了npm install ffmpeg.js

它不包含image2复用器和mjpeg编码器。

所以我用docker构建并修改了makefile:

代码语言:javascript
运行
复制
WEBM_MUXERS = webm ogg null image2
WEBM_ENCODERS = libvpx_vp8 libopus png mjpeg

然后制作并获取ffmpeg-webm.js

测试代码:

代码语言:javascript
运行
复制
const fs = require('fs');
const ffmpeg = require('./ffmpeg-webm.js');

const testData = new Uint8Array(fs.readFileSync("test/test.webm"));
const result = ffmpeg({
    MEMFS: [{ name: "test.webm", data: testData }],
    arguments: ["-i", "test.webm",  "-hide_banner", "%04d.jpg" ],
});
const out = result.MEMFS[0];
console.log(out);

并获取:

代码语言:javascript
运行
复制
{
  name: '0001.jpg',
  data: Uint8Array [
    137,  80,  78,  71,  13,  10,  26,  10,   0,   0,   0,  13,
     73,  72,  68,  82,   0,   0,   3,  86,   0,   0,   1, 224,
      8,   2,   0,   0,   0,  41,  50, 107, 125,   0,   0,   0,
      9, 112,  72,  89, 115,   0,   0,   0,   1,   0,   0,   0,
      1,   0,  79,  37, 196, 214,   0,   0,  16,   0,  73,  68,
     65,  84, 120, 156, 220, 221, 247, 111,  91, 249, 153,  47,
    254, 221, 205, 100,  48,  30, 219,  80, 133,  58,  84, 161,
     10, 177, 129,  21, 172,  96,   5,  69,  73,  80, 133, 228,
      2,  87, 184,  72,
    ... 524188 more items
  ]
}

它起作用了!

希望对你有帮助~

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62950128

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档