filter - ffmpeg 使用平铺过滤器表达式

标签 filter ffmpeg tile

有没有办法为 ffmpeg 的“tile”过滤器提供表达式?我已经尝试了我能想到的使用不同转义字符和引号的每种组合,但除了像“10x10”这样的显式字符串之外,它不会接受任何其他内容。请参阅下面有效的示例:

ffmpeg -i "big_buck_bunny.mp4" -vf "tile=10x10" grid_%d.jpg

我希望能够做这样的事情:

ffmpeg -i "big_buck_bunny.mp4" -vf "tile=expr(n*2)x10" grid_%d.jpg

其中“n”是当前帧编号。这不是我想要使用的确切表达式,但想从一个简单的示例开始,然后我可以适应更复杂的表达式。我尝试过的所有操作都会出现如下错误:

[tile @ 0x7facc1d000c0] Unable to parse option value "expr(n*2)x10" as image size

tile 可以不接受表达式吗?或者我应该尝试某种连接函数?

最佳答案

我没有完全回答你的问题,但这可能有助于找到它。

如果您想根据帧数进行计算,您可能必须从以下输出中提取 nb_frames 属性 ffprobe -show_streams -i“big_buck_bunny.mp4” 第一的。然后您可以执行计算并使用正确的平铺过滤器将结果插入到您的命令中。

如果您正在寻找一种从视频中仅提取一定数量的帧并将它们合并到一个文件中的方法,我会推荐此网站上的教程:http://www.binpress.com/tutorial/how-to-generate-video-previews-with-ffmpeg/138

Generating a preview is just another one-liner where ffmpeg captures images and joins them into a single long film strip.

ffmpeg -loglevel panic -y -i "video.mp4" -frames 1 -q:v 1 -vf "select=not(mod(n\,40)),scale=-1:120,tile=100x1" video_preview.jpg

  • -loglevel panic We don’t want to see any output. You can remove this option if you’re having any problems seeing what went wrong.
  • -i "$MOVIE" The input file.
  • -y Override any existing output file.
  • -frames 1 Tell ffmpeg that output from this command is just a single image (one frame).
  • -q:v 1 Output quality, 0 is the best.
  • -vf select= That's where all the magic happens. This is the selector function for video filter.
    • not(mod(n\,40)) Select one frame every 40 frames see the documentation.
    • scale=-1:120 Resize frames to fit 120px height, and the width is adjusted automatically to keep the correct aspect ratio.
    • tile=100x1 Layout captured frames into this grid.

关于filter - ffmpeg 使用平铺过滤器表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28617047/

相关文章:

java - 记录 Spring REST API

video - 使用 ffmpeg 进行动态转码和 HLS 流式传输

tile - 将大型 GeoTiff 切成 1 度的图 block

tile - 芒果应用瓷砖-移除

google-sheets - 过滤不在谷歌表格列表中的数据的功能是什么?

php - Wordpress 查询添加 INNER/LEFT JOIN。为什么或如何删除/防止 INNER/LEFT JOIN?

python - 根据条件将 Pandas DataFrame 中的一行替换为 'NaN'

node.js - 如何通过 node-fluent-ffmpeg 获取视频时长?

linux - ffprobe 报告一些错误的元数据,但仅当输入通过管道传入时

c# - 如何在C#中平铺两个程序窗口?