strip timeline

This commit is contained in:
j 2010-09-08 15:38:44 +02:00
commit 8947e51243
5 changed files with 85 additions and 12 deletions

View file

@ -415,7 +415,7 @@ class Movie(models.Model):
@property
def timeline_prefix(self):
return os.path.join('stream', movieid_path(self.movieId), 'timeline')
return os.path.join(settings.MEDIA_ROOT, 'stream', movieid_path(self.movieId), 'timeline')
def updateStreams(self):
files = {}
@ -440,9 +440,10 @@ class Movie(models.Model):
subprocess.Popen(cmd)
stream.save()
extract.timeline(stream.video.path, os.path.join(settings.MEDIA_ROOT, self.timeline_prefix))
extract.timeline(stream.video.path, self.timeline_prefix)
stream.extract_derivatives()
self.metadata['cuts'] = extract.cuts(self.timeline_prefix)
self.metadata['average_color'] = extract.average_color(self.timeline_prefix)
#something with poster
self.available = True
self.save()

View file

@ -10,7 +10,7 @@ urlpatterns = patterns("backend.views",
(r'^(?P<id>.*)/(?P<profile>.*.mp4)$', 'video'),
(r'^(?P<id>.*)/poster\.(?P<size>\d+)\.jpg$', 'poster'),
(r'^(?P<id>.*)/poster\.jpg$', 'poster'),
(r'^(?P<id>.*)/timelines/timeline\.(?P<size>\d+)\.(?P<position>\d+)\.png$', 'timeline'),
(r'^(?P<id>.*)/timelines/(?P<timeline>.+)\.(?P<size>\d+)\.(?P<position>\d+)\.png$', 'timeline'),
(r'^(?P<id>.*)/data/(?P<data>.+)\.json$', 'data'),
(r'^api/$', 'api'),
)

View file

@ -540,6 +540,8 @@ def data(request, id, data):
response = {}
if data == 'video':
response = movie.get_stream()
if data == 'cuts':
response = movie.metadata.get('cuts', {})
return render_to_json_response(response)
#media delivery
@ -570,9 +572,12 @@ def poster(request, id, size=128):
poster_path = os.path.join(settings.STATIC_ROOT, 'png/posterDark.48.png')
return HttpFileResponse(poster_path, content_type='image/jpeg')
def timeline(request, id, size, position):
def timeline(request, id, timeline, size, position):
movie = get_object_or_404(models.Movie, movieId=id)
timeline = os.path.join(settings.MEDIA_ROOT, '%s.%s.%04d.png' %(movie.timeline_prefix, size, int(position)))
if timeline == 'strip':
timeline = '%s.%s.%04d.png' %(movie.timeline_prefix[:-8] + 'strip', size, int(position))
else:
timeline = '%s.%s.%04d.png' %(movie.timeline_prefix, size, int(position))
return HttpFileResponse(timeline, content_type='image/png')
def video(request, id, profile):
@ -580,7 +585,5 @@ def video(request, id, profile):
stream = get_object_or_404(movie.streams, profile=profile)
path = stream.video.path
content_type = path.endswith('.mp4') and 'video/mp4' or 'video/webm'
#url = 'http://127.0.0.1/pandora_media' + path[len(settings.MEDIA_ROOT):]
#return redirect(url)
return HttpFileResponse(path, content_type=content_type)