pipeline.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:eclipse2017 作者: google 项目源码 文件源码
def assemble(self, fnames):
        """
        Stitches together movies from an ordered list of filenames.
        Downloads new files from GCS then feeds files to ffmpeg.
        Returns list of files sucessfully stitched into movie & calls stats func
        """

        # Get files from GCS
        pool = Pool(min(len(fnames), constants.MOVIE_DAEMON_MAX_PROCESSES))
        results = pool.map(get_file_from_gcs, fnames)
        pool.terminate()

        # Start ffmpeg subprocess
        ffmpeg_cmd = ["ffmpeg","-y",        # Overwrite exsisting movie file
                    "-f", "image2pipe",
                    "-framerate", constants.MOVIE_FRAMERATE,
                    "-vcodec","mjpeg",
                    "-i", "-",              # Input pipe from stdin
                    "-vf", "scale=1024:-1",
                    "-loglevel", "panic",
                    "-vcodec", "libx264",
                    constants.MOVIE_FPATH]

        ffmpeg_ps = subprocess.Popen(ffmpeg_cmd, stdin=subprocess.PIPE)


        fnames = list(compress(fnames, results))
        files_read = self._pipe_to_ffmpeg(ffmpeg_ps, fnames)

        if files_read > constants.MOVIE_MIN_FRAMES:
            ffmpeg_ps.stdin.close()
            ffmpeg_ps.wait()
        else:
            ffmpeg_ps.kill()

        return fnames
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号