Dus*_*gal 5 video ffmpeg node.js fluent-ffmpeg
我为此找到了很多样本,但没有一个适合我。
我有几个图像。URL、Base64 或缓冲区。
我需要将它们转换为视频,而不改变质量。
我最接近的是这个命令:
ffmpeg -framerate 1 pattern_type glob -i 'images/*.jpg' -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
但它每秒显示 1 张图像。我需要视频为 30fps,不是 30 帧的 1 张图像,而是每秒 30 张图像。
有人可以帮我弄这个吗?
我最终使用了不同的包 - ffmpeg-stream
我从 AWS 获取图像,因此下面有一些 AWS 代码:
const frames = ['frame1.jpg', 'frame2.jpg', ...]
const conv = ffmpeg() // create converter
const input = conv.input({f: 'image2pipe', r: 30}) // create input writable stream
conv.output('out.mp4', {vcodec: 'libx264', pix_fmt: 'yuv420p'}) // output to file
// for every frame create a function that returns a promise
frames.map(filename => () =>
new Promise((fulfill, reject) =>
s3
.getObject({Bucket: '...', Key: filename})
.createReadStream()
.on('end', fulfill) // fulfill promise on frame end
.on('error', reject) // reject promise on error
.pipe(input, {end: false}) // pipe to converter, but don't end the input yet
)
)
// reduce into a single promise, run sequentially
.reduce((prev, next) => prev.then(next), Promise.resolve())
// end converter input
.then(() => input.end())
conv.run()
Run Code Online (Sandbox Code Playgroud)
这是我在 github 存储库上发布的问题: https://github.com/phaux/node-ffmpeg-stream/issues/5
| 归档时间: |
|
| 查看次数: |
6237 次 |
| 最近记录: |