{"id":1804,"date":"2024-09-17T22:09:17","date_gmt":"2024-09-17T13:09:17","guid":{"rendered":"https:\/\/www.typea.info\/blog\/?p=1804"},"modified":"2024-09-17T22:09:17","modified_gmt":"2024-09-17T13:09:17","slug":"movie_telop_moviepy","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2024\/09\/17\/movie_telop_moviepy\/","title":{"rendered":"moviepy\u3067\u52d5\u753b\u306b\u30c6\u30ed\u30c3\u30d7\u3092\u633f\u5165"},"content":{"rendered":"<p>\u8af8\u822c\u306e\u4e8b\u60c5\u306b\u3088\u308a\u52d5\u753b\u306b\u30c6\u30ed\u30c3\u30d7\u3092\u5165\u308c\u308b\u4f9d\u983c\u3092\u53d7\u3051\u308b\u3002<\/p>\n<p>\u6700\u521d\u3001\u52d5\u753b\u7de8\u96c6 \u30bd\u30d5\u30c8\u3092RPA(\u30de\u30af\u30ed\u30de\u30f3)\u3067\u64cd\u4f5c\u3057\u3066\u4f5c\u696d\u3092\u8a66\u307f\u308b\u3082\u3001\u96e3\u3057\u3059\u304e\u3066\u8ae6\u3081\u305f\u3002<\/p>\n<p>moviepy\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u884c\u3051\u305d\u3046\u3060\u3051\u3069\u3001\u5b9f\u969b\u3044\u304f\u3064\u304b\u30cf\u30de\u308a\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u306e\u3067\u30e1\u30e2\u306b\u6b8b\u3057\u3066\u304a\u304f\u3002<\/p>\n<h2>\u5b9f\u88c5\u30b3\u30fc\u30c9<\/h2>\n<pre class=\"prettyprint\">from moviepy.editor import *\nimport os\n\n# windows \u3067\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u5834\u5408\u306e\u5bfe\u51e6\n# .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\nfrom moviepy.config import change_settings\nchange_settings({\"IMAGEMAGICK_BINARY\": r\"C:\\Programs\\ImageMagick-7.1.1-38-portable-Q16-x64\\magick.exe\"})\n\ndef add_telop(in_path, out_path):\n\n    os.makedirs(out_path, exist_ok=True)    \n    # \u65e5\u672c\u8a9e\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u5834\u5408\u306e\u5bfe\u51e6\n    # \u30d5\u30a9\u30f3\u30c8\u3092\u5217\u6319-&gt;\u65e5\u672c\u8a9e\u304c\u4f7f\u3048\u308b\u30d5\u30a9\u30f3\u30c8\u3092\u63a2\u3059\n    print(TextClip.list(\"font\"))\n\n    fos = os.listdir(in_path)\n    for fo in fos:\n        __add_telop(out_path, os.path.join(in_path,fo))\n\ndef __add_telop(out_path, movie_file):\n    movie_path = filename=os.path.abspath(movie_file)\n    out_movie = os.path.abspath(os.path.join(out_path, os.path.basename(movie_path)))\n\n    clip = VideoFileClip(movie_path)\n    txt_clip = TextClip(\n        txt=\"\u9023\u7d61\u5148 052-XXX-XXXXX\", \n        fontsize=20, \n        color='black', \n        font=\"HG\u4e38\uff7a\uff9e\uff7c\uff6f\uff78M-PRO\")           # Windows\u3067\u9069\u5f53\u306b\u65e5\u672c\u8a9e\u304c\u4f7f\u3048\u308b\u30d5\u30a9\u30f3\u30c8\n        # font=\"\u30d2\u30e9\u30ae\u30ce\u660e\u671d-Pro-W3\")     # Mac\u3067\u9069\u5f53\u306b\u65e5\u672c\u8a9e\u304c\u4f7f\u3048\u308b\u30d5\u30a9\u30f3\u30c8\n        \n    txt_clip = txt_clip.set_position((\"right\",\"top\")) #\u3000\u53f3\u4e0a\u306b\n    txt_clip = txt_clip.set_duration(15) # 15\u79d2\u9593\n    txt_clip = txt_clip.set_start(1) #\u3000\uff11\u79d2\u5f8c\u304b\u3089\n\n    video = CompositeVideoClip([clip, txt_clip]) #\u30c6\u30ad\u30b9\u30c8\u3068\u6620\u50cf\u3092\u5408\u6210\n\n    video.write_videofile(filename=out_movie, audio=True, audio_codec='aac')\n\nif __name__ == \"__main__\":\n    add_telop(\".\/movies\", \".\/out\")\n\n<\/pre>\n<h2>\u5bfe\u51e6\u306a\u3069<\/h2>\n<h3>1.moviepy<\/h3>\n<p>\u305d\u3082\u305d\u3082\u306emoviepy\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<p>https:\/\/pypi.org\/project\/moviepy\/<\/p>\n<pre class=\"prettyprint\">pip install moviepy\n<\/pre>\n<h3>2.FFMPEG\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044<\/h3>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u308b<\/p>\n<p>RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.<\/p>\n<p><a href=\"https:\/\/www.ffmpeg.org\/\">https:\/\/www.ffmpeg.org\/<\/a><\/p>\n<h4>2.1\u3000Mac : ffmpeg\u3092brew\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n<pre class=\"prettyprint\">$ brew install ffmpeg\n<\/pre>\n<h4>2.2\u3000Windows : ffmpeg\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066PATH\u3092\u901a\u3059<\/h4>\n<p><a href=\"https:\/\/ffmpeg.org\/\">https:\/\/ffmpeg.org\/<\/a><br \/><a href=\"https:\/\/github.com\/BtbN\/FFmpeg-Builds\/releases\">https:\/\/github.com\/BtbN\/FFmpeg-Builds\/releases<\/a><\/p>\n<p>ffmpeg-master-latest-win64-gpl-shared.zip<\/p>\n<p>PATH\u306b\u8ffd\u52a0\u4f8b<\/p>\n<pre class=\"prettyprint\">C:\\Programs\\ffmpeg-master-latest-win64-gpl-shared\\bin<\/pre>\n<p>\u78ba\u8a8d<\/p>\n<pre class=\"prettyprint\">ffmpeg -version<\/pre>\n<p>\u00a0<\/p>\n<h3>3.ImageMagick\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044<\/h3>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u308b<\/p>\n<p>.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn\u2019t specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect<\/p>\n<h4>2.1\u3000Mac : imagemagick\u3092brew\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n<pre class=\"prettyprint\">$ brew install imagemagick\n<\/pre>\n<h4>2.2\u3000Windows : ffmpeg\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066PATH\u3092\u901a\u3057\u3001\u30b3\u30fc\u30c9\u3067\u6307\u5b9a<\/h4>\n<p><a href=\"https:\/\/imagemagick.org\/script\/download.php\">https:\/\/imagemagick.org\/script\/download.php<br \/>\n<\/a><\/p>\n<p><a href=\"https:\/\/higuma.github.io\/2016\/08\/31\/imagemagick\u20131\/\">https:\/\/higuma.github.io\/2016\/08\/31\/imagemagick\u20131\/<\/a><\/p>\n<p>ImageMagick\u20137.1.1\u201338-portable-Q16-x64.zip<\/p>\n<p>.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn&#8217;t specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect<\/p>\n<p>\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u5834\u5408\u3001\u30b3\u30fc\u30c9\u3067\u5834\u6240\u3092\u6307\u5b9a<\/p>\n<pre class=\"prettyprint\">from moviepy.config import change_settings\nchange_settings({\"IMAGEMAGICK_BINARY\": r\"C:\\Programs\\ImageMagick-7.1.1-38-portable-Q16-x64\\magick.exe\"})<\/pre>\n<h3>4.\u65e5\u672c\u8a9e\u304c\u51fa\u529b\u3067\u304d\u306a\u3044<\/h3>\n<p>\u74b0\u5883\u306b\u3088\u3063\u3066\u4f7f\u3048\u308b\u30d5\u30a9\u30f3\u30c8\u3092\u5217\u6319\u3057\u3066\u3001\u660e\u793a\u3059\u308b<\/p>\n<pre class=\"prettyprint\">print(TextClip.list(\"font\"))<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8af8\u822c\u306e\u4e8b\u60c5\u306b\u3088\u308a\u52d5\u753b\u306b\u30c6\u30ed\u30c3\u30d7\u3092\u5165\u308c\u308b\u4f9d\u983c\u3092\u53d7\u3051\u308b\u3002 \u6700\u521d\u3001\u52d5\u753b\u7de8\u96c6 \u30bd\u30d5\u30c8\u3092RPA(\u30de\u30af\u30ed\u30de\u30f3)\u3067\u64cd\u4f5c\u3057\u3066\u4f5c\u696d\u3092\u8a66\u307f\u308b\u3082\u3001\u96e3\u3057\u3059\u304e\u3066\u8ae6\u3081\u305f\u3002 moviepy\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u884c\u3051\u305d\u3046\u3060\u3051\u3069\u3001\u5b9f\u969b\u3044\u304f\u3064\u304b\u30cf\u30de\u308a\u30dd\u30a4\u30f3\u30c8\u304c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1803,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[20],"tags":[214,213],"class_list":["post-1804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-moviepy","tag-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1804"}],"version-history":[{"count":1,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1804\/revisions"}],"predecessor-version":[{"id":1805,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1804\/revisions\/1805"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media\/1803"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}