从图像列表中为视频添加 ken burn 效果

Add ken burn effect on video from list of images

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

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

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

我不能谈论 , , or 技术。但是,如果您想创建 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