more vi:si:et:sw=4:sts=4:ts=4

This commit is contained in:
j 2008-06-19 12:14:38 +02:00
parent ecfb2ff28c
commit 2dd8f949b6
10 changed files with 258 additions and 203 deletions

View file

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from oxdb_utils import oxdb_makedir
from os.path import *
import cache
import extract
class BackupMovieFile:
def __init__(self, parent):
self.parent = parent

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2
# vi:si:et:sw=4:sts=4:ts=4
import os
from os.path import abspath, exists, join, dirname, basename
import shutil
@ -85,3 +83,4 @@ def loadPosterStill(afile, position):
if exists(still):
return loadFile(still)
return ''

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2
# vi:si:et:sw=4:sts=4:ts=4
from turbogears import controllers, expose, flash, redirect
from model import *
from json import *
@ -43,20 +41,18 @@ class Root(controllers.RootController):
position = position.replace('.png', '').replace('.jpg', '')
position = position.replace('.flv', '').replace('.ogv', '')
position = position.replace('-', ':').replace('.',':')
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*15)
if action == 'clip':
cherrypy.response.headerMap['Content-Type'] = "video/x-flv"
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*15)
return f.flvClip(position)
if action == 'ogv':
cherrypy.response.headerMap['Content-Type'] = "video/ogg"
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*15)
return f.oggClip(position)
elif action == 'frame':
cherrypy.response.headerMap['Content-Type'] = "image/jpeg"
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*15)
return f.frame(position)
elif action == 'posterStill':
cherrypy.response.headerMap['Content-Type'] = "image/png"
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*15)
return f.posterStill(position)
return dict()

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2
# vi:si:et:sw=4:sts=4:ts=4
from model import *
import cache
@ -46,3 +44,4 @@ def extractSubtitles():
os.system(cmd)
#only one subtitle at a time
return

View file

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# -*- Mode: Python; -*-
# vi:si:et:sw=2:sts=2:ts=2
import re
import os
from os.path import abspath, join, dirname

View file

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# -*- Mode: Python; -*-
# vi:si:et:sw=2:sts=2:ts=2
import os
import sys

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# -*- Mode: Python; -*-
# vi:si:et:sw=2:sts=2:ts=2
import gzip
import StringIO
@ -353,10 +352,13 @@ class ArchiveFile(SQLObject):
self.frameAspect = "%0.6f" % aspect
return aspect
def _get_sceneWidth(self):
return 128
def _get_sceneHeight(self):
default = 80
if not self.subtitle:
h = int(128 / self.frameAspect)
h = int(self.sceneWidth / self.frameAspect)
h = h + h % 2
return h
return default
@ -450,9 +452,8 @@ class ArchiveFile(SQLObject):
movie_file = self.mini_movie_file
position = inpoint.replace(':', '.')
flash_movie = join(self.frameFolder, '%s.%s' % (position, 'flv'))
width = 128
height = int(width / self.frameAspect)
height = height - height % 2
width = self.sceneWidth
height = self.sceneHeight
inpoint = inpoint.replace('.', ':')
if outpoint == -1:
s = self._findSubtitleByInPoint(inpoint)
@ -471,9 +472,8 @@ class ArchiveFile(SQLObject):
movie_file = self.mini_movie_file
position = inpoint.replace(':', '.')
clip_movie = join(self.frameFolder, '%s.%s' % (position, 'ogv'))
width = 128
height = int(width / self.frameAspect)
height = height - height % 2
width = self.sceneWidth
height = self.sceneHeight
inpoint = inpoint.replace('.', ':')
if outpoint == -1:
s = self._findSubtitleByInPoint(inpoint)
@ -534,7 +534,7 @@ class ArchiveFile(SQLObject):
options = ''
options += " -ovc lavc -lavcopts vcodec=mjpeg"
options += " -af volnorm=1 -oac mp3lame -lameopts br=64:mode=3 -af resample=44100"
options += " -vf scale -zoom -xy 128"
options += " -vf scale -zoom -xy %s" % self.sceneWidth
options += ' "%s"' % movie_file.replace('"', '\\"')
options += ' -o "%s"' % mini_movie_file
cmd = "mencoder %s >/dev/null 2>&1" % options
@ -543,6 +543,74 @@ class ArchiveFile(SQLObject):
if r == 0:
self.extracted = True
def extractOggMovie(self, force = False):
if self.broken:
return
if not self.height:
#only if midentify works we should try to extract the clip
return
if self.path.split('.')[-1] in ('mp3', 'wav', 'srt', 'sub', 'idx', 'rar','jpg', 'png'):
#ignore files known to not be
return
oggFile = self.mini_movie_file.replace('.avi', '.ogg')
movieFile = self.absolutePath
if not movieFile or not exists(movieFile):
return
if exists(oggFile) and not force:
debug("clip exists, skipping extraction %s" % oggFile)
return
self.extractedOgg = False
oxdb_makedir(dirname(oggFile))
options = ''
options += " --no-skeleton -K 16 -V 180 -a -1 -H 44100 -S 1 --speedlevel 0 -c 2 "
options += " -x %s -y %s" % (self.sceneWidth, self.sceneHeight)
options += ' "%s"' % movieFile.replace('"', '\\"')
options += ' -o "%s"' % oggFile
cmd = "ffmpeg2theora %s >/dev/null 2>&1" % options
r = os.system(cmd.encode('utf-8'))
if r == 0:
self.extractedOgg = True
def extractH264Movie(self, force = False):
if self.broken:
return
if not self.height:
#only if midentify works we should try to extract the clip
return
if self.path.split('.')[-1] in ('mp3', 'wav', 'srt', 'sub', 'idx', 'rar','jpg', 'png'):
#ignore files known to not be
return
h264File = self.mini_movie_file.replace('.avi', '.mp4')
h264FileTmp = h264File + ".tmp.mp4"
movieFile = self.absolutePath
if not movieFile or not exists(movieFile):
return
if exists(h264File) and not force:
debug("clip exists, skipping extraction %s" % h264File)
return
self.extractedH264 = False
height = self.sceneHeight
oxdb_makedir(dirname(h264File))
options = ''
options += " -vcodec libx264 -b 112k -bf 3 -subq 6 -cmp 256 -refs 5 -qmin 10 "
options += " -qmax 51 -qdiff 4 -coder 1 -loop 1 -me hex -me_range 16 -trellis 1 "
options += " -flags +mv4 -flags2 +bpyramid+wpred+mixed_refs+brdo+8x8dct "
options += " -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -g 250 "
options += " -keyint_min 16 -sc_threshold 40 -i_qfactor 0.71"
options += " -s %sx%s" % (self.sceneWidth, height)
cmd = '''ffmpeg -y -i "%s" -an -pass 1 -threads 2 %s "%s" >/dev/null 2>&1''' % (movieFile, options, h264FileTmp)
print cmd
r = os.system(cmd.encode('utf-8'))
cmd = '''ffmpeg -y -i "%s" -acodec libfaac -ac 2 -ar 44100 -ab 48k -pass 2 -threads 2 %s "%s" >/dev/null 2>&1''' % (movieFile, options, h264FileTmp)
r = os.system(cmd.encode('utf-8'))
cmd = '''qt-faststart "%s" "%s" >/dev/null 2>&1 && rm "%s"''' % (h264FileTmp, h264File, h264FileTmp)
r = os.system(cmd.encode('utf-8'))
if r == 0:
self.extractedH264 = True
def removeTimeline(self):
if exists(self.timelineFile):
os.unlink(self.timelineFile)

View file

@ -1,11 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- Mode: Python; -*-
# vi:si:et:sw=2:sts=2:ts=2
# OXDb Import client, crawls the filesystem and gathers information about
# movies
#
import md5
import os
import sys

View file

@ -1,11 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- Mode: Python; -*-
# vi:si:et:sw=2:sts=2:ts=2
# OXDb Import client, crawls the filesystem and gathers information about
# movies
#
import md5
import os
import sys

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2
import Image
import math
from StringIO import StringIO