首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

MoviePy-中文文档-5.使用Docker镜像快速搭建moviepy环境

  • 23-09-22 20:23
  • 3313
  • 11530
blog.csdn.net

回到目录

使用Docker镜像快速搭建moviepy环境

前言:之前有不少同学说搭建moviepy环境失败了,大部分是卡在ffmpeg自动下载的步骤了,原因在于从国外下载ffmpeg。当然有办法解决:可以手动下载,然后放在~/.imageio/ffmpeg目录下。

  1. ucsheep@ucsheep-B250M-D2V:~/.imageio/ffmpeg$ ll
  2. 总用量 44864
  3. drwxrwxr-x 2 ucsheep ucsheep 4096 8月 21 10:44 ./
  4. drwxrwxr-x 3 ucsheep ucsheep 4096 8月 14 08:54 ../
  5. -rwxrw-r-- 1 ucsheep ucsheep 45929032 8月 21 10:44 ffmpeg-linux64-v3.3.1*

但是,其实我这边最开始就直接使用的是moviepy的docker镜像,很方便。也不会遇到上述的情况。那么,在那里可以买的到呢?

有两种办法,一种是通过Dockerfile构建,一种是直接在Docker Hub寻找有么有现成的镜像。

注意:进行以下操作的首要前提是,您的电脑已经安装Docker

1.Docker Hub拉取镜像

首先,查找镜像

  1. ucsheep@ucsheep-B250M-D2V:~$ docker search moviepy
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. dkarchmervue/moviepy Image for moviepy, with latest Python 3.4, l… 1 [OK]
  4. jdauphant/moviepy 0 [OK]
  5. mentlsve/anaconda3-opencv-moviepy Anaconda3 (Python 3.5) with opencv and movie… 0
  6. srid/moviepy 0 [OK]
  7. mbeacom/moviepy 0
  8. jacquesvdm/moviepy Image that contains PHP and MoviePy 0
  9. hongyusir/python-moviepy docker image with python, pil and moviepy in… 0
  10. ib5k/moviepy 0
  11. screencom/moviepy 0
  12. verynb/moviepy 0
  13. hongyusir/mnpp mongo, nodejs and python together, and with … 0
  14. lucasrodesg/deepo Modified from ufoym/deepo. Incorporates pyth… 0

然后,选择第一个,拉取镜像,创建一个容器

  1. ucsheep@ucsheep-B250M-D2V:~$ docker run -idt --name moviepy-test dkarchmervue/moviepy
  2. 4e4afde5a3702171ac345f924f4a40596fb081f20cf6984544c0b7855d5585b7

查看容器运行情况

  1. ucsheep@ucsheep-B250M-D2V:~$ docker ps -a
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. 4e4afde5a370 dkarchmervue/moviepy "/bin/bash" About a minute ago Up About a minute moviepy-test

进入容器,看看moviepy环境是否可用

  1. ucsheep@ucsheep-B250M-D2V:~$ docker attach moviepy-test
  2. root@4e4afde5a370:/work#
  3. root@4e4afde5a370:/work# python3
  4. Python 3.4.4 (default, May 25 2016, 06:34:52)
  5. [GCC 4.8.4] on linux
  6. Type "help", "copyright", "credits" or "license" for more information.
  7. >>> import moviepy
  8. >>>

没有报错,大功告成。可以将开发目录挂载到容器中的work目录,方便运行。

Dockerfile构建

首先,clone MoviePy源码

ucsheep@ucsheep-B250M-D2V:~/git-projects$ git clone https://github.com/Zulko/moviepy.git

查看,看到了Dockerfile

  1. ucsheep@ucsheep-B250M-D2V:~/git-projects$ cd moviepy/
  2. ucsheep@ucsheep-B250M-D2V:~/git-projects/moviepy$ ls
  3. appveyor CONTRIBUTING.md examples MANIFEST.in setup.py
  4. appveyor.yml Dockerfile ez_setup.py moviepy tests
  5. CHANGELOG.md docs LICENCE.txt README.rst

Dockerfile的内容如下

  1. FROM python:3
  2. # Install numpy using system package manager
  3. RUN apt-get -y update && apt-get -y install libav-tools imagemagick libopencv-dev python-opencv
  4. # Install some special fonts we use in testing, etc..
  5. RUN apt-get -y install fonts-liberation
  6. RUN apt-get install -y locales &&
  7. locale-gen C.UTF-8 &&
  8. /usr/sbin/update-locale LANG=C.UTF-8
  9. ENV LC_ALL C.UTF-8
  10. # do we need all of these, maybe remove some of them?
  11. RUN pip install imageio numpy scipy matplotlib pandas sympy nose decorator tqdm pillow pytest requests
  12. # install scikit-image after the other deps, it doesn't cause errors this way.
  13. RUN pip install scikit-image sklearn
  14. ADD . /var/src/moviepy/
  15. #RUN git clone https://github.com/Zulko/moviepy.git /var/src/moviepy
  16. RUN cd /var/src/moviepy/ && python setup.py install
  17. # install ffmpeg from imageio.
  18. RUN python -c "import imageio; imageio.plugins.ffmpeg.download()"
  19. #add soft link so that ffmpeg can executed (like usual) from command line
  20. RUN ln -s /root/.imageio/ffmpeg/ffmpeg.linux64 /usr/bin/ffmpeg
  21. # modify ImageMagick policy file so that Textclips work correctly.
  22. RUN cat /etc/ImageMagick-6/policy.xml | sed 's/none/read,write/g'> /etc/ImageMagick-6/policy.xml

就是在Python3的基础上,搭建量MoviePy的运行环境

那么,接下来,开始构建

  1. ucsheep@ucsheep-B250M-D2V:~/git-projects/moviepy$ docker build -t moviepy -f Dockerfile .
  2. Sending build context to Docker daemon 7.115MB
  3. Step 1/12 : FROM python:3
  4. ---> 825141134528
  5. Step 2/12 : RUN apt-get -y update && apt-get -y install libav-tools imagemagick libopencv-dev python-opencv
  6. ---> Running in b09eb178cc0a
  7. Ign:1 http://deb.debian.org/debian stretch InRelease
  8. Get:2 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
  9. Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
  10. Get:4 http://deb.debian.org/debian stretch Release [118 kB]
  11. Get:5 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [437 kB]
  12. Get:6 http://deb.debian.org/debian stretch-updates/main amd64 Packages [5148 B]
  13. Get:7 http://deb.debian.org/debian stretch Release.gpg [2434 B]
  14. Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [7099 kB]

最终执行到Step 12/12后会构建完毕

接下来,可以运行容器,测试moviepy给出的示例代码:

  1. ucsheep@ucsheep-B250M-D2V:~/git-projects/moviepy$ cd tests/
  2. ucsheep@ucsheep-B250M-D2V:~/git-projects/moviepy/tests$ ls
  3. download_media.py test_fx.py test_resourcerelease.py
  4. __init__.py test_helper.py test_TextClip.py
  5. README.rst test_ImageSequenceClip.py test_tools.py
  6. test_AudioClips.py test_issues.py test_VideoClip.py
  7. test_compositing.py test_misc.py test_VideoFileClip.py
  8. test_examples.py test_PR.py test_Videos.py
  9. test_ffmpeg_reader.py test_resourcereleasedemo.py test_videotools.py
  10. ucsheep@ucsheep-B250M-D2V:~/git-projects/moviepy/tests$ docker run -it -v `pwd`:/tests moviepy bash

 

一起交流,一起进步,群内提问答疑

QQ群:MoviePy中文 :819718037

回到目录

 

 

 

文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树首页概览333612 人正在系统学习中
注:本文转载自blog.csdn.net的ucsheep的文章"https://blog.csdn.net/ucsheep/article/details/82772980"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2492) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

101
推荐
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2024 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top