forked from 0x2620/pandora
save derivatives
This commit is contained in:
parent
286e56561a
commit
a12e207a28
3 changed files with 21 additions and 14 deletions
|
@ -173,17 +173,18 @@ def stream(video, target, profile, info):
|
|||
cmd += ['-f','webm', target]
|
||||
|
||||
print cmd
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p.wait()
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
|
||||
p.communicate()
|
||||
if format == 'mp4':
|
||||
cmd = ['qt-faststart', "%s.mp4"%target, target]
|
||||
print cmd
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p.wait()
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
|
||||
p.communicate()
|
||||
os.unlink("%s.mp4"%target)
|
||||
return True
|
||||
|
||||
def run_command(cmd, timeout=10):
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = subprocess.Popen(cmd, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
|
||||
while timeout > 0:
|
||||
time.sleep(0.2)
|
||||
timeout -= 0.2
|
||||
|
|
|
@ -443,7 +443,7 @@ class Movie(models.Model):
|
|||
'''
|
||||
def frame(self, position, width=128):
|
||||
stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')[0]
|
||||
path = os.path.join(settings.MEDIA_ROOT, movieid_path(self.movieId), 'frame', "%d"%width, "%s.jpg"%position)
|
||||
path = os.path.join(settings.MEDIA_ROOT, movieid_path(self.movieId), 'frames', "%d"%width, "%s.jpg"%position)
|
||||
if not os.path.exists(path):
|
||||
extract.frame(stream.video.path, path, position, width)
|
||||
return path
|
||||
|
@ -832,7 +832,7 @@ class Collection(models.Model):
|
|||
return self.users.filter(id=user.id).count() > 0
|
||||
|
||||
def movieid_path(h):
|
||||
return os.path.join('movie', h[:2], h[2:4], h[4:6], h[6:])
|
||||
return os.path.join('movies', h[:2], h[2:4], h[4:6], h[6:])
|
||||
|
||||
def stream_path(stream):
|
||||
return os.path.join(movieid_path(stream.movie.movieId), stream.profile)
|
||||
|
@ -854,25 +854,31 @@ class Stream(models.Model):
|
|||
def extract_derivatives(self):
|
||||
if settings.VIDEO_H264:
|
||||
profile = self.profile.replace('.webm', '.mp4')
|
||||
if Stream.objects.filter(profile=profile, source=self).count() == 0:
|
||||
derivative = Stream(movie=self.movie, source=self, profile=profile)
|
||||
derivative, created = Stream.objects.get_or_create(profile=profile, movie=self.movie)
|
||||
if created:
|
||||
derivative.source = self
|
||||
derivative.video.name = self.video.name.replace(self.profile, profile)
|
||||
derivative.encode()
|
||||
derivative.save()
|
||||
|
||||
for p in settings.VIDEO_DERIVATIVES:
|
||||
profile = p + '.webm'
|
||||
target = self.video.path.replace(self.profile, profile)
|
||||
if Stream.objects.filter(profile=profile, source=self).count() == 0:
|
||||
derivative = Stream(movie=movie.file, source=self, profile=profile)
|
||||
derivative, created = Stream.objects.get_or_create(profile=profile, movie=self.movie)
|
||||
if created:
|
||||
derivative.source = self
|
||||
derivative.video.name = self.video.name.replace(self.profile, profile)
|
||||
derivative.encode()
|
||||
derivative.save()
|
||||
|
||||
if settings.VIDEO_H264:
|
||||
profile = p + '.mp4'
|
||||
if Stream.objects.filter(profile=profile, source=self).count() == 0:
|
||||
derivative = Stream(movie=self.movie, source=self, profile=profile)
|
||||
derivative, created = Stream.objects.get_or_create(profile=profile, movie=self.movie)
|
||||
if created:
|
||||
derivative.source = self
|
||||
derivative.video.name = self.video.name.replace(self.profile, profile)
|
||||
derivative.encode()
|
||||
derivative.save()
|
||||
return True
|
||||
|
||||
def encode(self):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
if(typeof(app.afterLaunch) == "undefined")
|
||||
app.afterLaunch = [];
|
||||
|
||||
//app.afterLaunch[0]();
|
||||
app.afterLaunch.push(function() {
|
||||
if (typeof(OxFF) == 'undefined')
|
||||
return;
|
||||
|
@ -32,7 +33,6 @@ app.afterLaunch.push(function() {
|
|||
.append("For this part of the page to work, you have to allow OxFF to send data to this site")
|
||||
.open();
|
||||
} else {
|
||||
Ox.print('we got it, lets party');
|
||||
_this.api.login(app.user.username);
|
||||
_this.api.volumes(function(result) {
|
||||
var data = JSON.parse(result);
|
||||
|
|
Loading…
Reference in a new issue