Compare commits
2 commits
38a893aae7
...
a7816225a5
| Author | SHA1 | Date | |
|---|---|---|---|
| a7816225a5 | |||
| e31df1790c |
2 changed files with 36 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
|
@ -33,6 +34,7 @@ class Command(BaseCommand):
|
|||
def add_arguments(self, parser):
|
||||
parser.add_argument('--lang', action='store', dest='lang', default=None, help='subtitle language')
|
||||
parser.add_argument('--prefix', action='store', dest='prefix', default="/srv/t_for_time", help='prefix to build clips in')
|
||||
parser.add_argument('--censored', action='store', dest='censored', default=None, help='censor items from list')
|
||||
|
||||
def handle(self, **options):
|
||||
prefix = options['prefix']
|
||||
|
|
@ -45,8 +47,12 @@ class Command(BaseCommand):
|
|||
tlang = None
|
||||
if lang == "en":
|
||||
lang = None
|
||||
if options['censored']:
|
||||
censored_list = itemlist.models.List.get(options["censored"])
|
||||
censored = list(censored_list.get_items(censored_list.user).all().values_list('public_id', flat=True))
|
||||
clips = []
|
||||
for i in item.models.Item.objects.filter(sort__type='original'):
|
||||
original_target = ""
|
||||
qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id)
|
||||
if qs.count() >= 1:
|
||||
clip = {}
|
||||
|
|
@ -65,6 +71,10 @@ class Command(BaseCommand):
|
|||
if os.path.islink(target):
|
||||
os.unlink(target)
|
||||
os.symlink(source, target)
|
||||
if type_ == "original":
|
||||
original_target = target
|
||||
if options['censored'] and e.public_id in censored:
|
||||
target = '/srv/t_for_time/censored.mp4'
|
||||
clip[type_] = target
|
||||
durations.append(e.files.filter(selected=True)[0].duration)
|
||||
clip["duration"] = min(durations)
|
||||
|
|
@ -77,8 +87,7 @@ class Command(BaseCommand):
|
|||
clip["duration"] = cd
|
||||
clip['tags'] = i.data.get('tags', [])
|
||||
clip['editingtags'] = i.data.get('editingtags', [])
|
||||
name = os.path.basename(clip['original'])
|
||||
|
||||
name = os.path.basename(original_target)
|
||||
seqid = re.sub("Hotel Aporia_(\d+)", "S\\1_", name)
|
||||
seqid = re.sub("Night March_(\d+)", "S\\1_", seqid)
|
||||
seqid = re.sub("_(\d+)H_(\d+)", "_S\\1\\2_", seqid)
|
||||
|
|
@ -129,3 +138,18 @@ class Command(BaseCommand):
|
|||
}
|
||||
with open(os.path.join(prefix, 'voice_over.json'), 'w') as fd:
|
||||
json.dump(voice_over, fd, indent=2, ensure_ascii=False)
|
||||
|
||||
if options['censored']:
|
||||
censored_mp4 = '/srv/t_for_time/censored.mp4'
|
||||
if not os.path.exists(censored_mp4):
|
||||
cmd = [
|
||||
"ffmpeg",
|
||||
"-nostats", "-loglevel", "error",
|
||||
"-f", "lavfi",
|
||||
"-i", "color=color=white:size=1920x1080:rate=24",
|
||||
"-t", "3600",
|
||||
"-c:v", "libx264",
|
||||
"-pix_fmt", "yuv420p",
|
||||
censored_mp4
|
||||
]
|
||||
subprocess.call(cmd)
|
||||
|
|
|
|||
15
render.py
15
render.py
|
|
@ -885,19 +885,24 @@ def render_infinity(options):
|
|||
prefix = options['prefix']
|
||||
duration = int(options['duration'])
|
||||
|
||||
defaults = {
|
||||
"offset": 100,
|
||||
"max-items": 30,
|
||||
"no_video": False,
|
||||
}
|
||||
state_f = os.path.join(prefix, "infinity.json")
|
||||
if os.path.exists(state_f):
|
||||
with open(state_f) as fd:
|
||||
state = json.load(fd)
|
||||
else:
|
||||
state = {
|
||||
"offset": 100,
|
||||
"max-items": 30,
|
||||
"no_video": False,
|
||||
}
|
||||
state = {}
|
||||
for key in ("prefix", "duration", "debug", "single_file", "keep_audio", "stereo_downmix"):
|
||||
state[key] = options[key]
|
||||
|
||||
for key in defaults:
|
||||
if key not in state:
|
||||
state[key] = defaults[key]
|
||||
|
||||
while True:
|
||||
render_prefix = state["prefix"] + "/render/"
|
||||
current = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue