From 53d094b39e05246e77b91bdefa60343772da2615 Mon Sep 17 00:00:00 2001 From: WORD559 Date: Wed, 4 Jul 2018 12:37:50 +0100 Subject: [PATCH] Added ffmpeg detection in preparation for automated exporting --- PPM.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/PPM.py b/PPM.py index f908bc4..ad14650 100755 --- a/PPM.py +++ b/PPM.py @@ -12,14 +12,26 @@ # - Jsafive for supplying .tmb files # - Austin Burk, Midmad on hatena haiku and WDLmaster on hcs64.com for determining the sound codec # -import sys, wave, audioop, re#needs os and time aswell in CMD mode +import sys, wave, audioop, re, os #needs os and time aswell in CMD mode (UPDATE 2018/07/04: os used to get devnull for discarding subprocess output) import numpy as np +import subprocess # used for ffmpeg try: from PIL import Image hasPIL = True except ImportError: print "Warning: PIL not found, image extraction won't work!" hasPIL = False +# Test for ffmpeg by executing ffmpeg -h; an OSError indicates ffmpeg is not installed + +try: + with open(os.devnull,"w") as null: + subprocess.call(["ffmpeg","-h"], + stdout=null, + stderr=null) + hasffmpeg = True +except OSError: + print "Warning: ffmpeg not found, video export unavailable. Please make sure ffmepg is installed and can be accessed on your path." + hasffmpeg = False #helpers: def AscDec(ascii, LittleEndian=False):#Converts a ascii string into a decimal