• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tools.subprocess_call函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中moviepy.tools.subprocess_call函数的典型用法代码示例。如果您正苦于以下问题:Python subprocess_call函数的具体用法?Python subprocess_call怎么用?Python subprocess_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了subprocess_call函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: ffmpeg_resize

def ffmpeg_resize(video,output,size):
    """ resizes ``video`` to new size ``size`` and write the result
        in file ``output``. """
    cmd= [get_setting("FFMPEG_BINARY"), "-i", video, "-vf", "scale=%d:%d"%(size[0], size[1]),
             output]
             
    subprocess_call(cmd)
开发者ID:Zulko,项目名称:moviepy,代码行数:7,代码来源:ffmpeg_tools.py


示例2: ffmpeg_resize

def ffmpeg_resize(video,output,size):
    """ resizes ``video`` to new size ``size`` and write the result
        in file ``output``. """
    cmd= ["ffmpeg", "-i", video, "-vf", "scale=%d:%d"%(res[0], res[1]),
             output]
             
    subprocess_call(cmd)
开发者ID:Dhertz,项目名称:moviepy,代码行数:7,代码来源:ffmpeg_tools.py


示例3: gif_to_directory

def gif_to_directory(gif_file,dirName=None):
    """
    Stores all the frames of the given .gif file
    into the directory ``dirName``. If ``dirName``
    is not provided, the directory has the same name
    as the .gif file. Supports transparency.
    Returns the directory name.

    Example:

    >>> d = gif_to_directory("animated-earth.gif")
    >>> clip = DirectoryClip(d,fps=3)

    """

    if dirName is None:
        name, ext = os.path.splitext(gif_file)
        dirName = name

    try:
        os.mkdir(dirName)
    except:
        pass

    subprocess_call(["convert", "-coalesce", gif_file,
             os.path.join(dirName,"%04d.png")])
开发者ID:DevinGeo,项目名称:moviepy,代码行数:26,代码来源:imageMagick_tools.py


示例4: ffmpeg_merge_video_audio

def ffmpeg_merge_video_audio(video,audio,output,
                vcodec='copy', acodec='copy', ffmpeg_output=False):
    """ merges video file ``video`` and audio file ``audio`` into one
        movie file ``output``. """
    cmd = ["ffmpeg", "-y", "-i", audio,"-i", video,
             "-vcodec", vcodec, "-acodec", acodec, output]
             
    subprocess_call(cmd, stdin=None, stdout=None)
开发者ID:bihicheng,项目名称:moviepy,代码行数:8,代码来源:ffmpeg_tools.py


示例5: __init__

    def __init__(self, txt, size=None, color='black',
             bg_color='transparent', fontsize=None, font='Courier',
             stroke_color=None, stroke_width=1, method='label',
             kerning=None, align='center', interline=None,
             tempfile='temp.png', temptxt='temp.txt',
             transparent=True, remove_temp=True,
             print_cmd=False):

        if not txt.startswith('@'):
            temptxt = 'temp.txt'
            with open(temptxt, 'w+') as f:
                f.write(txt)
            txt = '@temp.txt'
        else:
            txt = "'%s'"%txt

        if size != None:
            size = ('' if size[0] is None else str(size[0]),
                    '' if size[1] is None else str(size[1]))

        cmd = ( ["convert",
               "-background", bg_color,
               "-fill", color,
               "-font", font])
            
        if fontsize !=None:
            cmd += ["-pointsize", "%d"%fontsize]
        if kerning != None:
            cmd += ["-kerning", "%0.1f"%kerning]
        if stroke_color != None:
            cmd += ["-stroke", stroke_color, "-strokewidth",
                                             "%.01f"%stroke_width]
        if size != None:
            cmd += ["-size", "%sx%s"%(size[0], size[1])]
        if align != None:
            cmd += ["-gravity",align]
        if interline != None:
            cmd += ["-interline-spacing", "%d"%interline]
            
        cmd += ["%s:%s" %(method, txt),
        "-type",  "truecolormatte", "PNG32:%s"%tempfile]
        
        if print_cmd:
            print( " ".join(cmd) )

        subprocess_call(cmd, verbose=False )
        
        ImageClip.__init__(self, tempfile, transparent=transparent)
        self.txt = txt
        self.color = color
        self.stroke_color = stroke_color

        if remove_temp:
            os.remove(tempfile)
            try:
                os.remove(temptxt)
            except:
                pass
开发者ID:JoshdanG,项目名称:moviepy,代码行数:58,代码来源:VideoClip.py


示例6: ffmpeg_merge_video_audio

def ffmpeg_merge_video_audio(video,audio,output, vcodec='copy',
                             acodec='copy', ffmpeg_output=False,
                             logger = 'bar'):
    """ merges video file ``video`` and audio file ``audio`` into one
        movie file ``output``. """
    cmd = [get_setting("FFMPEG_BINARY"), "-y", "-i", audio,"-i", video,
             "-vcodec", vcodec, "-acodec", acodec, output]
             
    subprocess_call(cmd, logger = logger)
开发者ID:Zulko,项目名称:moviepy,代码行数:9,代码来源:ffmpeg_tools.py


示例7: ffmpeg_merge_video_audio

def ffmpeg_merge_video_audio(video,audio,output, vcodec='copy',
                             acodec='copy', ffmpeg_output=False,
                             verbose = True):
    """ merges video file ``video`` and audio file ``audio`` into one
        movie file ``output``. """
    cmd = [FFMPEG_BINARY, "-y", "-i", audio,"-i", video,
             "-vcodec", vcodec, "-acodec", acodec, output]
             
    subprocess_call(cmd, verbose = verbose)
开发者ID:BAT0000,项目名称:moviepy,代码行数:9,代码来源:ffmpeg_tools.py


示例8: download_webfile

def download_webfile(url, filename, overwrite=False):
    """ Small utility to download the file at 'url' under name 'filename'.
    If url is a youtube video ID like z410eauCnH it will download the video
    using youtube-dl (install youtube-dl first !).
    If the filename already exists and overwrite=False, nothing will happen.
    """
    if os.path.exists(filename) and not overwrite:
        return

    if '.' in url:
        urlretrieve(url, filename)
    else:
        subprocess_call(['youtube-dl', url, '-o', filename])
开发者ID:JNazare,项目名称:ScratchGifMakerApi,代码行数:13,代码来源:downloader.py


示例9: ffmpeg_movie_from_frames

def ffmpeg_movie_from_frames(filename, folder, fps, digits=6):
    """
    Writes a movie out of the frames (picture files) in a folder.
    Almost deprecated.
    """
    s = "%" + "%02d" % digits + "d.png"
    cmd = ["ffmpeg", "-y", "-f","image2",
             "-r", "%d"%fps,
             "-i", os.path.join(folder,folder) + '/' + s,
             "-b", "%dk"%bitrate,
             "-r", "%d"%self.fps,
             filename]
    
    subprocess_call(cmd, stdin=None, stdout=None)
开发者ID:bihicheng,项目名称:moviepy,代码行数:14,代码来源:ffmpeg_tools.py


示例10: ffmpeg_movie_from_frames

def ffmpeg_movie_from_frames(filename, folder, fps, digits=6, bitrate='v'):
    """
    Writes a movie out of the frames (picture files) in a folder.
    Almost deprecated.
    """
    s = "%" + "%02d" % digits + "d.png"
    cmd = [get_setting("FFMPEG_BINARY"), "-y", "-f","image2",
             "-r", "%d"%fps,
             "-i", os.path.join(folder,folder) + '/' + s,
             "-b", "%dk"%bitrate,
             "-r", "%d"%fps,
             filename]
    
    subprocess_call(cmd)
开发者ID:Zulko,项目名称:moviepy,代码行数:14,代码来源:ffmpeg_tools.py


示例11: ffmpeg_extract_subclip

def ffmpeg_extract_subclip(filename, t1, t2, targetname=None):
    """ Makes a new video file playing video file ``filename`` between
        the times ``t1`` and ``t2``. """
    name, ext = os.path.splitext(filename)
    if not targetname:
        T1, T2 = [int(1000*t) for t in [t1, t2]]
        targetname = "%sSUB%d_%d.%s" % (name, T1, T2, ext)
    
    cmd = [get_setting("FFMPEG_BINARY"),"-y",
           "-ss", "%0.2f"%t1,
           "-i", filename,
           "-t", "%0.2f"%(t2-t1),
           "-vcodec", "copy", "-acodec", "copy", targetname]
    
    subprocess_call(cmd)
开发者ID:Zulko,项目名称:moviepy,代码行数:15,代码来源:ffmpeg_tools.py


示例12: download_webfile

def download_webfile(url, filename, overwrite=False):
    """ Small utility to download the file at 'url' under name 'filename'.
    If url is a youtube video ID like z410eauCnH it will download the video
    using youtube-dl (install youtube-dl first !).
    If the filename already exists and overwrite=False, nothing will happen.
    """
    if os.path.exists(filename) and not overwrite:
        return

    if '.' in url:
        urlretrieve(url, filename)
    else:
        try:
            subprocess_call(['youtube-dl', url, '-o', filename])
        except OSError as e:
            raise OSError(e.message + '\n A possible reason is that youtube-dl'
                ' is not installed on your computer. Install it with '
                ' "pip install youtube-dl"')
开发者ID:410063005,项目名称:moviepy,代码行数:18,代码来源:downloader.py


示例13: download_webfile

def download_webfile(url, filename, overwrite=False):
    """ Small utility to download the file at 'url' under name 'filename'.
    If url is a youtube video ID like z410eauCnH it will download the video
    using youtube-dl (install youtube-dl first !).
    If the filename already exists and overwrite=False, nothing will happen.
    """
    if os.path.exists(filename) and not overwrite:
        return

    if '.' in url:
        r = requests.get(url, stream=True)
        with open(filename, 'wb') as fd:
            for chunk in r.iter_content(chunk_size=128):
                fd.write(chunk)

    else:
        try:
            subprocess_call(['youtube-dl', url, '-o', filename])
        except OSError as e:
            raise OSError(
                e.message + '\n A possible reason is that youtube-dl'
                ' is not installed on your computer. Install it with '
                ' "pip install youtube_dl"')
开发者ID:Mediaeater,项目名称:moviepy,代码行数:23,代码来源:downloader.py


示例14: __init__

    def __init__(self, txt, size=None, color='black',
             bg_color='transparent', fontsize=None, font='Courier',
             stroke_color=None, stroke_width=1, method='label',
             kerning=None, align='center', interline=None,
             tempfilename=None, temptxt=None,
             transparent=True, remove_temp=True,
             print_cmd=False):

        if not txt.startswith('@'):
            if temptxt is None:
                temptxt_fd, temptxt = tempfile.mkstemp(suffix='.txt')
                os.write(temptxt_fd, txt)
                os.close(temptxt_fd)
            txt = '@'+temptxt
        else:
            txt = "'%s'"%txt

        if size != None:
            size = ('' if size[0] is None else str(size[0]),
                    '' if size[1] is None else str(size[1]))

        cmd = ( [IMAGEMAGICK_BINARY,
               "-background", bg_color,
               "-fill", color,
               "-font", font])

        if fontsize !=None:
            cmd += ["-pointsize", "%d"%fontsize]
        if kerning != None:
            cmd += ["-kerning", "%0.1f"%kerning]
        if stroke_color != None:
            cmd += ["-stroke", stroke_color, "-strokewidth",
                                             "%.01f"%stroke_width]
        if size != None:
            cmd += ["-size", "%sx%s"%(size[0], size[1])]
        if align != None:
            cmd += ["-gravity",align]
        if interline != None:
            cmd += ["-interline-spacing", "%d"%interline]

        if tempfilename is None:
            tempfile_fd, tempfilename = tempfile.mkstemp(suffix='.png')
            os.close(tempfile_fd)

        cmd += ["%s:%s" %(method, txt),
        "-type",  "truecolormatte", "PNG32:%s"%tempfilename]

        if print_cmd:
            print( " ".join(cmd) )

        subprocess_call(cmd, verbose=False )

        ImageClip.__init__(self, tempfilename, transparent=transparent)
        self.txt = txt
        self.color = color
        self.stroke_color = stroke_color

        if remove_temp:
            if os.path.exists(tempfilename):
                os.remove(tempfilename)
            if os.path.exists(temptxt):
                os.remove(temptxt)
开发者ID:engmsaleh,项目名称:moviepy,代码行数:62,代码来源:VideoClip.py


示例15: to_gif

    def to_gif(self, filename, fps=None, program= 'ImageMagick',
            opt="OptimizeTransparency", fuzz=1, verbose=True,
            loop=0, dispose=False):
        """ Write the VideoClip to a GIF file
        Converts a VideoClip into an animated GIF using ImageMagick or
        ffmpeg.


        Parameters
        -----------

        filename
          Name of the resulting gif file.

        fps
          Number of frames per second (see note below). If it
            isn't provided, then the function will look for the clip's
            ``fps`` attribute (VideoFileClip, for instance, have one).

        program
          Software to use for the conversion, either 'ImageMagick' or
          'ffmpeg'.

        opt
          (ImageMagick only) optimalization to apply, either
          'optimizeplus' or 'OptimizeTransparency'.

        fuzz
          (ImageMagick only) Compresses the GIF by considering that the
          colors that are less than fuzz% different are in fact the same.


        Notes
        -----

        The gif will be playing the clip in real time (you can
        only change the frame rate). If you want the gif to be played
        slower than the clip you will use ::

            >>> # slow down clip 50% and make it a gif
            >>> myClip.speedx(0.5).to_gif('myClip.gif')

        """

        def verbose_print(s):
            if verbose: sys_write_flush(s)

        if fps is None:
            fps = self.fps

        fileName, fileExtension = os.path.splitext(filename)
        tt = np.arange(0,self.duration, 1.0/fps)
        tempfiles = []

        verbose_print("\nMoviePy: building GIF file %s\n"%filename
                      +40*"-"+"\n")

        verbose_print("Generating GIF frames.\n")

        total = int(self.duration/fps)+1
        for i, t in tqdm(enumerate(tt), total=total):

            name = "%s_GIFTEMP%04d.png"%(fileName, i+1)
            tempfiles.append(name)
            self.save_frame(name, t, savemask=True)

        verbose_print("Done generating GIF frames.\n")

        delay = int(100.0/fps)

        if program == "ImageMagick":

            cmd = [IMAGEMAGICK_BINARY,
                  '-delay' , '%d'%delay,
                  "-dispose" ,"%d"%(2 if dispose else 1),
                  "-loop" , "%d"%loop,
                  "%s_GIFTEMP*.png"%fileName,
                  "-coalesce",
                  "-fuzz", "%02d"%fuzz + "%",
                  "-layers", "%s"%opt,
                  "%s"%filename]

        elif program == "ffmpeg":

            cmd = [FFMPEG_BINARY, '-y',
                   '-f', 'image2',
                   '-i', fileName+'_GIFTEMP%04d.png',
                   '-r',str(fps),
                   filename]


        subprocess_call( cmd, verbose = verbose )

        for f in tempfiles:
            os.remove(f)
开发者ID:engmsaleh,项目名称:moviepy,代码行数:95,代码来源:VideoClip.py


示例16: __init__

    def __init__(self, txt=None, filename=None, size=None, color='black',
                 bg_color='transparent', fontsize=None, font='Courier',
                 stroke_color=None, stroke_width=1, method='label',
                 kerning=None, align='center', interline=None,
                 tempfilename=None, temptxt=None,
                 transparent=True, remove_temp=True,
                 shadow=None, antialias=4,
                 print_cmd=False):

        import tempfile
        import subprocess as sp

        from moviepy.tools import subprocess_call
        from moviepy.config import get_setting

        # from moviepy.video.VideoClip import *

        aa_factor= 1 if not antialias else antialias

        if txt is not None:
            if temptxt is None:
                temptxt_fd, temptxt = tempfile.mkstemp(suffix='.txt')
                try:  # only in Python3 will this work
                    os.write(temptxt_fd, bytes(txt, 'UTF8'))
                except TypeError:  # oops, fall back to Python2
                    os.write(temptxt_fd, txt)
                os.close(temptxt_fd)
            txt = '@' + temptxt
        else:
            # use a file instead of a text.
            txt = "@%" + filename

        if size is not None:
            size = ('' if size[0] is None else size[0],
                    '' if size[1] is None else size[1])

        if shadow is not None:
            shadow = (80 if shadow[0] is None else shadow[0],
                       1 if shadow[1] is None else shadow[1],
                       2 if shadow[2] is None else shadow[2],
                       2 if shadow[3] is None else shadow[3])

        cmd = ( [get_setting("IMAGEMAGICK_BINARY"),
               "-density", str(aa_scale(72, aa_factor)),
               "-background", bg_color,
               "-fill", color,
               "-font", font])

        if fontsize is not None:
            cmd += ["-pointsize", "%d" % fontsize]
        if kerning is not None:
            cmd += ["-kerning", "%0.1f" % aa_scale(kerning, aa_factor)]
        if stroke_color is not None:
            cmd += ["-stroke", stroke_color, "-strokewidth",
                    "%.01f" % aa_scale(stroke_width, aa_factor)]
        if size is not None:
            cmd += ["-size", "%sx%s" % aa_scale(size, aa_factor)]
        if align is not None:
            cmd += ["-gravity", align]
        if interline is not None:
            cmd += ["-interline-spacing", "%d" % interline]

        if tempfilename is None:
            tempfile_fd, tempfilename = tempfile.mkstemp(suffix='.png')
            os.close(tempfile_fd)

        if shadow is not None:
            shadow_cmd = ( ["(", "+clone",
                          "-shadow", "%sx%s+%s+%s" % (tuple([shadow[0]]) + aa_scale(shadow[1:], aa_factor)),
                          ")",
                          "-compose", "DstOver",
                          "-flatten"])

        cmd += ["%s:%s" % (method, txt)]
        cmd += shadow_cmd
        cmd += ["-resample", "72"]
        cmd += ["-type", "truecolormatte", "PNG32:%s" % tempfilename]

        if print_cmd:
            print( " ".join(cmd) )

        try:
            subprocess_call(cmd, verbose=verbose)
        except (IOError,OSError) as err:
            error = ("MoviePy Error: creation of %s failed because "
              "of the following error:\n\n%s.\n\n."%(filename, str(err))
               + ("This error can be due to the fact that "
                    "ImageMagick is not installed on your computer, or "
                    "(for Windows users) that you didn't specify the "
                    "path to the ImageMagick binary in file conf.py, or."
                    "that the path you specified is incorrect" ))
            raise IOError(error)

        ImageClip.__init__(self, tempfilename, transparent=transparent)
        self.txt = txt
        self.color = color
        self.stroke_color = stroke_color

        if remove_temp:
            if os.path.exists(tempfilename):
#.........这里部分代码省略.........
开发者ID:BooDoo,项目名称:grepcap,代码行数:101,代码来源:grepcap.py


示例17: write_gif_with_tempfiles

def write_gif_with_tempfiles(clip, filename, fps=None, program= 'ImageMagick',
       opt="OptimizeTransparency", fuzz=1, verbose=True,
       loop=0, dispose=True, colors=None):
    """ Write the VideoClip to a GIF file.


    Converts a VideoClip into an animated GIF using ImageMagick
    or ffmpeg. Does the same as write_gif (see this one for more
    docstring), but writes every frame to a file instead of passing
    them in the RAM. Useful on computers with little RAM.

    """

    fileName, fileExtension = os.path.splitext(filename)
    tt = np.arange(0,clip.duration, 1.0/fps)

    tempfiles = []

    verbose_print(verbose, "\n[MoviePy] Building file %s\n"%filename
                  +40*"-"+"\n")

    verbose_print(verbose, "[MoviePy] Generating GIF frames...\n")

    total = int(clip.duration*fps)+1
    for i, t in tqdm(enumerate(tt), total=total):

        name = "%s_GIFTEMP%04d.png"%(fileName, i+1)
        tempfiles.append(name)
        clip.save_frame(name, t, withmask=True)

    delay = int(100.0/fps)

    if program == "ImageMagick":
        verbose_print(verbose, "[MoviePy] Optimizing GIF with ImageMagick... ")
        cmd = [get_setting("IMAGEMAGICK_BINARY"),
              '-delay' , '%d'%delay,
              "-dispose" ,"%d"%(2 if dispose else 1),
              "-loop" , "%d"%loop,
              "%s_GIFTEMP*.png"%fileName,
              "-coalesce",
              "-layers", "%s"%opt,
              "-fuzz", "%02d"%fuzz + "%",
              ]+(["-colors", "%d"%colors] if colors is not None else [])+[
              filename]

    elif program == "ffmpeg":

        cmd = [get_setting("FFMPEG_BINARY"), '-y',
               '-f', 'image2', '-r',str(fps),
               '-i', fileName+'_GIFTEMP%04d.png',
               '-r',str(fps),
               filename]

    try:
        subprocess_call( cmd, verbose = verbose )
        verbose_print(verbose, "[MoviePy] GIF %s is ready."%filename)

    except (IOError,OSError) as err:

        error = ("MoviePy Error: creation of %s failed because "
          "of the following error:\n\n%s.\n\n."%(filename, str(err)))

        if program == "ImageMagick":
            error = error + ("This error can be due to the fact that "
                "ImageMagick is not installed on your computer, or "
                "(for Windows users) that you didn't specify the "
                "path to the ImageMagick binary in file conf.py." )

        raise IOError(error)

    for f in tempfiles:
        os.remove(f)
开发者ID:mgaitan,项目名称:moviepy,代码行数:72,代码来源:gif_writers.py


示例18: ffmpeg_extract_audio

def ffmpeg_extract_audio(inputfile,output,bitrate=3000,fps=44100):
    """ extract the sound from a video file and save it in ``output`` """
    cmd = ["ffmpeg", "-y", "-i", inputfile, "-ab", "%dk"%bitrate,
         "-ar", "%d"%fps, output]
    subprocess_call(cmd, stdin=None, stdout=None)
开发者ID:bihicheng,项目名称:moviepy,代码行数:5,代码来源:ffmpeg_tools.py


示例19: ffmpeg_extract_audio

def ffmpeg_extract_audio(inputfile,output,bitrate=3000,fps=44100):
    """ extract the sound from a video file and save it in ``output`` """
    cmd = [get_setting("FFMPEG_BINARY"), "-y", "-i", inputfile, "-ab", "%dk"%bitrate,
         "-ar", "%d"%fps, output]
    subprocess_call(cmd)
开发者ID:Zulko,项目名称:moviepy,代码行数:5,代码来源:ffmpeg_tools.py



注:本文中的moviepy.tools.subprocess_call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python VideoClip.VideoClip类代码示例发布时间:2022-05-27
下一篇:
Python editor.VideoFileClip类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap