【问题标题】:Add ken burn effect on video from list of images从图像列表中添加对视频的刻录效果
【发布时间】:2015-12-17 18:15:09
【问题描述】:

我使用 ffmpeg 从图像列表中创建了视频

system("ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4")

现在我想添加 Ken Burn 效果,我可以用 ffmpeg 或 imagemagic 或任何 linux 上的命令行工具来做吗?

【问题讨论】:

  • 这和编程有什么关系?你会写一些东西来自动(不止一次)吗?请查看我们的topics列表
  • 是的,会自动生成带有kenburn效果的视频

标签: ruby-on-rails linux ffmpeg imagemagick zooming


【解决方案1】:

我不能谈论 技术。但是,如果您想创建由 Ken Burn 流行的平移效果,您可以提取图像的区域,并将它们一起制作动画。

#!/bin/bash

# A 16:10 ratio
WIDTH=64
HEIGHT=40

# Extract parts of an image with -extent operator
for index in $(seq 40)
do
  TOP=$(expr 120 + $index)
  LEFT=$(expr 150 + $index)
  FILENAME=$(printf  /tmp/wizard-%02d.jpg $index)
  convert wizard: -extent "${WIDTH}x${HEIGHT}+${TOP}+${LEFT}" $FILENAME
done

# Replace this with your ffmpeg script
SLICES=$(ls /tmp/wizard-*.jpg)
RSLCES=$(ls /tmp/wizard-*.jpg | sort -rn)
convert $SLICES $RSLCES -set delay 15 -layers Optimize /tmp/movie.gif

由 Mark Setchell 编辑...(只是想帮忙)

尽管我讨厌编辑其他人的帖子,但如果您觉得这样更容易理解,Eric 代码的第一部分同样可以这样编写:

# Extract parts of an image with -extent operator
for index in {1..40}
do
  ((TOP=120 + $index))
  ((LEFT=150 + $index))
  FILENAME=$(printf  /tmp/wizard-%02d.jpg $index)
  convert wizard: -extent "${WIDTH}x${HEIGHT}+${TOP}+${LEFT}" $FILENAME
done

【讨论】:

  • seq 是一个生成数字序列的实用程序。使用man seq 查看手册。 expr 只计算一个表达式。就像之前一样;只需执行man expr 即可查看手册。您可以添加调试打印和回显语句以了解每次迭代的当前值。
  • 还有一个问题,这个程序是针对随机序列图像的,不希望图像是有序的?和 **convert $SLICES $RSLCES -set delay 15 -layers Optimize /tmp/movie.gif ** 我必须用我的 ffmpeg 命令删除最后一个转换命令,对吗?
  • 没错。 $RSLICES$SLICES 正好相反,用于 GIF 中的演示。你可以用你已经在使用的ffmpeg 命令替换所有这些。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-08
  • 2017-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-05
  • 1970-01-01
相关资源
最近更新 更多