一个关键帧和ffmpeg iframes提取器
video-kf的Python项目详细描述
快速指南
安装
pip install video-kf
使用
从视频所在的同一目录打开命令行或终端,然后运行:
^{pr2}$如果命令行是在视频所在的不同目录中打开的,则完整路径将为 需要。在
扩展文档
Video kf是一个Python包,可以从命令行运行,也可以通过导入从Python内部运行。 它基于不同的方法提取视频中最相关的关键帧。在
目前,有3种方法可供选择:
- 在
iframes:它提取视频的iframes, 由ffmpeg计算。这是默认选项。在
在命令行中使用:
^{pr2}$或者
video-kf "My_video.mp4" -m "iframes"
在Python内部使用:
importvideokfasvfvf.extract_keyframes("My_video.mp4")
或者
importvideokfasvfvf.extract_keyframes("My_video.mp4",method="iframes")
在 - 在
color:返回基于颜色的每个快照序列的平均帧。镜头序列是一组帧 从一个iframe开始。在
在命令行中使用:
video-kf "My_video.mp4" -m "color"
在Python内部使用:
importvideokfasvfvf.extract_keyframes("My_video.mp4",method="color")
在 - 在
flow:返回相对于每个快照序列前一帧的最静止帧。镜头序列 是以iframe开头的帧组。在
在命令行中使用:
video-kf "My_video.mp4" -m "flow"
在Python内部使用:
importvideokfasvfvf.extract_keyframes("My_video.mp4",method="flow")
在
注意
方法color和flow^{str1}$将下载视频的所有帧。请记住,如果视频很长, 这将需要时间和空间来保存帧。在
对于只下载iframes的方法iframes则不是这样。在
Ffmpeg和Ffprobe的使用
Video kf自动下载ffmpeg和ffprobe的可执行文件,并在默认情况下保存在 名为“Ffmpeg”的文件夹,位于home目录中。您可以选择将可执行文件保存在其他 运行位置:
video-kf "My_video.mp4" -dir "PATH_RO_A_DIFFERENT_LOCATION"
如果已经安装了ffmpeg或ffprobe,则还可以使用自己的可执行文件。有很多种方法 这样做,他们都是同等的。选择最适合你的:
- 在
使用命令行选项ffmpeg和ffprobe(您可以选择只使用这两个选项中的一个):
在video-kf "My_video.mp4" -ffmpeg "PATH_TO_FFMPEG" -ffprobe "PATH_TO_FFPROBE"
- 在
将ffmpeg和ffprobe保存为分别命名为ffmpeg和ffprobe的环境变量。在
在 - 在
手动保存ffmpeg和ffprobe到名为“ffmpeg”的文件夹中,默认情况下该文件夹位于home 目录,并正常运行程序(在命令行中或在python中)。您也可以选择 通过命令行使用
在-dir
选项更改目录
命令行选项
positional arguments:
video_file Path to the video file to extract the keyframes from.
optional arguments:
-h, --help show this help message and exit
-m METHOD, --method METHOD
Method to extract the keyframes
-o OUTPUT_DIR_KEYFRAMES, --output_dir_keyframes OUTPUT_DIR_KEYFRAMES
Directory where to extract keyframes. If it is a
string instead of a directory, keyframes will be saved
in a folder named as this string, located in the same
directory of the video
-ffmpeg FFMPEG, --ffmpeg FFMPEG
Path to the Ffmpeg executable
-ffprobe FFPROBE, --ffprobe FFPROBE
Path to the Ffprobe executable
-dir DIR_FFMPEG_FFPROBE, --dir_ffmpeg_ffprobe DIR_FFMPEG_FFPROBE
Path to the directory containing both Ffmpeg and
Ffprobe executables
--no-frames-rm If present, this option will NOT remove the directory
with the extracted frames, if they were extracted
(only for 'color' and 'flow' methods)
参考文献
FFmpeg开发人员。(2016年)。Ffmpeg工具[软件]。 可从http://ffmpeg.org/获得
从:https://ffbinaries.com/readme获取的二进制文件
- 项目
标签: