Added conversion options
authorThierry Florac <thierry.florac@onf.fr>
Fri, 04 Dec 2015 16:34:56 +0100
changeset 20 30a34a5cb19c
parent 19 179f9381965b
child 21 1784464dfe62
Added conversion options
src/pyams_media/converter.py
--- a/src/pyams_media/converter.py	Fri Dec 04 16:34:30 2015 +0100
+++ b/src/pyams_media/converter.py	Fri Dec 04 16:34:56 2015 +0100
@@ -61,9 +61,10 @@
         for loop in self.get_conversion_loop(document):
             if self.require_temp_file:
                 output = NamedTemporaryFile(prefix='media_', suffix='.%s' % self.format)
-                document.get_output(self.format, target=output.name)
+                converted = document.get_output(self.format, target=output.name)
                 output.file.seek(0)
-                yield loop, output.file.read()
+                converted['output'] = output.file.read()
+                yield loop, converted
             else:
                 yield loop, document.get_output(self.format)
 
@@ -143,12 +144,14 @@
     def add_filters(self, document):
         utility = query_utility(IMediaConversionUtility)
         if utility is not None:
+            if utility.video_bitrate:
+                document.bitrate(utility.video_bitrate)
+            if utility.video_quantisation:
+                document.quantizerscale(utility.video_quantisation)
             if utility.video_audio_sampling:
                 document.audiosampling(utility.video_audio_sampling)
             if utility.video_audio_bitrate:
-                document.bitrate(utility.video_audio_bitrate)
-            if utility.video_quantisation:
-                document.quantizerscale(utility.video_quantisation)
+                document.audiobitrate(utility.video_audio_bitrate)
 
     def get_conversion_loop(self, document):
         utility = query_utility(IMediaConversionUtility)
@@ -201,9 +204,10 @@
         effects['pix_fmt'] = 'yuv420p'
         effects['preset:v'] = 'slow'
         effects['profile:v'] = 'baseline'
-        effects['x264opts'] = 'level=3.0:ref=1'
+        effects['x264-params'] = 'level=3.0:ref=1'
         effects['r:v'] = '25/1'
         effects['movflags'] = '+faststart'
+        effects['strict'] = 'experimental'
 
 
 @utility_config(name='video/ogg', provides=IMediaConverter)