new frame urls
This commit is contained in:
parent
60539576ed
commit
b78b73da8a
5 changed files with 13 additions and 9 deletions
|
@ -230,7 +230,7 @@ def run_command(cmd, timeout=10):
|
||||||
return p.returncode
|
return p.returncode
|
||||||
|
|
||||||
|
|
||||||
def frame(videoFile, frame, position, width=128, redo=False):
|
def frame(videoFile, frame, position, height=128, redo=False):
|
||||||
'''
|
'''
|
||||||
params:
|
params:
|
||||||
videoFile input
|
videoFile input
|
||||||
|
@ -243,7 +243,7 @@ def frame(videoFile, frame, position, width=128, redo=False):
|
||||||
frameFolder = os.path.dirname(frame)
|
frameFolder = os.path.dirname(frame)
|
||||||
if redo or not exists(frame):
|
if redo or not exists(frame):
|
||||||
ox.makedirs(frameFolder)
|
ox.makedirs(frameFolder)
|
||||||
cmd = ['oxframe', '-i', videoFile, '-o', frame, '-p', str(position), '-x', str(width)]
|
cmd = ['oxframe', '-i', videoFile, '-o', frame, '-p', str(position), '-y', str(height)]
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -676,16 +676,17 @@ class Item(models.Model):
|
||||||
Video related functions
|
Video related functions
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def frame(self, position, width=128):
|
def frame(self, position, height=128):
|
||||||
stream = self.streams.filter(profile=settings.VIDEO_PROFILE)
|
stream = self.streams.filter(profile=settings.VIDEO_PROFILE)
|
||||||
if stream.count()>0:
|
if stream.count()>0:
|
||||||
stream = stream[0]
|
stream = stream[0]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
height = min(height, stream.height())
|
||||||
path = os.path.join(settings.MEDIA_ROOT, self.path(),
|
path = os.path.join(settings.MEDIA_ROOT, self.path(),
|
||||||
'frames', "%d"%width, "%s.jpg"%position)
|
'frames', "%dp"%height, "%s.jpg"%position)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
extract.frame(stream.video.path, path, position, width)
|
extract.frame(stream.video.path, path, position, height)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
path = os.path.join(settings.STATIC_ROOT, 'png/frame.broken.png')
|
path = os.path.join(settings.STATIC_ROOT, 'png/frame.broken.png')
|
||||||
return path
|
return path
|
||||||
|
@ -1091,6 +1092,9 @@ class Stream(models.Model):
|
||||||
def path(self):
|
def path(self):
|
||||||
return self.item.path(self.profile)
|
return self.item.path(self.profile)
|
||||||
|
|
||||||
|
def height(self):
|
||||||
|
return int(self.profile.split('p')[0])
|
||||||
|
|
||||||
def extract_derivatives(self):
|
def extract_derivatives(self):
|
||||||
for profile in settings.VIDEO_DERIVATIVES:
|
for profile in settings.VIDEO_DERIVATIVES:
|
||||||
derivative, created = Stream.objects.get_or_create(profile=profile, item=self.item)
|
derivative, created = Stream.objects.get_or_create(profile=profile, item=self.item)
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.conf.urls.defaults import *
|
||||||
|
|
||||||
urlpatterns = patterns("item.views",
|
urlpatterns = patterns("item.views",
|
||||||
#frames
|
#frames
|
||||||
(r'^(?P<id>[A-Z0-9].+)/frame(?P<size>\d+)p(?P<position>[\d\.]+)\.jpg$', 'frame'),
|
(r'^(?P<id>[A-Z0-9].+)/(?P<size>\d+)p(?P<position>[\d\.]+)\.jpg$', 'frame'),
|
||||||
|
|
||||||
#timelines
|
#timelines
|
||||||
(r'^(?P<id>[A-Z0-9].+)/timeline(?P<size>\d+)p(?P<position>\d+)\.png$', 'timeline'),
|
(r'^(?P<id>[A-Z0-9].+)/timeline(?P<size>\d+)p(?P<position>\d+)\.png$', 'timeline'),
|
||||||
|
|
|
@ -26,7 +26,7 @@ pandora.ui.item = function() {
|
||||||
var ratio = result.data.stream.aspectRatio,
|
var ratio = result.data.stream.aspectRatio,
|
||||||
width = ratio > 1 ? size : Math.round(size * ratio),
|
width = ratio > 1 ? size : Math.round(size * ratio),
|
||||||
height = ratio > 1 ? Math.round(size / ratio) : size,
|
height = ratio > 1 ? Math.round(size / ratio) : size,
|
||||||
url = '/' + pandora.user.ui.item + '/frame' + size + 'p' + data['in'] + '.jpg';
|
url = '/' + pandora.user.ui.item + '/' + size + 'p' + data['in'] + '.jpg';
|
||||||
return {
|
return {
|
||||||
height: height,
|
height: height,
|
||||||
id: data['id'],
|
id: data['id'],
|
||||||
|
@ -278,7 +278,7 @@ pandora.ui.item = function() {
|
||||||
duration: video.duration,
|
duration: video.duration,
|
||||||
find: '',
|
find: '',
|
||||||
getFrameURL: function(position) {
|
getFrameURL: function(position) {
|
||||||
return '/' + pandora.user.ui.item + '/frame' + video.height.toString() + 'p' + position.toString() + '.jpg';
|
return '/' + pandora.user.ui.item + '/' + video.height.toString() + 'p' + position.toString() + '.jpg';
|
||||||
},
|
},
|
||||||
getLargeTimelineImageURL: function(i) {
|
getLargeTimelineImageURL: function(i) {
|
||||||
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
||||||
|
|
|
@ -118,7 +118,7 @@ pandora.ui.list = function(view) { // fixme: remove view argument
|
||||||
var ratio = data.aspectRatio,
|
var ratio = data.aspectRatio,
|
||||||
width = ratio > 1 ? size : Math.round(size * ratio),
|
width = ratio > 1 ? size : Math.round(size * ratio),
|
||||||
height = ratio > 1 ? Math.round(size / ratio) : size,
|
height = ratio > 1 ? Math.round(size / ratio) : size,
|
||||||
url = '/' + data.item + '/frame' + height + 'p' + data['in'] + '.jpg';
|
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
||||||
return {
|
return {
|
||||||
height: height,
|
height: height,
|
||||||
id: data['id'],
|
id: data['id'],
|
||||||
|
|
Loading…
Reference in a new issue