From 33725ff9d496bdf5a46a5548764f9dfef4f4bc83 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 15 Nov 2010 20:15:52 +0100 Subject: [PATCH] add encodingProfile api call, minor fixes --- README | 5 +++++ pandora/api/views.py | 2 +- pandora/archive/extract.py | 1 + pandora/archive/views.py | 11 ++++++++--- pandora/item/models.py | 1 + pandora/item/tasks.py | 2 +- pandora/settings.py | 6 +++--- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README b/README index 9818a5c0..a82e8937 100644 --- a/README +++ b/README @@ -42,3 +42,8 @@ add pandora repository: sudo add-apt-repository ppa:gstreamer-developers/ppa sudo apt-get update sudo apt-get install oxtools mkvtoolnix + +H264: + install ffmpeg with x264 enabled, install qt-faststart from (ffmpeg/tools) + set VIDEO_H264 = True in local_settings.py + diff --git a/pandora/api/views.py b/pandora/api/views.py index e4f1d53e..68c440ff 100644 --- a/pandora/api/views.py +++ b/pandora/api/views.py @@ -34,7 +34,7 @@ import tasks from user.models import getUserJSON from user.views import api_login, api_logout, api_register, api_contact, api_recover, api_preferences, api_findUser -from archive.views import api_update, api_upload, api_editFile +from archive.views import api_update, api_upload, api_editFile, api_encodingProfile from archive.models import File from archive import extract diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 43703b86..9e55b7c3 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -207,6 +207,7 @@ def stream(video, target, profile, info): return True def run_command(cmd, timeout=10): + #print cmd p = subprocess.Popen(cmd, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT) while timeout > 0: time.sleep(0.2) diff --git a/pandora/archive/views.py b/pandora/archive/views.py index bb7f9198..c0777318 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -30,7 +30,7 @@ import ox import models from item.utils import oxid, parse_path -import item.models +from item.models import getItem import item.tasks @login_required_json @@ -73,7 +73,6 @@ def api_update(request): volume, created = models.Volume.objects.get_or_create(user=user, name=data['volume']) all_files = [] for f in data['files']: - #print f path = f['path'] folder = path.split('/') name = folder.pop() @@ -114,7 +113,7 @@ def api_update(request): else: if not item: item_info = parse_path(folder) - item = item.models.getItem(item_info) + item = getItem(item_info) file_object = models.File() file_object.oshash = oshash file_object.name = name @@ -160,6 +159,11 @@ def api_update(request): return render_to_json_response(response) +@login_required_json +def api_encodingProfile(request): + response = json_response({'profile': settings.VIDEO_PROFILE}) + return render_to_json_response(response) + @login_required_json def api_upload(request): ''' @@ -223,6 +227,7 @@ def firefogg_upload(request): elif form.cleaned_data['done']: f.available = True f.save() + #FIXME: this fails badly if rabbitmq goes down item.tasks.updateStreams.delay(f.item.itemId) response['result'] = 1 response['done'] = 1 diff --git a/pandora/item/models.py b/pandora/item/models.py index 13568769..6634bb00 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -8,6 +8,7 @@ import math import random import re import subprocess +import unicodedata from glob import glob from django.db import models diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index 37be7100..da66c933 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -33,6 +33,6 @@ def updateStreams(itemId): create stream, extract timeline and create derivatives ''' item = models.Item.objects.get(itemId=itemId) - if item.files.filter(is_main=True, is_video=True, availble=False).count() == 0: + if item.files.filter(is_main=True, is_video=True, available=False).count() == 0: item.updateStreams() diff --git a/pandora/settings.py b/pandora/settings.py index 5a085618..7a423481 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -2,7 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 # Django settings for pandora project. import os -from os.path import join +from os.path import join, normpath SITENAME = 'Pan.do/ra' SITEID = 'pandora' @@ -67,8 +67,8 @@ APPEND_SLASH = False # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = join(PROJECT_ROOT, '..', 'data') -STATIC_ROOT = join(PROJECT_ROOT, '..', 'static') +MEDIA_ROOT = normpath(join(PROJECT_ROOT, '..', 'data')) +STATIC_ROOT = normpath(join(PROJECT_ROOT, '..', 'static')) TESTS_ROOT = join(PROJECT_ROOT, 'tests') # URL that handles the media served from MEDIA_ROOT. Make sure to use a