use jpg, png is to big to get in time
This commit is contained in:
parent
a6d52af083
commit
e49db8cdfa
2 changed files with 2 additions and 43 deletions
|
@ -163,47 +163,6 @@ def extract_frame(movie_file, timestamp, img_folder, width=128, offset = 0, redo
|
||||||
print "update the cache %s missing" % movie_file
|
print "update the cache %s missing" % movie_file
|
||||||
shutil.rmtree(framedir)
|
shutil.rmtree(framedir)
|
||||||
|
|
||||||
def extract_still(movie_file, timestamp, img_folder, width=128, offset = 0, redo = False):
|
|
||||||
import warnings
|
|
||||||
warnings.filterwarnings("ignore", "tempnam")
|
|
||||||
ext = movie_file.split('.')[-1]
|
|
||||||
if ext in ('sub', 'srt'):
|
|
||||||
print "this is not a movie file, will not try to extract frames"
|
|
||||||
return
|
|
||||||
framedir = os.tempnam()
|
|
||||||
|
|
||||||
os.mkdir(framedir)
|
|
||||||
os.chdir(framedir)
|
|
||||||
if offset:
|
|
||||||
timestamp_in_file = shift_time(-offset, timestamp)
|
|
||||||
else:
|
|
||||||
timestamp_in_file = timestamp
|
|
||||||
if os.path.exists(movie_file):
|
|
||||||
mplayer_options = ''
|
|
||||||
mplayer_options += " '%s'" % movie_file
|
|
||||||
mplayer_options += " -ss '%s' -frames 2" % (timestamp_in_file)
|
|
||||||
mplayer_options += " -vo png "
|
|
||||||
if width > 0:
|
|
||||||
mplayer_options += " -vf scale -zoom -xy %d " % width
|
|
||||||
mplayer_options += " -ao null"
|
|
||||||
mplayer = "mplayer %s >/dev/null 2>&1" % mplayer_options
|
|
||||||
frame = os.path.join(img_folder, "%s.%s" % (timestamp.replace(':', '.'), 'png'))
|
|
||||||
if redo or not os.path.exists(frame):
|
|
||||||
print mplayer.encode('utf-8')
|
|
||||||
os.system (mplayer.encode('utf-8'))
|
|
||||||
files = os.listdir(framedir)
|
|
||||||
if files:
|
|
||||||
print "creating frame ", frame
|
|
||||||
shutil.move(os.path.join(framedir,files[-1]), frame)
|
|
||||||
if len(files)>1:
|
|
||||||
for f in files[:-2]:
|
|
||||||
print "unlink", f
|
|
||||||
os.unlink(f)
|
|
||||||
time.sleep(0.1)
|
|
||||||
else:
|
|
||||||
print "update the cache %s missing" % movie_file
|
|
||||||
shutil.rmtree(framedir)
|
|
||||||
|
|
||||||
def extract_poster_still(movie_file, png_file, inpoint):
|
def extract_poster_still(movie_file, png_file, inpoint):
|
||||||
ext = movie_file.split('.')[-1]
|
ext = movie_file.split('.')[-1]
|
||||||
if ext in ('sub', 'srt'):
|
if ext in ('sub', 'srt'):
|
||||||
|
|
|
@ -741,13 +741,13 @@ class ArchiveFile(SQLObject):
|
||||||
return cache.loadPosterStill(self, position)
|
return cache.loadPosterStill(self, position)
|
||||||
|
|
||||||
def still(self, position):
|
def still(self, position):
|
||||||
still = os.path.join(self.stillFolder, "%s.%s" % (position.replace(':', '.'), 'png'))
|
still = os.path.join(self.stillFolder, "%s.%s" % (position.replace(':', '.'), 'jpg'))
|
||||||
if not exists(still):
|
if not exists(still):
|
||||||
oxdb_makedir(dirname(still))
|
oxdb_makedir(dirname(still))
|
||||||
movieFile = self.absolutePath
|
movieFile = self.absolutePath
|
||||||
if os.path.splitext(movieFile)[-1] in ('.mov', '.mpg', '.mpeg'):
|
if os.path.splitext(movieFile)[-1] in ('.mov', '.mpg', '.mpeg'):
|
||||||
movieFile = self.mini_movie_file
|
movieFile = self.mini_movie_file
|
||||||
extract_still(movieFile, position, self.stillFolder, -1)
|
extract_frame(movieFile, position, self.stillFolder, -1)
|
||||||
if exists(still):
|
if exists(still):
|
||||||
return cache.loadFile(still)
|
return cache.loadFile(still)
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in a new issue