-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotion_transfer.py
More file actions
31 lines (25 loc) · 969 Bytes
/
Copy pathmotion_transfer.py
File metadata and controls
31 lines (25 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import cv2
import numpy as np
def transfer_motion(input_video_path):
"""
Placeholder function for motion transfer.
Currently just copies the video as-is.
Replace this with FOMM / first-order-motion model code for actual character replacement.
"""
output_path = input_video_path.replace("input_videos", "output_videos").replace(".mp4", "_transferred.mp4")
cap = cv2.VideoCapture(input_video_path)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS)
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
while True:
ret, frame = cap.read()
if not ret:
break
# For now: no change. Replace this with actual transferred frame.
out.write(frame)
cap.release()
out.release()
return output_path