Merge pull request #2046 from pypeclub/bugfix/ffmpeg_command_split

FFmpeg: Split command to list does not work
This commit is contained in:
Jakub Trllo 2021-09-21 10:55:09 +02:00 committed by GitHub
commit cfa6687a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 57 deletions

View file

@ -58,7 +58,7 @@ class ExtractThumbnailSP(pyblish.api.InstancePlugin):
# use first frame as thumbnail if is sequence of jpegs
full_thumbnail_path = os.path.join(
thumbnail_repre["stagingDir"], file
)
)
self.log.info(
"For thumbnail is used file: {}".format(full_thumbnail_path)
)
@ -101,14 +101,11 @@ class ExtractThumbnailSP(pyblish.api.InstancePlugin):
jpeg_items.append("\"{}\"".format(full_thumbnail_path))
subprocess_jpeg = " ".join(jpeg_items)
subprocess_args = openpype.lib.split_command_to_list(
subprocess_jpeg
)
# run subprocess
self.log.debug("Executing: {}".format(" ".join(subprocess_args)))
self.log.debug("Executing: {}".format(subprocess_jpeg))
openpype.api.run_subprocess(
subprocess_args, logger=self.log
subprocess_jpeg, shell=True, logger=self.log
)
# remove thumbnail key from origin repre

View file

@ -27,7 +27,6 @@ from .execute import (
get_pype_execute_args,
execute,
run_subprocess,
split_command_to_list,
path_to_subprocess_arg,
CREATE_NO_WINDOW
)
@ -174,7 +173,6 @@ __all__ = [
"get_pype_execute_args",
"execute",
"run_subprocess",
"split_command_to_list",
"path_to_subprocess_arg",
"CREATE_NO_WINDOW",

View file

@ -147,36 +147,6 @@ def path_to_subprocess_arg(path):
return subprocess.list2cmdline([path])
def split_command_to_list(string_command):
"""Split string subprocess command to list.
Should be able to split complex subprocess command to separated arguments:
`"C:\\ffmpeg folder\\ffmpeg.exe" -i \"D:\\input.mp4\\" \"D:\\output.mp4\"`
Should result into list:
`["C:\ffmpeg folder\ffmpeg.exe", "-i", "D:\input.mp4", "D:\output.mp4"]`
This may be required on few versions of python where subprocess can handle
only list of arguments.
To be able do that is using `shlex` python module.
Args:
string_command(str): Full subprocess command.
Returns:
list: Command separated into individual arguments.
"""
if not string_command:
return []
kwargs = {}
# Use 'posix' argument only on windows
if platform.system().lower() == "windows":
kwargs["posix"] = False
return shlex.split(string_command, **kwargs)
def get_pype_execute_args(*args):
"""Arguments to run pype command.

View file

@ -5,7 +5,6 @@ from openpype.lib import (
get_ffmpeg_tool_path,
run_subprocess,
split_command_to_list,
path_to_subprocess_arg,
should_decompress,
@ -116,13 +115,12 @@ class ExtractJpegEXR(pyblish.api.InstancePlugin):
jpeg_items.append(path_to_subprocess_arg(full_output_path))
subprocess_command = " ".join(jpeg_items)
subprocess_args = split_command_to_list(subprocess_command)
# run subprocess
self.log.debug("{}".format(subprocess_command))
try: # temporary until oiiotool is supported cross platform
run_subprocess(
subprocess_args, logger=self.log
subprocess_command, shell=True, logger=self.log
)
except RuntimeError as exp:
if "Compression" in str(exp):

View file

@ -3,7 +3,6 @@ import pyblish
import openpype.api
from openpype.lib import (
get_ffmpeg_tool_path,
split_command_to_list,
path_to_subprocess_arg
)
import tempfile
@ -62,13 +61,10 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin):
cmd += self.create_cmd(audio_inputs)
cmd += path_to_subprocess_arg(audio_temp_fpath)
# Split command to list for subprocess
cmd_list = split_command_to_list(cmd)
# run subprocess
self.log.debug("Executing: {}".format(cmd))
openpype.api.run_subprocess(
cmd_list, logger=self.log
cmd, shell=True, logger=self.log
)
# remove empty

View file

@ -14,7 +14,6 @@ from openpype.lib import (
get_ffmpeg_tool_path,
ffprobe_streams,
split_command_to_list,
path_to_subprocess_arg,
should_decompress,
@ -220,15 +219,12 @@ class ExtractReview(pyblish.api.InstancePlugin):
raise NotImplementedError
subprcs_cmd = " ".join(ffmpeg_args)
subprocess_args = split_command_to_list(subprcs_cmd)
# run subprocess
self.log.debug(
"Executing: {}".format(" ".join(subprocess_args))
)
self.log.debug("Executing: {}".format(subprcs_cmd))
openpype.api.run_subprocess(
subprocess_args, logger=self.log
subprcs_cmd, shell=True, logger=self.log
)
# delete files added to fill gaps

View file

@ -200,16 +200,14 @@ class ExtractReviewSlate(openpype.api.Extractor):
" ".join(input_args),
" ".join(output_args)
]
slate_subprocess_args = openpype.lib.split_command_to_list(
" ".join(slate_args)
)
slate_subprocess_cmd = " ".join(slate_args)
# run slate generation subprocess
self.log.debug(
"Slate Executing: {}".format(" ".join(slate_subprocess_args))
"Slate Executing: {}".format(slate_subprocess_cmd)
)
openpype.api.run_subprocess(
slate_subprocess_args, logger=self.log
slate_subprocess_cmd, shell=True, logger=self.log
)
# create ffmpeg concat text file path