Commit 28c881c3 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor code to allow edit the environment

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43636 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent caf0ccfe
...@@ -34,7 +34,7 @@ from subprocess import Popen, PIPE ...@@ -34,7 +34,7 @@ from subprocess import Popen, PIPE
class FFMPEGHandler(object): class FFMPEGHandler(object):
"""FFMPEGHandler is used to handler inputed video files""" """FFMPEGHandler is used to handler inputed video files"""
def __init__(self, base_folder_url, data, source_format): def __init__(self, base_folder_url, data, source_format, **kw):
""" """
base_folder_url(string) base_folder_url(string)
The requested url for data base folder The requested url for data base folder
...@@ -44,7 +44,7 @@ class FFMPEGHandler(object): ...@@ -44,7 +44,7 @@ class FFMPEGHandler(object):
The source format of the inputed video""" The source format of the inputed video"""
self.base_folder_url = base_folder_url self.base_folder_url = base_folder_url
self.input = File(base_folder_url, data, source_format) self.input = File(base_folder_url, data, source_format)
self.ffmpeg_bin = "/usr/bin/ffmpeg" self.environment = kw.get("env", {})
def convert(self, destination_format): def convert(self, destination_format):
""" Convert the inputed video to output as format that were informed """ """ Convert the inputed video to output as format that were informed """
...@@ -53,7 +53,7 @@ class FFMPEGHandler(object): ...@@ -53,7 +53,7 @@ class FFMPEGHandler(object):
# the end # the end
output = File(self.base_folder_url, '', destination_format) output = File(self.base_folder_url, '', destination_format)
try: try:
command = [self.ffmpeg_bin, command = ["ffmpeg",
"-i", "-i",
self.input.getUrl(), self.input.getUrl(),
"-y", "-y",
...@@ -61,7 +61,8 @@ class FFMPEGHandler(object): ...@@ -61,7 +61,8 @@ class FFMPEGHandler(object):
stdout, stderr = Popen(command, stdout, stderr = Popen(command,
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,
close_fds=True).communicate() close_fds=True,
env=self.environment).communicate()
output.reload() output.reload()
return output.getContent() return output.getContent()
finally: finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment