mirror of
https://github.com/KwaiVGI/LivePortrait.git
synced 2024-12-22 20:42:38 +00:00
fix: use opencv to get fps of the driving video (#93)
Co-authored-by: tuling <tuling.com>
This commit is contained in:
parent
3c1a866b6b
commit
1a11b2ffe2
@ -141,9 +141,7 @@ def change_video_fps(input_file, output_file, fps=20, codec='libx264', crf=5):
|
|||||||
|
|
||||||
def get_fps(filepath, default_fps=25):
|
def get_fps(filepath, default_fps=25):
|
||||||
try:
|
try:
|
||||||
probe = ffmpeg.probe(filepath)
|
fps = cv2.VideoCapture(filepath).get(cv2.CAP_PROP_FPS)
|
||||||
video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None)
|
|
||||||
fps = eval(video_stream['avg_frame_rate'])
|
|
||||||
|
|
||||||
if fps in (0, None):
|
if fps in (0, None):
|
||||||
fps = default_fps
|
fps = default_fps
|
||||||
|
Loading…
Reference in New Issue
Block a user