Load audio

- Audio on renders (reviews)
This commit is contained in:
Toke Stuart Jepsen 2020-06-17 15:37:57 +01:00
parent e75167445f
commit 0ab4842c03
2 changed files with 46 additions and 1 deletions

View 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]}
)

View 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