{"id":3790,"date":"2023-01-16T12:14:06","date_gmt":"2023-01-16T07:14:06","guid":{"rendered":"https:\/\/www.edopedia.com\/blog\/?p=3790"},"modified":"2023-01-16T12:38:36","modified_gmt":"2023-01-16T07:38:36","slug":"how-to-combine-images-and-create-video-using-python-opencv","status":"publish","type":"post","link":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/","title":{"rendered":"How to Combine Images and Create Video Using Python &amp; OpenCV"},"content":{"rendered":"\n<p>Do you want to make your own <strong>text-to-video<\/strong> or <strong>images-to-video<\/strong> generator tool?<\/p>\n\n\n\n<p>Flickify is an excellent example that utilizes the concept of <strong>text-to-video<\/strong> and <strong>images-to-video<\/strong> tools. So, if you are interested in making a similar tool then this tutorial is for you.<\/p>\n\n\n\n<p><strong>Note:<\/strong> <em>If you&#8217;re not familiar with Flickify then I&#8217;ll explain it to you. Basically, it is an online tool that <strong>converts articles\/blog posts into videos<\/strong>. Flickify is part of Ezoic (a <strong>Google Adsense<\/strong> alternative for publishers to Increase Earnings, Improve Performance, &amp; Grow Website Traffic Faster). <strong>You need a <a href=\"https:\/\/ezoic.com\/?tap_a=6182-5778c2&amp;tap_s=2640219-b01bfc\">free Ezoic account<\/a> to try Flickify<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"493\" src=\"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/scrnli_1_16_2023_11-50-47-AM-1024x493.png\" alt=\"Flickify Article to Video Converter Tool\" class=\"wp-image-3794\" srcset=\"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/scrnli_1_16_2023_11-50-47-AM-1024x493.png 1024w, https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/scrnli_1_16_2023_11-50-47-AM-300x144.png 300w, https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/scrnli_1_16_2023_11-50-47-AM-768x369.png 768w, https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/scrnli_1_16_2023_11-50-47-AM.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Flickify Article to Video Converter Tool<\/figcaption><\/figure>\n\n\n\n<p><strong>Anyways, In this tutorial, I&#8217;ll use Python 3 and OpenCV 3 to select all the images available in a specified folder and then combine them into an MP4 video.<\/strong><\/p>\n\n\n\n<p>The source code of <strong>image to video converter tool<\/strong> is written in a very simple and easy manner. So, that even beginner Python developers can understand and use it in their projects.<\/p>\n\n\n\n<p>So, let&#8217;s have a look at the <strong>Python source code of images to video converter<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Image to Video Converter Tool Source Code<\/h2>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">#!\/usr\/local\/bin\/python3\n\nimport cv2\nimport argparse\nimport os\n\n# Construct the argument parser and parse the arguments\nap = argparse.ArgumentParser()\nap.add_argument(&quot;-ext&quot;, &quot;--extension&quot;, required=False, default='png', help=&quot;extension name. default is 'png'.&quot;)\nap.add_argument(&quot;-o&quot;, &quot;--output&quot;, required=False, default='output.mp4', help=&quot;output video file&quot;)\nargs = vars(ap.parse_args())\n\n# Arguments\ndir_path = '.'\next = args['extension']\noutput = args['output']\n\nimages = []\nfor f in os.listdir(dir_path):\n    if f.endswith(ext):\n        images.append(f)\n\n# Determine the width and height from the first image\nimage_path = os.path.join(dir_path, images[0])\nframe = cv2.imread(image_path)\ncv2.imshow('video',frame)\nheight, width, channels = frame.shape\n\n# Define the codec and create VideoWriter object\nfourcc = cv2.VideoWriter_fourcc(*'mp4v') # Be sure to use lower case\nout = cv2.VideoWriter(output, fourcc, 20.0, (width, height))\n\nfor image in images:\n\n    image_path = os.path.join(dir_path, image)\n    frame = cv2.imread(image_path)\n\n    out.write(frame) # Write out frame to video\n\n    cv2.imshow('video',frame)\n    if (cv2.waitKey(1) &amp; 0xFF) == ord('q'): # Hit `q` to exit\n        break\n\n# Release everything if job is finished\nout.release()\ncv2.destroyAllWindows()\n\nprint(&quot;The output video is {}&quot;.format(output))<\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Final Words<\/h2>\n\n\n\n<p>I think this code is very self-explanatory. Still, I&#8217;ve added a few comments to help you understand what&#8217;s going on.<\/p>\n\n\n\n<p>If you have any questions regarding this images to video converter tool then let me know in the comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you want to make your own text-to-video or images-to-video generator tool? Flickify is an excellent example that utilizes the concept of text-to-video and images-to-video tools. So, if you are interested in making a similar tool then this tutorial is for you. Note: If you&#8217;re not familiar with Flickify then I&#8217;ll explain it to you. &#8230; <a title=\"How to Combine Images and Create Video Using Python &amp; OpenCV\" class=\"read-more\" href=\"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/\" aria-label=\"Read more about How to Combine Images and Create Video Using Python &amp; OpenCV\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":3800,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[],"class_list":["post-3790","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Combine Images and Create Video Using Python &amp; OpenCV<\/title>\n<meta name=\"description\" content=\"Do you want to make your own text-to-video or images-to-video generator tool? Flickify is an excellent example that utilizes the concept of text-to-video\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Combine Images and Create Video Using Python &amp; OpenCV\" \/>\n<meta property=\"og:description\" content=\"Do you want to make your own text-to-video or images-to-video generator tool? Flickify is an excellent example that utilizes the concept of text-to-video\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/\" \/>\n<meta property=\"og:site_name\" content=\"Edopedia\" \/>\n<meta property=\"article:author\" content=\"trulyfurqan\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-16T07:14:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-16T07:38:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/Combine_Images_and_Create_Video_Using_Python_OpenCV.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"880\" \/>\n\t<meta property=\"og:image:height\" content=\"495\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Furqan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Furqan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Combine Images and Create Video Using Python &amp; OpenCV","description":"Do you want to make your own text-to-video or images-to-video generator tool? Flickify is an excellent example that utilizes the concept of text-to-video","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/","og_locale":"en_US","og_type":"article","og_title":"How to Combine Images and Create Video Using Python &amp; OpenCV","og_description":"Do you want to make your own text-to-video or images-to-video generator tool? Flickify is an excellent example that utilizes the concept of text-to-video","og_url":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/","og_site_name":"Edopedia","article_author":"trulyfurqan","article_published_time":"2023-01-16T07:14:06+00:00","article_modified_time":"2023-01-16T07:38:36+00:00","og_image":[{"width":880,"height":495,"url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/Combine_Images_and_Create_Video_Using_Python_OpenCV.jpg","type":"image\/jpeg"}],"author":"Furqan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Furqan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#article","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/"},"author":{"name":"Furqan","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339"},"headline":"How to Combine Images and Create Video Using Python &amp; OpenCV","datePublished":"2023-01-16T07:14:06+00:00","dateModified":"2023-01-16T07:38:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/"},"wordCount":238,"commentCount":0,"publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/Combine_Images_and_Create_Video_Using_Python_OpenCV.jpg","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/","url":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/","name":"How to Combine Images and Create Video Using Python &amp; OpenCV","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#primaryimage"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/Combine_Images_and_Create_Video_Using_Python_OpenCV.jpg","datePublished":"2023-01-16T07:14:06+00:00","dateModified":"2023-01-16T07:38:36+00:00","description":"Do you want to make your own text-to-video or images-to-video generator tool? Flickify is an excellent example that utilizes the concept of text-to-video","breadcrumb":{"@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#primaryimage","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/Combine_Images_and_Create_Video_Using_Python_OpenCV.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2023\/01\/Combine_Images_and_Create_Video_Using_Python_OpenCV.jpg","width":880,"height":495,"caption":"How to Combine Images and Create Video Using Python & OpenCV"},{"@type":"BreadcrumbList","@id":"https:\/\/www.edopedia.com\/blog\/how-to-combine-images-and-create-video-using-python-opencv\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.edopedia.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Combine Images and Create Video Using Python &amp; OpenCV"}]},{"@type":"WebSite","@id":"https:\/\/www.edopedia.com\/blog\/#website","url":"https:\/\/www.edopedia.com\/blog\/","name":"Edopedia","description":"Coding\/Programming Blog","publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.edopedia.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.edopedia.com\/blog\/#organization","name":"Edopedia","url":"https:\/\/www.edopedia.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","width":400,"height":100,"caption":"Edopedia"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339","name":"Furqan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","caption":"Furqan"},"description":"Well. I've been working for the past three years as a web designer and developer. I have successfully created websites for small to medium sized companies as part of my freelance career. During that time I've also completed my bachelor's in Information Technology.","sameAs":["http:\/\/www.edopedia.com\/blog\/","trulyfurqan"],"url":"https:\/\/www.edopedia.com\/blog\/author\/furqan\/"}]}},"_links":{"self":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/3790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/comments?post=3790"}],"version-history":[{"count":7,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/3790\/revisions"}],"predecessor-version":[{"id":3799,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/3790\/revisions\/3799"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media\/3800"}],"wp:attachment":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media?parent=3790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/categories?post=3790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/tags?post=3790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}