python - 以编程方式为视频添加一个简单的暂停

标签 python matplotlib command-line ffmpeg

假设我有一个 30 多岁的视频。我想制作一个 40 秒的视频,它只是第一个视频,但在中间的某个地方有一个额外的“卡住”帧(比如 10 秒)。 (将其视为想要在特定点评论视频)

我知道我可以使用视频编辑软件轻松做到这一点。但是,我正在寻找一个可以让我有效地执行此操作的命令行工具(我需要使用可变点多次执行此操作以卡住视频)

我正在使用 Python

我想到了使用 ffmpeg,将视频分成两个,创建由给定帧组成的第三个视频,然后将三个视频连接起来。

但也许有更简单的技术?

最佳答案

我找到了一种方法

假设我有原始电影文件:in.mp4
我想在 15 秒标记处找到帧时暂停 10 秒

#first extract the frame
ffmpeg -ss 00:00:15 -i in.mp4 -vframes 1 -q:v 2 -y static_frame.png

# Create the movie_aux1.mp4 of the first part of the original video
ffmpeg -t 00:00:15 -i in.mp4 movie_aux1.mp4
# Create the movie_aux2.mp4
ffmpeg -loop 1 -i static_frame.png -t 10 movie_aux2.mp4
# Create the movie_aux3.mp4
ffmpeg -ss 00:00:15 -i in.mp4 movie_aux3.mp4

# Create a list of the movies to concatenate. Dont forget to erase this file afterwards
echo "file 'movie_aux1.mp4'" >> mylist.txt
echo "file 'movie_aux2.mp4'" >> mylist.txt
echo "file 'movie_aux3.mp4'" >> mylist.txt

# Concatenate all three movies
ffmpeg -f concat -safe 0 -i mylist.txt out.mp4

关于python - 以编程方式为视频添加一个简单的暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61632968/

相关文章:

python - 导入tensorflow时出现错误 'ImportError: DLL load failed: The specified module could not be found.'

python - Emacs 和 conda 解决方法

python - Networkx 的数据光标模式

c# - while 语句忽略响应值

testing - 填充os.Stdin以读取其中的函数

node.js - 我如何(字面意思)使用 Node 打开文件?

python - 如何对包含两个 ttk Treeviews 的 ttk Notebook 进行网格化,以便它扩展以填充其指定的网格单元?

python - SQL 语句中并未使用所有参数,但我只想更新 1 列

matplotlib - 检测matplotlib Canvas 上的相对鼠标位置

python - 发生异常 : TypeError:only size-1 arrays can be converted to Python scalars