Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pytapo/media_stream/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def __init__(self):
self.known_lengths = {}
self.addedChunks = 0
self.lengthLastCalculatedAtChunk = 0
if not self.is_ffmpeg_installed():
raise Exception('ffmpeg is not installed')

# cuts and saves the video
def save(self, fileLocation, fileLength, method="ffmpeg"):
Expand Down Expand Up @@ -114,3 +116,10 @@ def getLength(self, exact=False):
def write(self, data: bytes, audioData: bytes):
self.addedChunks += 1
return self.writer.write(data) and self.audioWriter.write(audioData)

def is_ffmpeg_installed(self):
try:
subprocess.run(["ffmpeg", "-version"], capture_output=True, check=True)
return True
except (FileNotFoundError, subprocess.CalledProcessError):
return False