Skip to content

Commit

Permalink
Added ffmpeg installation check
Browse files Browse the repository at this point in the history
  • Loading branch information
chunyu-li committed Jan 19, 2025
1 parent 21e36b6 commit c59cf07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion latentsync/pipelines/lipsync_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from ..models.unet import UNet3DConditionModel
from ..utils.image_processor import ImageProcessor
from ..utils.util import read_video, read_audio, write_video
from ..utils.util import read_video, read_audio, write_video, check_ffmpeg_installed
from ..whisper.audio2feature import Audio2Feature
import tqdm
import soundfile as sf
Expand Down Expand Up @@ -317,6 +317,8 @@ def __call__(
is_train = self.unet.training
self.unet.eval()

check_ffmpeg_installed()

# 0. Define call parameters
batch_size = 1
device = self._execution_device
Expand Down
7 changes: 7 additions & 0 deletions latentsync/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,10 @@ def count_video_time(video_path):
frame_count = video.get(cv2.CAP_PROP_FRAME_COUNT)
fps = video.get(cv2.CAP_PROP_FPS)
return frame_count / fps


def check_ffmpeg_installed():
# Run the ffmpeg command with the -version argument to check if it's installed
result = subprocess.run("ffmpeg -version", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
if not result.returncode == 0:
raise FileNotFoundError("ffmpeg not found, please install it by:\n $ conda install -c conda-forge ffmpeg")

0 comments on commit c59cf07

Please sign in to comment.