render fixes, encode vides in render command
This commit is contained in:
parent
e84ea31147
commit
5075394318
4 changed files with 35 additions and 7 deletions
|
|
@ -19,10 +19,12 @@ class Command(BaseCommand):
|
|||
clips = []
|
||||
for i in item.models.Item.objects.filter(data__type__contains="Original"):
|
||||
qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id)
|
||||
if qs.count() == 2:
|
||||
if qs.count() >= 2:
|
||||
clip = {}
|
||||
durations = []
|
||||
for e in item.models.Item.objects.filter(data__title=i.data['title']):
|
||||
if 'type' not in e.data:
|
||||
print("ignoring invalid video", e)
|
||||
source = e.files.all()[0].data.path
|
||||
ext = os.path.splitext(source)[1]
|
||||
type_ = e.data['type'][0].lower()
|
||||
|
|
@ -35,7 +37,10 @@ class Command(BaseCommand):
|
|||
durations.append(e.files.all()[0].duration)
|
||||
clip["duration"] = min(durations)
|
||||
clip['tags'] = i.data.get('tags', [])
|
||||
clips.append(clip)
|
||||
if "original" in clip and "foreground" in clip and "background" in clip:
|
||||
clips.append(clip)
|
||||
else:
|
||||
print("ignoring incomplete video", i)
|
||||
|
||||
with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
|
||||
json.dump(clips, fd, indent=2, ensure_ascii=False)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
|
@ -14,6 +15,7 @@ class Command(BaseCommand):
|
|||
parser.add_argument('--prefix', action='store', dest='prefix', default="/srv/t_for_time", help='prefix to build clips in')
|
||||
parser.add_argument('--duration', action='store', dest='duration', default="150", help='target duration in seconds')
|
||||
parser.add_argument('--offset', action='store', dest='offset', default="1024", help='inital offset in pi')
|
||||
parser.add_argument('--no-video', action='store_true', dest='no_video', default=False, help='don\'t render video')
|
||||
|
||||
def handle(self, **options):
|
||||
prefix = options['prefix']
|
||||
|
|
@ -23,7 +25,15 @@ class Command(BaseCommand):
|
|||
with open(os.path.join(prefix, "clips.json")) as fd:
|
||||
clips = json.load(fd)
|
||||
scene = compose(clips, target=target, base=base)
|
||||
render(prefix, scene, 'scene-%s-' % base)
|
||||
timelines = render(prefix, scene, 'scene-%s-' % base)
|
||||
with open(os.path.join(prefix, 'scene-%s.json' % base), 'w') as fd:
|
||||
json.dump(scene, fd, indent=2, ensure_ascii=False)
|
||||
if not options['no_video']:
|
||||
for timeline in timelines:
|
||||
cmd = [
|
||||
'xvfb-run', '-a',
|
||||
'melt', timeline,
|
||||
'-consumer', 'avformat:%s' % timeline.replace('.kdenlive', '.mp4')
|
||||
]
|
||||
subprocess.call(cmd)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue