use get_path_to_ffmpeg which checks if any of filled ffmpeg paths in FFMPEG_PATH exists

This commit is contained in:
iLLiCiTiT 2020-02-11 14:01:56 +01:00
parent c71b8dbf2c
commit 62b3f852f1
9 changed files with 28 additions and 13 deletions

View file

@ -13,6 +13,15 @@ import avalon
log = logging.getLogger(__name__)
def get_path_to_ffmpeg():
paths = os.environ.get("FFMPEG_PATH") or ""
path_items = paths.split(os.pathsep)
for item in path_items:
item = os.path.normpath(item)
if os.path.exists(item):
return item
return ""
# Special naming case for subprocess since its a built-in method.
def _subprocess(*args, **kwargs):
"""Convenience method for getting output errors for subprocess."""

View file

@ -3,6 +3,7 @@ import os
import pyblish.api
import clique
import pype.api
import pype.lib
class ExtractJpegEXR(pyblish.api.InstancePlugin):
@ -67,7 +68,7 @@ class ExtractJpegEXR(pyblish.api.InstancePlugin):
jpeg_items = []
jpeg_items.append(
os.path.join(os.environ.get("FFMPEG_PATH"), "ffmpeg"))
os.path.join(pype.lib.get_path_to_ffmpeg(), "ffmpeg"))
# override file if already exists
jpeg_items.append("-y")
# use same input args like with mov

View file

@ -313,9 +313,8 @@ class ExtractReview(pyblish.api.InstancePlugin):
mov_args = [
os.path.join(
os.environ.get(
"FFMPEG_PATH",
""), "ffmpeg"),
pype.lib.get_path_to_ffmpeg(), "ffmpeg"
),
" ".join(input_args),
" ".join(output_args)
]

View file

@ -1,5 +1,6 @@
import os
import pype.api
import pype.lib
import pyblish
@ -21,7 +22,7 @@ class ExtractReviewSlate(pype.api.Extractor):
suffix = "_slate"
slate_path = inst_data.get("slateFrame")
ffmpeg_path = os.path.join(os.environ.get("FFMPEG_PATH", ""), "ffmpeg")
ffmpeg_path = os.path.join(pype.lib.get_path_to_ffmpeg(), "ffmpeg")
to_width = 1920
to_height = 1080

View file

@ -1,6 +1,7 @@
import pyblish.api
import os
import subprocess
import pype.lib
try:
import os.errno as errno
except ImportError:
@ -28,9 +29,10 @@ class ValidateFfmpegInstallef(pyblish.api.Validator):
def process(self, instance):
self.log.info("ffmpeg path: `{}`".format(
os.environ.get("FFMPEG_PATH", "")))
pype.lib.get_path_to_ffmpeg()
))
if self.is_tool(
os.path.join(
os.environ.get("FFMPEG_PATH", ""), "ffmpeg")) is False:
pype.lib.get_path_to_ffmpeg(), "ffmpeg")) is False:
self.log.error("ffmpeg not found in PATH")
raise RuntimeError('ffmpeg not installed.')

View file

@ -4,6 +4,7 @@ import tempfile
import pyblish.api
import clique
import pype.api
import pype.lib
class ExtractReviewSP(pyblish.api.InstancePlugin):
@ -148,7 +149,7 @@ class ExtractReviewSP(pyblish.api.InstancePlugin):
# output filename
output_args.append(full_output_path)
ffmpeg_path = os.getenv("FFMPEG_PATH", "")
ffmpeg_path = pype.lib.get_path_to_ffmpeg()
if ffmpeg_path:
ffmpeg_path += "/ffmpeg"
else:

View file

@ -3,6 +3,7 @@ import tempfile
import subprocess
import pyblish.api
import pype.api
import pype.lib
class ExtractThumbnailSP(pyblish.api.InstancePlugin):
@ -73,7 +74,7 @@ class ExtractThumbnailSP(pyblish.api.InstancePlugin):
config_data.get("__default__", {})
)
ffmpeg_path = os.getenv("FFMPEG_PATH", "")
ffmpeg_path = pype.lib.get_path_to_ffmpeg()
if ffmpeg_path:
ffmpeg_path += "/ffmpeg"
else:

View file

@ -5,14 +5,14 @@ import json
import opentimelineio_contrib.adapters.ffmpeg_burnins as ffmpeg_burnins
from pypeapp.lib import config
from pype import api as pype
from subprocess import Popen, PIPE
import pype.lib
# FFmpeg in PATH is required
log = pype.Logger().get_logger("BurninWrapper", "burninwrap")
ffmpeg_path = os.environ.get("FFMPEG_PATH")
ffmpeg_path = pype.lib.get_path_to_ffmpeg()
if ffmpeg_path and os.path.exists(ffmpeg_path):
# add separator "/" or "\" to be prepared for next part
ffmpeg_path += os.path.sep
@ -267,7 +267,7 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins):
command = self.command(output=output,
args=args,
overwrite=overwrite)
proc = Popen(command, shell=True)
proc = subprocess.Popen(command, shell=True)
proc.communicate()
if proc.returncode != 0:
raise RuntimeError("Failed to render '%s': %s'"

View file

@ -4,6 +4,7 @@ import json
import clique
import subprocess
from pypeapp import config
import pype.lib
from . import QtWidgets, QtCore
from . import DropEmpty, ComponentsList, ComponentItem
@ -224,7 +225,7 @@ class DropDataFrame(QtWidgets.QFrame):
self._process_data(data)
def load_data_with_probe(self, filepath):
ffprobe_path = os.getenv("FFMPEG_PATH", "")
ffprobe_path = pype.lib.get_path_to_ffmpeg()
if ffprobe_path:
ffprobe_path += '/ffprobe'
else: