功能
根据更改原始视频的播放速度并保存更改视频
可指定fps,也可指定播放倍速,两者同时指定时,以fps为主
依赖库
python3,cv2
代码实现
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/04/08
# @Author : Devil_Xiao
# Purpose: This script is used to change the video_speed
# You can choose to specify the fps,
# or you can choose to change the multiple of the original playback speed
import cv2
from cv2 import VideoWriter, VideoWriter_fourcc
import argparse
def video_speed(video_root, out_root, fps=None, scale=1):
"""When fps and scale are specified at the same time, fps is the dominant"""
cap = cv2.VideoCapture(video_root