1 Star 0 Fork 0

dengxuezheng/video-object-removal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
convert_frames2video.py 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
zllrunning 提交于 2019-07-03 16:18 . init repo
import glob
import cv2
import os
import numpy as np
import subprocess as sp
def createVideoClip(clip, folder, name, size=[256, 256]):
vf = clip.shape[0]
command = ['ffmpeg',
'-y', # overwrite output file if it exists
'-f', 'rawvideo',
'-s', '%dx%d' % (size[1], size[0]), # '256x256', # size of one frame
'-pix_fmt', 'rgb24',
'-r', '25', # frames per second
'-an', # Tells FFMPEG not to expect any audio
'-i', '-', # The input comes from a pipe
'-vcodec', 'libx264',
'-b:v', '1500k',
'-vframes', str(vf), # 5*25
'-s', '%dx%d' % (size[1], size[0]), # '256x256', # size of one frame
folder + '/' + name]
# sfolder+'/'+name
pipe = sp.Popen(command, stdin=sp.PIPE, stderr=sp.PIPE)
out, err = pipe.communicate(clip.tostring())
pipe.wait()
pipe.terminate()
print(err)
if __name__ == '__main__':
out_frames = []
video_name = 'Human6'
for path in sorted(glob.glob(os.path.join('data', video_name, '*.jp*'))):
print(path)
out_frame = cv2.imread(path)
shape = out_frame.shape
out_frames.append(out_frame[:, :, ::-1])
final_clip = np.stack(out_frames)
video_path = 'results'
if not os.path.exists(video_path):
os.makedirs(video_path)
createVideoClip(final_clip, video_path, '%s.mp4' % (video_name), [shape[0], shape[1]])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dengxuezheng/video-object-removal.git
git@gitee.com:dengxuezheng/video-object-removal.git
dengxuezheng
video-object-removal
video-object-removal
master

搜索帮助