forked from openlp/openlp
Head
This commit is contained in:
commit
6b73581ec5
@ -25,12 +25,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
try:
|
|
||||||
import gst
|
|
||||||
except:
|
|
||||||
NOGST = True
|
|
||||||
log = logging.getLogger(u'MediaMediaItemSetup')
|
|
||||||
log.warning(u'Can\'t generate Videos previews - import gst failed');
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -70,54 +64,17 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
|
||||||
def video_get_preview(self, filename):
|
def video_get_preview(self, filename):
|
||||||
if NOGST:
|
#
|
||||||
#
|
# For now cross platform is an icon. Phonon does not support
|
||||||
# For now cross platform is an icon. Phonon does not support
|
# individual frame access (yet?) and GStreamer is not available
|
||||||
# individual frame access (yet?) and GStreamer is not available
|
# on Windows
|
||||||
# on Windows
|
#
|
||||||
#
|
image = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
||||||
image = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
return image
|
||||||
return image
|
|
||||||
else:
|
|
||||||
"""
|
|
||||||
Gets a preview of the first frame of a video file using GSTREAMER
|
|
||||||
(non-portable) - returns a QImage
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
# Define your pipeline, just as you would at the command
|
|
||||||
# prompt. This is much easier than trying to create and link
|
|
||||||
# each gstreamer element in Python. This is great for
|
|
||||||
# pipelines that end with a filesink (i.e. there is no audible
|
|
||||||
# or visual output)
|
|
||||||
log.info ("Video preview %s"%( filename))
|
|
||||||
outfile = tempfile.NamedTemporaryFile(suffix='.png')
|
|
||||||
cmd = u'filesrc location="%s" ! decodebin ! ffmpegcolorspace ! pngenc ! filesink location="%s"'% (filename, outfile.name)
|
|
||||||
pipe = gst.parse_launch(cmd)
|
|
||||||
# Get a reference to the pipeline's bus
|
|
||||||
bus = pipe.get_bus()
|
|
||||||
|
|
||||||
# Set the pipeline's state to PLAYING
|
|
||||||
pipe.set_state(gst.STATE_PLAYING)
|
|
||||||
|
|
||||||
# Listen to the pipeline's bus indefinitely until we receive a
|
|
||||||
# EOS (end of stream) message. This is a super important step,
|
|
||||||
# or the pipeline might not work as expected. For example, in
|
|
||||||
# my example pipeline above, the pngenc will not export an
|
|
||||||
# actual image unless you have this line of code. It just
|
|
||||||
# exports a 0 byte png file. So... don't forget this step.
|
|
||||||
bus.poll(gst.MESSAGE_EOS, -1)
|
|
||||||
img = QtGui.QImage(outfile.name)
|
|
||||||
outfile.close()
|
|
||||||
# os.unlink(outfile.name)
|
|
||||||
pipe.set_state(gst.STATE_NULL)
|
|
||||||
return img
|
|
||||||
except:
|
|
||||||
log.info("Can't generate video preview for some reason");
|
|
||||||
return None
|
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item):
|
||||||
indexes = self.ListView.selectedIndexes()
|
indexes = self.ListView.selectedIndexes()
|
||||||
if len(items) > 1:
|
if len(indexes) > 1:
|
||||||
return False
|
return False
|
||||||
service_item.title = u'Media'
|
service_item.title = u'Media'
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
@ -151,7 +108,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
row = self.ListView.row(item)
|
row = self.ListView.row(item)
|
||||||
self.ListView.takeItem(row)
|
self.ListView.takeItem(row)
|
||||||
self.parent.config.set_list(
|
self.parent.config.set_list(
|
||||||
self.ConfigSection, self.ListData.getFileList())
|
self.ConfigSection, self.getFileList())
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
for file in list:
|
for file in list:
|
||||||
|
Loading…
Reference in New Issue
Block a user