make derivatives more generic
This commit is contained in:
parent
7dd47d1544
commit
b563afcfc8
7 changed files with 34 additions and 41 deletions
|
@ -196,10 +196,13 @@ def stream(video, target, profile, info):
|
|||
+ audio_settings \
|
||||
+ video_settings
|
||||
|
||||
if format == 'mp4':
|
||||
cmd += ["%s.mp4"%target]
|
||||
else:
|
||||
if format == 'webm':
|
||||
cmd += ['-f', 'webm', target]
|
||||
if format == 'mp4':
|
||||
#mp4 needs postprocessing(qt-faststart), write to temp file
|
||||
cmd += ["%s.mp4"%target]
|
||||
else :
|
||||
cmd += [target]
|
||||
|
||||
print cmd
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
|
||||
|
|
|
@ -139,7 +139,7 @@ class File(models.Model):
|
|||
|
||||
#upload and data handling
|
||||
video = models.FileField(null=True, blank=True,
|
||||
upload_to=lambda f, x: f.path('%s.webm'%settings.VIDEO_PROFILE))
|
||||
upload_to=lambda f, x: f.path(settings.VIDEO_PROFILE))
|
||||
data = models.FileField(null=True, blank=True,
|
||||
upload_to=lambda f, x: f.path('data.bin'))
|
||||
|
||||
|
@ -221,7 +221,7 @@ class File(models.Model):
|
|||
def save_chunk(self, chunk, chunk_id=-1):
|
||||
if not self.available:
|
||||
if not self.video:
|
||||
self.video.save('%s.webm'%settings.VIDEO_PROFILE, chunk)
|
||||
self.video.save(settings.VIDEO_PROFILE, chunk)
|
||||
else:
|
||||
f = open(self.video.path, 'a')
|
||||
#FIXME: should check that chunk_id/offset is right
|
||||
|
|
|
@ -161,8 +161,6 @@ class VideoChunkForm(forms.Form):
|
|||
@login_required_json
|
||||
def firefogg_upload(request):
|
||||
profile = request.GET['profile']
|
||||
if profile.endswith('.webm'):
|
||||
profile = os.path.splitext(profile)[0]
|
||||
oshash = request.GET['oshash']
|
||||
#handle video upload
|
||||
if request.method == 'POST':
|
||||
|
|
|
@ -333,6 +333,7 @@ class Item(models.Model):
|
|||
else:
|
||||
stream['baseUrl'] = os.path.dirname(s.video.url)
|
||||
stream['profiles'] = list(set(map(lambda s: int(os.path.splitext(s['profile'])[0][:-1]), self.streams.all().values('profile'))))
|
||||
stream['formats'] = list(set(map(lambda s: os.path.splitext(s['profile'])[1][1:], self.streams.all().values('profile'))))
|
||||
return stream
|
||||
|
||||
def get_layers(self):
|
||||
|
@ -588,7 +589,7 @@ class Item(models.Model):
|
|||
'''
|
||||
|
||||
def frame(self, position, width=128):
|
||||
stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')
|
||||
stream = self.streams.filter(profile=settings.VIDEO_PROFILE)
|
||||
if stream.count()>0:
|
||||
stream = stream[0]
|
||||
else:
|
||||
|
@ -627,7 +628,7 @@ class Item(models.Model):
|
|||
#FIXME: how to detect if something changed?
|
||||
if files:
|
||||
stream, created = Stream.objects.get_or_create(item=self,
|
||||
profile='%s.webm' % settings.VIDEO_PROFILE)
|
||||
profile=settings.VIDEO_PROFILE)
|
||||
stream.video.name = stream.path()
|
||||
cmd = []
|
||||
if os.path.exists(stream.video.path):
|
||||
|
@ -766,7 +767,7 @@ class Item(models.Model):
|
|||
|
||||
def get_poster_frame_path(self):
|
||||
if self.poster_frame >= 0:
|
||||
size = int(settings.VIDEO_PROFILE[:-1])
|
||||
size = int(settings.VIDEO_PROFILE.split('.')[0][:-1])
|
||||
return self.frame(self.poster_frame, size)
|
||||
|
||||
frames = []
|
||||
|
@ -919,27 +920,7 @@ class Stream(models.Model):
|
|||
return self.item.path(self.profile)
|
||||
|
||||
def extract_derivatives(self):
|
||||
if settings.VIDEO_H264:
|
||||
profile = self.profile.replace('.webm', '.mp4')
|
||||
derivative, created = Stream.objects.get_or_create(profile=profile, item=self.item)
|
||||
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)
|
||||
derivative, created = Stream.objects.get_or_create(profile=profile, item=self.item)
|
||||
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'
|
||||
for profile in settings.VIDEO_DERIVATIVES:
|
||||
derivative, created = Stream.objects.get_or_create(profile=profile, item=self.item)
|
||||
if created:
|
||||
derivative.source = self
|
||||
|
|
|
@ -144,15 +144,23 @@ SITE_CONFIG = join(PROJECT_ROOT, '0xdb.json')
|
|||
DEFAULT_SORT = [{"key": "director", "operator": ""}]
|
||||
DEFAULT_THEME = "classic"
|
||||
|
||||
VIDEO_PROFILE = '96p'
|
||||
VIDEO_PROFILE = '96p.webm'
|
||||
VIDEO_DERIVATIVES = []
|
||||
VIDEO_H264 = False
|
||||
|
||||
#Pad.ma
|
||||
#VIDEO_PROFILE = '480p'
|
||||
#VIDEO_DERIVATIVES = ['96p', '270p', '360p']
|
||||
#VIDEO_H264 = False
|
||||
|
||||
'''
|
||||
VIDEO_PROFILE = '480p.webm'
|
||||
VIDEO_DERIVATIVES = [
|
||||
'96p.webm',
|
||||
'240p.webm',
|
||||
'360p.webm'
|
||||
'96p.mp4',
|
||||
'240p.mp4',
|
||||
'360p.mp4',
|
||||
'480p.mp4',
|
||||
]
|
||||
'''
|
||||
|
||||
TRANSMISSON_HOST = 'localhost'
|
||||
TRANSMISSON_PORT = 9091
|
||||
|
|
|
@ -10,6 +10,7 @@ jQuery.support.video = function() {
|
|||
video.webm = false;
|
||||
video.h264 = !!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
|
||||
video.ogg = !!(v.canPlayType && v.canPlayType('video/ogg; codecs="theora, vorbis"').replace(/no/, ''));
|
||||
video.ogv = video.ogg;
|
||||
} else {
|
||||
video.support = false;
|
||||
}
|
||||
|
|
|
@ -1734,10 +1734,11 @@
|
|||
});
|
||||
} else if (app.user.ui.itemView == 'player') {
|
||||
var video = result.data.item.stream,
|
||||
subtitles = result.data.item.layers.subtitles;
|
||||
subtitles = result.data.item.layers.subtitles,
|
||||
format = Ox.supportedVideoFormat(video.formats);
|
||||
video.height = video.profiles[0]
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + ($.support.video.webm ? 'webm' : 'mp4');
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
|
||||
app.$ui.contentPanel.replace(1, app.$ui.player = new Ox.VideoPanelPlayer({
|
||||
annotationsSize: app.user.ui.annotationsSize,
|
||||
duration: video.duration,
|
||||
|
@ -1775,10 +1776,11 @@
|
|||
'in': 5,
|
||||
'out': 10,
|
||||
'value': 'This subtitle is just a test...'
|
||||
}];
|
||||
video.height = video.profiles[0]
|
||||
}],
|
||||
format = Ox.supportedVideoFormat(video.formats);
|
||||
video.height = video.profiles[0];
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + ($.support.video.webm ? 'webm' : 'mp4');
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
|
||||
app.$ui.contentPanel.replace(1, app.$ui.editor = new Ox.VideoEditor({
|
||||
annotationsSize: app.user.ui.annotationsSize,
|
||||
cuts: cuts,
|
||||
|
|
Loading…
Reference in a new issue