Switch to libAV tools
authorThierry Florac <thierry.florac@onf.fr>
Fri, 04 Dec 2015 16:36:06 +0100
changeset 22 b5da674fd06c
parent 21 1784464dfe62
child 23 d49c3f386782
Switch to libAV tools
src/pyams_media/media.py
--- a/src/pyams_media/media.py	Fri Dec 04 16:35:28 2015 +0100
+++ b/src/pyams_media/media.py	Fri Dec 04 16:36:06 2015 +0100
@@ -21,7 +21,7 @@
 # import interfaces
 from pyams_file.interfaces import IFile
 from pyams_media.interfaces import IMediaInfo, CUSTOM_AUDIO_TYPES, CUSTOM_VIDEO_TYPES, IMediaConversions, \
-    IMediaConversion, IMediaConversionUtility, VIDEO_FRAME_SIZE
+    IMediaConversion, IMediaConversionUtility, VIDEO_FRAME_SIZE, MEDIA_CONVERSIONS_KEY
 from pyams_utils.interfaces.tales import ITALESExtension
 from transaction.interfaces import ITransactionManager
 from zope.annotation.interfaces import IAnnotations
@@ -59,7 +59,7 @@
     annotations = IAnnotations(context)
     info = annotations.get(MEDIA_INFO_KEY)
     if info is None:
-        info = annotations[MEDIA_INFO_KEY] = FFmpeg('ffprobe').info(context)
+        info = annotations[MEDIA_INFO_KEY] = FFmpeg('avprobe').info(context)
     return info
 
 
@@ -67,8 +67,6 @@
 # Media conversions
 #
 
-MEDIA_CONVERSIONS_KEY = 'pyams_media.media.conversions'
-
 MEDIA_FRAME_SIZE = re.compile(".*-(.*)\..*")
 
 
@@ -89,6 +87,7 @@
                                                          extension=extension)
         target.filename = target_name
         self[target_name] = target
+        return target
 
     def get_conversions(self, with_source=False, order=None):
         result = []
@@ -105,7 +104,7 @@
     def get_conversion_width(name):
         match = MEDIA_FRAME_SIZE.match(name)
         if match:
-            return VIDEO_FRAME_SIZE.get(match.groups()[0])
+            return VIDEO_FRAME_SIZE.get(match.groups()[0])[0]
 
     def has_conversion(self, formats):
         for conversion in self.get_conversions():