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'),
stderr=subprocess.STDOUT)
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':
cmd = ['qt-faststart', "%s.mp4" % target, target]
#print cmd

View file

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

View file

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

View file

@ -310,6 +310,12 @@ def direct_upload(request):
else:
file, created = models.File.objects.get_or_create(oshash=oshash)
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.save()
upload_url = request.build_absolute_uri('/api/upload/direct/?id=%s' % file.oshash)