流利的 ffmpeg display_aspect_ratio 不改变
大家好,我正在尝试使用流畅的 ffmpeg 将某些输入的宽度和高度调整为 768x1366(基本上以垂直模式显示),所以我还必须更改其 display_aspect_ratio,我碰巧知道它是 0.562225476。 这里的问题是,根据 Fluent-ffmpeg doc,如果我设置固定大小,它不会改变宽高比,但如果我使用 ?
为自动模式,它也不会工作。这是我的代码:
ffmpeg({source: req.file.path})
.withFps(30)
.toFormat('mp4')
.size("768x?")
.aspect(0.562225476)
控制台命令: ffmpeg -i tmp/video.mp4 -y -r 30 -filter:v scale=w=768:h=1366 -f mp4 ./src/internal/media/video.mp4
所以当我使用 ffprobe 检查 display_aspect_ratio 它仍然是 4:3(作为源文件)。
如果我不添加 .aspect()
选项,则该命令完全相同......所以它不会考虑它。
我也尝试过:
ffmpeg({source: req.file.path})
.withFps(30)
.toFormat('mp4')
.size('768x1366')
.addOptions('-vf setdar=0.562225476')
这里的命令最终是 ffmpeg -i tmp/video.mp4 -y -r 30 -filter:v scale=w=768:h=1366 -f mp4 -vf setdar=0.562225476 。 /src/internal/media/video.mp4,所以看起来没问题,但是当我检查 ffprobe 时它没有应用宽度和高度变化。
我真正需要的命令是某种:ffmpeg -i video.mp4 -vf scale=768:1766,"setdar=0.562225476" video2.mp4
,它会改变两者, widthXheight 和 display_aspect_ratio
Hi everyone i'm trying to resize width and height of certain input with fluent ffmpeg to 768x1366 (basically to show it in vertical mode), so i have to also change its display_aspect_ratio which i happen to know is 0.562225476.
The issue here is that, according to fluent-ffmpeg doc, if i set a fix size, it wont change the aspect ratio, but it wont work either if I use ?
to automatic mode. This is my code:
ffmpeg({source: req.file.path})
.withFps(30)
.toFormat('mp4')
.size("768x?")
.aspect(0.562225476)
Console command:ffmpeg -i tmp/video.mp4 -y -r 30 -filter:v scale=w=768:h=1366 -f mp4 ./src/internal/media/video.mp4
So when i check the display_aspect_ratio with ffprobe
it's still 4:3 (as source file).
If I do not add the .aspect()
option, the command is exactly the same...so it's not considering it.
I've also tried:
ffmpeg({source: req.file.path})
.withFps(30)
.toFormat('mp4')
.size('768x1366')
.addOptions('-vf setdar=0.562225476')
And command here ends up being ffmpeg -i tmp/video.mp4 -y -r 30 -filter:v scale=w=768:h=1366 -f mp4 -vf setdar=0.562225476 ./src/internal/media/video.mp4
, so it seemed ok, but when I check with ffprobe it did not apply width and height changes.
The command I really need is some kind of : ffmpeg -i video.mp4 -vf scale=768:1766,"setdar=0.562225476" video2.mp4
which changes both, widthXheight and display_aspect_ratio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,您的最后一个调用正是您需要做的(除非您不需要
setdar
周围的双引号)。[编辑]
你就不能这样做吗?
[/edit]
我不知道如何使用
Fluent-ffmpeg
做到这一点,但从前,我提交了kiss-ffmpeg
到 NPM,将控制台 ffmpeg 命令更容易地转换为 JavaScript。它不再被维护(因为我后来转向了 Python),但我看到人们仍在下载,所以应该仍然可用。指定
vf
选项。使用
kiss-ffmpeg
,您可以通过查看 NPM 自述文件了解如何设置调用的其余部分来Indeed, your last call is exactly what you need to do (except you don't need the double quotes around
setdar
).[edit]
Can't you just do this?
[/edit]
I don't know how to do that with
fluent-ffmpeg
, but once upon a time, I submittedkiss-ffmpeg
to NPM to translate console ffmpeg command easier to JavaScript. It's no longer maintained (as I moved to Python since) but I see people are still downloading so should be still usable.With
kiss-ffmpeg
, you can specify yourvf
option bySee the NPM readme for how to set up the rest of the call.