remove failed transcodes, fix reuploading the same file via direct upload

This commit is contained in:
j 2013-09-26 14:55:37 +00:00
parent 2c01974625
commit 3064785b3e
4 changed files with 16 additions and 3 deletions

View file

@ -247,6 +247,11 @@ def stream(video, target, profile, info):
stdout=open('/dev/null', 'w'), stdout=open('/dev/null', 'w'),
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
p.communicate() p.communicate()
if p.returncode != 0:
t = "%s.mp4" % target if format == 'mp4' else target
if os.path.exists(t):
os.unlink(t)
return False
if format == 'mp4': if format == 'mp4':
cmd = ['qt-faststart', "%s.mp4" % target, target] cmd = ['qt-faststart', "%s.mp4" % target, target]
#print cmd #print cmd

View file

@ -570,6 +570,7 @@ class Stream(models.Model):
if extract.stream(media, target, self.name(), info): if extract.stream(media, target, self.name(), info):
self.available = True self.available = True
else: else:
self.media = None
self.available = False self.available = False
self.save() self.save()

View file

@ -87,9 +87,9 @@ def process_stream(fileId):
''' '''
file = models.File.objects.get(id=fileId) file = models.File.objects.get(id=fileId)
streams = file.streams.filter(source=None) streams = file.streams.filter(source=None)
models.File.objects.filter(id=fileId).update(encoding=True, queued=False)
if streams.count() > 0: if streams.count() > 0:
stream = streams[0] stream = streams[0]
models.File.objects.filter(id=fileId).update(encoding=True, queued=False)
stream.make_timeline() stream.make_timeline()
stream.extract_derivatives() stream.extract_derivatives()
file = models.File.objects.get(id=fileId) file = models.File.objects.get(id=fileId)
@ -100,6 +100,7 @@ def process_stream(fileId):
file.item.update_timeline() file.item.update_timeline()
if file.item.rendered: if file.item.rendered:
file.item.save() file.item.save()
models.File.objects.filter(id=fileId).update(encoding=False)
return True return True
@task(queue="encoding") @task(queue="encoding")
@ -107,6 +108,7 @@ def extract_stream(fileId):
''' '''
extract stream from direct upload extract stream from direct upload
''' '''
models.File.objects.filter(id=fileId).update(encoding=True, queued=False)
file = models.File.objects.get(id=fileId) file = models.File.objects.get(id=fileId)
if file.data: if file.data:
config = settings.CONFIG['video'] config = settings.CONFIG['video']
@ -114,7 +116,6 @@ def extract_stream(fileId):
file=file, resolution=max(config['resolutions']), file=file, resolution=max(config['resolutions']),
format=config['formats'][0]) format=config['formats'][0])
if created: if created:
models.File.objects.filter(id=fileId).update(encoding=True, queued=False)
stream.media.name = stream.path(stream.name()) stream.media.name = stream.path(stream.name())
stream.encode() stream.encode()
if stream.available: if stream.available:

View file

@ -310,6 +310,12 @@ def direct_upload(request):
else: else:
file, created = models.File.objects.get_or_create(oshash=oshash) file, created = models.File.objects.get_or_create(oshash=oshash)
if file.editable(request.user): if file.editable(request.user):
#remove previous uploads
if not created:
file.streams.all().delete()
file.delete_frames()
if file.item.rendered and file.selected:
Item.objects.filter(id=file.item.id).update(rendered=False)
file.uploading = True file.uploading = True
file.save() file.save()
upload_url = request.build_absolute_uri('/api/upload/direct/?id=%s' % file.oshash) upload_url = request.build_absolute_uri('/api/upload/direct/?id=%s' % file.oshash)