Crash-Course-Computer-Scien.../1. screenshot.py
2018-05-03 12:27:14 +08:00

21 lines
775 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Crash Course Computer Science
# 这里的程序只是为了截图视频开头 00:00:00 的时间表
# 最后的输出结果40张 jpg 图片
import os
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
# 文件名举例:
# 1. 计算机早期历史-Early Computing_BiliBili.mp4
# 23. 屏幕&2D 图形显示-Screens&2D Graphics_BiliBili.mp4
filename = f
filename_array = filename.split('.')
number = filename_array[0] # 拿 1
suffix = filename_array[-1] # 拿 mp4
if suffix == 'mp4':
cmd = "ffmpeg -ss 00:00:00 -i '{0}' -vframes 1 -q:v 2 {1}.jpg".format(filename, number)
# 截图第一帧图片#
# {0} 是 input 文件名
# {1} 是输出的 jpg 名
os.system(cmd) # 执行