Skip to content

Commit

Permalink
Ensure ffmpeg dependency is installed
Browse files Browse the repository at this point in the history
- to ensure ffmpeg is installed for macos when reencoding video
  • Loading branch information
kchiem12 committed Oct 1, 2023
1 parent 80eb10a commit 7d35268
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/processing/video_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
import random
import os
import numpy as np
import subprocess
import sys

# pass in homo matrix + +
# implement video reencoding

class VideoRender:
def __init__(self, homography):
self._TRUE_PATH = os.path.join('data','true_map.png')
Expand All @@ -15,7 +19,24 @@ def reencode(self, input_path, output_path):
"""
Re-encodes a MPEG4 video file to H.264 format. Overrides existing output videos if present.
Deletes the unprocessed video when complete.
Ensures ffmpeg dependency is installed
"""

if sys.platform != 'darwin':
print("Designed to install dependency for macOS")
else:
try:
# check if it is installed already
subprocess.run(["brew", "list", "ffmpeg"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except:
# install dependency
print("Installing ffmpeg")
try:
subprocess.run(["brew", "install", "ffmpeg"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except:
print("Error installing ffmpeg")
return

reencode_command = f'ffmpeg -y -i {input_path} -vcodec libx264 -c:a copy {output_path}'
os.system(reencode_command)
# os.remove(input_path)
Expand Down

0 comments on commit 7d35268

Please sign in to comment.