add voice over, output 6 channels, add 5.1 mix

This commit is contained in:
j 2023-10-16 23:26:09 +01:00
commit 9c778bb7de
3 changed files with 263 additions and 37 deletions

View file

@ -1,5 +1,6 @@
import json
import os
from collections import defaultdict
from django.core.management.base import BaseCommand
from django.conf import settings
@ -44,3 +45,23 @@ class Command(BaseCommand):
with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
json.dump(clips, fd, indent=2, ensure_ascii=False)
voice_over = defaultdict(dict)
for vo in item.models.Item.objects.filter(
data__type__contains="Voice Over",
):
fragment_id = int(vo.get('title').split('_')[0])
source = vo.files.all()[0]
batch = vo.get('batch')[0].replace('Text-', '')
src = source.data.path
target = os.path.join(prefix, 'voice_over', batch, '%s.wav' % fragment_id)
os.makedirs(os.path.dirname(target), exist_ok=True)
if os.path.exists(target):
os.unlink(target)
os.symlink(src, target)
voice_over[fragment_id][batch] = {
"src": target,
"duration": source.duration
}
with open(os.path.join(prefix, 'voice_over.json'), 'w') as fd:
json.dump(voice_over, fd, indent=2, ensure_ascii=False)