Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3771 from pypeclub/feature/OP-3872_Copy-Extractor…
Browse files Browse the repository at this point in the history
…-to-publish-pipeline

General: Copied 'Extractor' plugin to publish pipeline
  • Loading branch information
iLLiCiTiT authored Sep 1, 2022
2 parents 1e87bda + e4085f7 commit 9721df1
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 32 deletions.
4 changes: 4 additions & 0 deletions openpype/pipeline/publish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

RepairAction,
RepairContextAction,

Extractor,
)

from .lib import (
Expand Down Expand Up @@ -58,6 +60,8 @@
"RepairAction",
"RepairContextAction",

"Extractor",

"DiscoverResult",
"publish_plugins_discover",
"load_help_content_from_plugin",
Expand Down
25 changes: 24 additions & 1 deletion openpype/pipeline/publish/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from .lib import (
load_help_content_from_plugin,
get_errored_instances_from_context,
get_errored_plugins_from_context
get_errored_plugins_from_context,
get_instance_staging_dir,
)


Expand Down Expand Up @@ -241,3 +242,25 @@ def process(self, context, plugin):
if plugin in errored_plugins:
self.log.info("Attempting fix ...")
plugin.repair(context)


class Extractor(pyblish.api.InstancePlugin):
"""Extractor base class.
The extractor base class implements a "staging_dir" function used to
generate a temporary directory for an instance to extract to.
This temporary directory is generated through `tempfile.mkdtemp()`
"""

order = 2.0

def staging_dir(self, instance):
"""Provide a temporary directory in which to store extracted files
Upon calling this method the staging directory is stored inside
the instance.data['stagingDir']
"""

return get_instance_staging_dir(instance)
1 change: 0 additions & 1 deletion openpype/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def __init__(self, *args, **kwargs):
super(InstancePlugin, self).__init__(*args, **kwargs)


# NOTE: This class is used on so many places I gave up moving it
class Extractor(pyblish.api.InstancePlugin):
"""Extractor base class.
Expand Down
12 changes: 6 additions & 6 deletions openpype/plugins/publish/extract_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import clique
import six
import pyblish
import pyblish.api

import openpype
import openpype.api
from openpype import resources, PACKAGE_DIR
from openpype.pipeline import publish
from openpype.lib import (
run_openpype_process,

Expand All @@ -23,7 +23,7 @@
)


class ExtractBurnin(openpype.api.Extractor):
class ExtractBurnin(publish.Extractor):
"""
Extractor to create video with pre-defined burnins from
existing extracted video representation.
Expand Down Expand Up @@ -400,7 +400,7 @@ def _get_burnin_options(self):

# Use OpenPype default font
if not font_filepath:
font_filepath = openpype.api.resources.get_liberation_font_path()
font_filepath = resources.get_liberation_font_path()

burnin_options["font"] = font_filepath

Expand Down Expand Up @@ -981,7 +981,7 @@ def burnin_script_path(self):
"""Return path to python script for burnin processing."""
scriptpath = os.path.normpath(
os.path.join(
openpype.PACKAGE_DIR,
PACKAGE_DIR,
"scripts",
"otio_burnin.py"
)
Expand Down
5 changes: 3 additions & 2 deletions openpype/plugins/publish/extract_otio_file.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import pyblish.api
import openpype.api
import opentimelineio as otio

from openpype.pipeline import publish

class ExtractOTIOFile(openpype.api.Extractor):

class ExtractOTIOFile(publish.Extractor):
"""
Extractor export OTIO file
"""
Expand Down
13 changes: 9 additions & 4 deletions openpype/plugins/publish/extract_otio_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
import clique
import opentimelineio as otio
from pyblish import api
import openpype

from openpype.lib import (
get_ffmpeg_tool_path,
run_subprocess,
)
from openpype.pipeline import publish
from openpype.pipeline.editorial import (
otio_range_to_frame_range,
trim_media_range,
Expand All @@ -28,7 +33,7 @@
)


class ExtractOTIOReview(openpype.api.Extractor):
class ExtractOTIOReview(publish.Extractor):
"""
Extract OTIO timeline into one concuted image sequence file.
Expand Down Expand Up @@ -334,7 +339,7 @@ def _render_seqment(self, sequence=None,
otio.time.TimeRange: trimmed available range
"""
# get rendering app path
ffmpeg_path = openpype.lib.get_ffmpeg_tool_path("ffmpeg")
ffmpeg_path = get_ffmpeg_tool_path("ffmpeg")

# create path and frame start to destination
output_path, out_frame_start = self._get_ffmpeg_output()
Expand Down Expand Up @@ -397,7 +402,7 @@ def _render_seqment(self, sequence=None,
])
# execute
self.log.debug("Executing: {}".format(" ".join(command)))
output = openpype.api.run_subprocess(
output = run_subprocess(
command, logger=self.log
)
self.log.debug("Output: {}".format(output))
Expand Down
18 changes: 12 additions & 6 deletions openpype/plugins/publish/extract_otio_trimming_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
"""

import os
from pyblish import api
import openpype
from copy import deepcopy

import pyblish.api

from openpype.lib import (
get_ffmpeg_tool_path,
run_subprocess,
)
from openpype.pipeline import publish
from openpype.pipeline.editorial import frames_to_seconds


class ExtractOTIOTrimmingVideo(openpype.api.Extractor):
class ExtractOTIOTrimmingVideo(publish.Extractor):
"""
Trimming video file longer then required lenght
"""
order = api.ExtractorOrder
order = pyblish.api.ExtractorOrder
label = "Extract OTIO trim longer video"
families = ["trim"]
hosts = ["resolve", "hiero", "flame"]
Expand Down Expand Up @@ -70,7 +76,7 @@ def _ffmpeg_trim_seqment(self, input_file_path, otio_range):
"""
# get rendering app path
ffmpeg_path = openpype.lib.get_ffmpeg_tool_path("ffmpeg")
ffmpeg_path = get_ffmpeg_tool_path("ffmpeg")

# create path to destination
output_path = self._get_ffmpeg_output(input_file_path)
Expand All @@ -96,7 +102,7 @@ def _ffmpeg_trim_seqment(self, input_file_path, otio_range):

# execute
self.log.debug("Executing: {}".format(" ".join(command)))
output = openpype.api.run_subprocess(
output = run_subprocess(
command, logger=self.log
)
self.log.debug("Output: {}".format(output))
Expand Down
19 changes: 11 additions & 8 deletions openpype/plugins/publish/extract_review_slate.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import os
from pprint import pformat
import re
import openpype.api
import pyblish
from pprint import pformat

import pyblish.api

from openpype.lib import (
path_to_subprocess_arg,
run_subprocess,
get_ffmpeg_tool_path,
get_ffprobe_data,
get_ffprobe_streams,
get_ffmpeg_codec_args,
get_ffmpeg_format_args,
)
from openpype.pipeline import publish


class ExtractReviewSlate(openpype.api.Extractor):
class ExtractReviewSlate(publish.Extractor):
"""
Will add slate frame at the start of the video files
"""
Expand Down Expand Up @@ -158,7 +161,7 @@ def process(self, instance):

input_args.extend([
"-loop", "1",
"-i", openpype.lib.path_to_subprocess_arg(slate_path),
"-i", path_to_subprocess_arg(slate_path),
"-r", str(input_frame_rate),
"-frames:v", "1",
])
Expand Down Expand Up @@ -267,7 +270,7 @@ def process(self, instance):
self.log.debug(
"Slate Executing: {}".format(slate_subprocess_cmd)
)
openpype.api.run_subprocess(
run_subprocess(
slate_subprocess_cmd, shell=True, logger=self.log
)

Expand Down Expand Up @@ -348,7 +351,7 @@ def process(self, instance):
"Executing concat filter: {}".format
(" ".join(concat_args))
)
openpype.api.run_subprocess(
run_subprocess(
concat_args, logger=self.log
)

Expand Down Expand Up @@ -533,7 +536,7 @@ def _create_silent_slate(
self.log.debug("Silent Slate Executing: {}".format(
" ".join(slate_silent_args)
))
openpype.api.run_subprocess(
run_subprocess(
slate_silent_args, logger=self.log
)

Expand Down
10 changes: 6 additions & 4 deletions openpype/plugins/publish/extract_trim_video_audio.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os
from pprint import pformat

import pyblish.api
import openpype.api

from openpype.lib import (
get_ffmpeg_tool_path,
run_subprocess,
)
from pprint import pformat
from openpype.pipeline import publish


class ExtractTrimVideoAudio(openpype.api.Extractor):
class ExtractTrimVideoAudio(publish.Extractor):
"""Trim with ffmpeg "mov" and "wav" files."""

# must be before `ExtractThumbnailSP`
Expand Down Expand Up @@ -98,7 +100,7 @@ def process(self, instance):

joined_args = " ".join(ffmpeg_args)
self.log.info(f"Processing: {joined_args}")
openpype.api.run_subprocess(
run_subprocess(
ffmpeg_args, logger=self.log
)

Expand Down

0 comments on commit 9721df1

Please sign in to comment.