Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_module():
try:
imageio.plugins.avbin.download()
except imageio.core.InternetNotAllowedError:
pass
def test_freeimage_lib():
fi = imageio.plugins.freeimage.fi
# Error messages
imageio.plugins._freeimage.fi._messages.append("this is a test")
assert imageio.plugins._freeimage.fi.get_output_log()
imageio.plugins._freeimage.fi._show_any_warnings()
imageio.plugins._freeimage.fi._get_error_message()
# Test getfif
raises(ValueError, fi.getFIF, "foo.png", "x") # mode must be r or w
raises(ValueError, fi.getFIF, "foo.notvalid", "w") # invalid ext
raises(ValueError, fi.getFIF, "foo.iff", "w") # We cannot write iff
def extract(video_name=None, subtitle_name=None, relative_outdir='voice_data', logger=None):
if video_name is None:
raise ValueError('video file not specified')
if subtitle_name is None:
raise ValueError('subtitle file is not specified')
# Downloads ffmpeg binary if it is absent
imageio.plugins.ffmpeg.download()
video_path = os.path.join(os.getcwd(), video_name)
logger.info("video path: {}".format(video_path))
subtitle_path = os.path.join(os.getcwd(), subtitle_name)
logger.info("subtitles path: {}".format(subtitle_path))
output_path = os.path.join(os.getcwd(), relative_outdir)
logger.info("output path: {}".format(output_path))
if not mkdir_p(output_path):
logger.debug("Output directory created at {}".format(output_path))
subs = pysrt.open(subtitle_path, encoding='utf-8')
clip = mp.VideoFileClip(video_path)
for line, num in zip(subs, itertools.count()):
if '\n' in line.text:
continue
# noinspection PyShadowingBuiltins
format = format[1:] # to remove the dot
else:
# noinspection PyShadowingBuiltins
format = "mp4"
key += "." + format
filename = pJoin(self.prefix, key)
import tempfile, imageio # , logging as py_logging
# py_logging.getLogger("imageio").setLevel(py_logging.WARNING)
with tempfile.NamedTemporaryFile(suffix=f'.{format}') as ntp:
from skimage import img_as_ubyte
try:
imageio.mimsave(ntp.name, img_as_ubyte(frame_stack), format=format, fps=fps, **imageio_kwargs)
except imageio.core.NeedDownloadError:
imageio.plugins.ffmpeg.download()
imageio.mimsave(ntp.name, img_as_ubyte(frame_stack), format=format, fps=fps, **imageio_kwargs)
ntp.seek(0)
self.client.log_buffer(key=filename, buf=ntp.read(), overwrite=True)
"""
# Note that these imports could have been performed in the __init__.py
# file, but this would make the loading of moviepy slower.
import os
import sys
# Downloads ffmpeg if it isn't already installed
import imageio
# Checks to see if the user has set a place for their own version of ffmpeg
if os.getenv('FFMPEG_BINARY', 'ffmpeg-imageio') == 'ffmpeg-imageio':
if sys.version_info < (3, 4):
#uses an old version of imageio with ffmpeg.download.
imageio.plugins.ffmpeg.download()
# Hide the welcome message from pygame: https://github.com/pygame/pygame/issues/542
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "1"
# Clips
from .video.io.VideoFileClip import VideoFileClip
from .video.io.ImageSequenceClip import ImageSequenceClip
from .video.io.downloader import download_webfile
from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip
from .video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array
from .video.compositing.concatenate import concatenate_videoclips, concatenate # concatenate=deprecated
from .audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips
from .audio.io.AudioFileClip import AudioFileClip
# FX
import os
import sys
import subprocess
from joblib import Parallel, delayed
import numpy as np
import imageio
imageio.plugins.freeimage.download()
from imageio.plugins import freeimage
import h5py
from lz4.block import decompress
import scipy.misc
import cv2
from path import Path
path = os.path.join(os.path.dirname(os.path.abspath(__file__)))
def dump_example(dataset_name):
print("Converting {:}.h5 ...".format(dataset_name))
file = h5py.File(os.path.join(path, "traindata", "{:}.h5".format(dataset_name)), "r")
for (seq_idx, seq_name) in enumerate(file):
if dataset_name == 'scenes11_train':