Video editing with Python
fix import of os for other systems than win
Florian Zierer699ebf085df6
diff --git a/moviepy/audio/io/ffmpeg_audiowriter.py b/moviepy/audio/io/ffmpeg_audiowriter.pyindex b7f65cc2..a05dc182 100644--- a/moviepy/audio/io/ffmpeg_audiowriter.py+++ b/moviepy/audio/io/ffmpeg_audiowriter.py@@ -2,10 +2,10 @@import numpy as npimport subprocess as sp+import ostry:from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')from tqdm import tqdmdiff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.pyindex 83e65d80..896860ba 100644--- a/moviepy/audio/io/readers.py+++ b/moviepy/audio/io/readers.py@@ -7,12 +7,13 @@ from moviepy.tools import cvsecsfrom moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infosfrom moviepy.conf import FFMPEG_BINARY+import ostry:from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')+class FFMPEG_AudioReader:"""A class to read the audio in either video files or audio filesdiff --git a/moviepy/conf.py b/moviepy/conf.pyindex 44b5bedb..796828bb 100644--- a/moviepy/conf.py+++ b/moviepy/conf.py@@ -34,7 +34,11 @@ You can run this file to check that FFMPEG has been detected.FFMPEG_BINARY = NoneIMAGEMAGICK_BINARY = 'convert'-+import os+try:+ from subprocess import DEVNULL # py3k+except ImportError:+ DEVNULL = open(os.devnull, 'wb')# =====================================================================# CODE. Don't write anything below this line !@@ -43,7 +47,14 @@ import subprocess as spdef try_cmd(cmd):try:- proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)+ popen_params = {"stdout": sp.PIPE,+ "stderr": sp.PIPE,+ "stdin": DEVNULL}++ if os.name == "nt":+ popen_params["creationflags"] = 0x08000000++ proc = sp.Popen(cmd, **popen_params)proc.communicate()except:return Falsediff --git a/moviepy/tools.py b/moviepy/tools.pyindex 16f4aa16..a570ecba 100644--- a/moviepy/tools.py+++ b/moviepy/tools.py@@ -7,12 +7,13 @@ import sysimport warningsimport re+import ostry:from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')+def sys_write_flush(s):""" Writes and flushes without delay a text in the console """sys.stdout.write(s)diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex 8df8878f..22d0fcad 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -41,10 +41,10 @@ from ..decorators import (apply_to_mask,convert_to_seconds)+import ostry:from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.pyindex e4e77e3d..160aba50 100644--- a/moviepy/video/io/ffmpeg_reader.py+++ b/moviepy/video/io/ffmpeg_reader.py@@ -12,10 +12,10 @@ import numpy as npfrom moviepy.conf import FFMPEG_BINARY # ffmpeg, ffmpeg.exe, etc...from moviepy.tools import cvsecs+import ostry:from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex 794d79e1..3296306f 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -6,10 +6,10 @@ out of VideoClipsimport numpy as npimport subprocess as sp+import ostry:from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')diff --git a/moviepy/video/io/gif_writers.py b/moviepy/video/io/gif_writers.pyindex 4f00282d..727f86ad 100644--- a/moviepy/video/io/gif_writers.py+++ b/moviepy/video/io/gif_writers.py@@ -7,9 +7,8 @@ from moviepy.tools import verbose_print, subprocess_callimport numpy as nptry:- from subprocess import DEVNULL # py3k+ from subprocess import DEVNULL # py3kexcept ImportError:- import osDEVNULL = open(os.devnull, 'wb')