mirror of
https://github.com/KwaiVGI/LivePortrait.git
synced 2024-12-22 20:42:38 +00:00
fix: audio stream set false without ffmepg and ffprobe (#100)
This commit is contained in:
parent
877295a776
commit
7c77e29442
@ -1,7 +1,9 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
"""
|
"""
|
||||||
functions for processing video
|
Functions for processing video
|
||||||
|
|
||||||
|
ATTENTION: you need to install ffmpeg and ffprobe in your env!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os.path as osp
|
import os.path as osp
|
||||||
@ -9,19 +11,11 @@ import numpy as np
|
|||||||
import subprocess
|
import subprocess
|
||||||
import imageio
|
import imageio
|
||||||
import cv2
|
import cv2
|
||||||
|
from rich.progress import track
|
||||||
|
|
||||||
from .rprint import rlog as log
|
from .rprint import rlog as log
|
||||||
|
|
||||||
# try:
|
|
||||||
# import ffmpeg
|
|
||||||
# except ImportError as e:
|
|
||||||
# log(f'Try to install ffmpeg by: pip install ffmpeg-python==0.2.0', style='bold red')
|
|
||||||
# raise(e)
|
|
||||||
|
|
||||||
from rich.progress import track
|
|
||||||
from .helper import prefix
|
|
||||||
from .rprint import rprint as print
|
from .rprint import rprint as print
|
||||||
|
from .helper import prefix
|
||||||
|
|
||||||
|
|
||||||
def exec_cmd(cmd):
|
def exec_cmd(cmd):
|
||||||
@ -146,7 +140,7 @@ def get_fps(filepath, default_fps=25):
|
|||||||
if fps in (0, None):
|
if fps in (0, None):
|
||||||
fps = default_fps
|
fps = default_fps
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
log(e)
|
||||||
fps = default_fps
|
fps = default_fps
|
||||||
|
|
||||||
return fps
|
return fps
|
||||||
@ -171,13 +165,17 @@ def has_audio_stream(video_path: str) -> bool:
|
|||||||
video_path
|
video_path
|
||||||
]
|
]
|
||||||
|
|
||||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
try:
|
||||||
if result.returncode != 0:
|
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||||
log(f"Error occurred while probing video: {result.stderr}")
|
if result.returncode != 0:
|
||||||
return False
|
log(f"Error occurred while probing video: {result.stderr}")
|
||||||
|
return False
|
||||||
|
|
||||||
# Check if there is any output from ffprobe command
|
# Check if there is any output from ffprobe command
|
||||||
return bool(result.stdout.strip())
|
return bool(result.stdout.strip())
|
||||||
|
except Exception as e:
|
||||||
|
log(f"Error occurred while probing video: {video_path}, you may need to install ffprobe! Now set audio to false!", style="bold red")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def add_audio_to_video(silent_video_path: str, audio_video_path: str, output_video_path: str):
|
def add_audio_to_video(silent_video_path: str, audio_video_path: str, output_video_path: str):
|
||||||
|
Loading…
Reference in New Issue
Block a user