mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #286 from tokejepsen/2.x/feature/harmony_audio
Load audio
This commit is contained in:
commit
9cd35c9612
2 changed files with 46 additions and 1 deletions
42
pype/plugins/harmony/load/load_audio.py
Normal file
42
pype/plugins/harmony/load/load_audio.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
from avalon import api, harmony
|
||||
|
||||
|
||||
func = """
|
||||
function getUniqueColumnName( column_prefix )
|
||||
{
|
||||
var suffix = 0;
|
||||
// finds if unique name for a column
|
||||
var column_name = column_prefix;
|
||||
while(suffix < 2000)
|
||||
{
|
||||
if(!column.type(column_name))
|
||||
break;
|
||||
|
||||
suffix = suffix + 1;
|
||||
column_name = column_prefix + "_" + suffix;
|
||||
}
|
||||
return column_name;
|
||||
}
|
||||
|
||||
function func(args)
|
||||
{
|
||||
var uniqueColumnName = getUniqueColumnName(args[0]);
|
||||
column.add(uniqueColumnName , "SOUND");
|
||||
column.importSound(uniqueColumnName, 1, args[1]);
|
||||
}
|
||||
func
|
||||
"""
|
||||
|
||||
|
||||
class ImportAudioLoader(api.Loader):
|
||||
"""Import audio."""
|
||||
|
||||
families = ["shot"]
|
||||
representations = ["wav"]
|
||||
label = "Import Audio"
|
||||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
wav_file = api.get_representation_path(context["representation"])
|
||||
harmony.send(
|
||||
{"function": func, "args": [context["subset"]["name"], wav_file]}
|
||||
)
|
||||
|
|
@ -28,7 +28,8 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
scene.currentScene(),
|
||||
scene.getFrameRate(),
|
||||
scene.getStartFrame(),
|
||||
scene.getStopFrame()
|
||||
scene.getStopFrame(),
|
||||
sound.getSoundtrackAll().path()
|
||||
]
|
||||
}
|
||||
func
|
||||
|
|
@ -41,6 +42,7 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
frame_rate = result[3]
|
||||
frame_start = result[4]
|
||||
frame_end = result[5]
|
||||
audio_path = result[6]
|
||||
|
||||
# Set output path to temp folder.
|
||||
path = tempfile.mkdtemp()
|
||||
|
|
@ -111,6 +113,7 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
mov_path = os.path.join(path, instance.data["name"] + ".mov")
|
||||
args = [
|
||||
"ffmpeg", "-y",
|
||||
"-i", audio_path,
|
||||
"-i",
|
||||
os.path.join(path, collection.head + "%04d" + collection.tail),
|
||||
mov_path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue