-
Notifications
You must be signed in to change notification settings - Fork 25
/
images_to_video.html
103 lines (93 loc) · 4.36 KB
/
images_to_video.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<script type="text/javascript">var blog_title = "Making videos from images";</script>
<script type="text/javascript">var publication_date = "September 28, 2018";</script>
<head>
<link rel="icon" href="images/ml_logo.png">
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<base target="_blank">
<script type="text/javascript" src="javascripts/blog_head.js"></script>
</head>
<body>
<script type="text/javascript" src="javascripts/blog_header.js"></script>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h3>You can stitch images into a movie</h3>
<code>ffmpeg -pattern_type glob -i '*.png' -y -c:v libx264 movie_name.mp4</code>
<h3>Or break a movie's frames out into images</h3>
<code>ffmpeg -i movie_name.mp4 img_%05d.png</code>
<br>
<br>
<p>
<img src="images/im_to_video_before_0.png" style="height: 150px;" />
<img src="images/im_to_video_before_1.png" style="height: 150px;" />
<img src="images/im_to_video_before_2.png" style="height: 150px;" />
<img src="images/im_to_video_before_3.png" style="height: 150px;" />
</p>
<br>
<p>
Video is a natural way for us to understand three dimensional and time varying information.
It's how we navigate the world.
Converting images to video is a great way to level up your data science results.
It helps you to communicate more clearly and it gives you eye-catching GIFs in the process.
</p>
<p>
You can go the other direction too and convert video to a sequence of images.
This is helpful if you want to do frame-by-frame analysis on video
in machine learning applications.
</p>
<h4>Prerequisites</h4>
<ul>
<li>
<a href="https://ffmpeg.org/download.html">Install FFmpeg</a>.
It's a powerful open source audio video processing tool.
It has a dizzying collection of cryptic command line options, so when you settle on the one
that meets your needs, it's very much a Wingardium Leviosa moment.
It's available on Linux, MacOS, and Windows.
</li>
<li>
Make sure all the images are the same size - that they have the same number of pixel rows and columns.
</li>
<li>
Put all the <code>.png</code> images you want to use as video frames into a directory by themselves.
</li>
</ul>
<p>
Images are ordered alphabetically by filename and stitched together to make your video.
<p>
<p>
For the adventurous, you can exercize absolute control over every step of this process.
Want to change the frame rate?
Use a different video filetype? Add music? Just read through
<a href="https://ffmpeg.org/ffmpeg.html">the FFmpeg documentation</a>.
</p>
<h4>You can help keep open source open</h4>
<p>
If this solution works for you, consider
<a href="https://ffmpeg.org/donations.html">sending support to the FFmpeg project</a>.
Maybe enough to buy a cup of coffee. Or a coffee machine. It goes toward keeping their servers running.
All the human work that goes into it is donated.
</p>
<p>
Good luck in your video production!
</p>
<script type="text/javascript" src="javascripts/blog_signature.js"></script>
</section>
</div>
<script type="text/javascript" src="javascripts/blog_footer.js"></script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10180621-3");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>