How to create a video from images?
up vote
0
down vote
favorite
I have an algorithm, which after each iteration creates a matrix. After some operations on matrix it is plotted to the user. if I run program 6 times I will get:
My goal is to changing image dynamically, like a movie.
I have no idea from which side to start. I found some ways of creating video from images in python and then wrap it in the video player. But it seems to be a bit complicated and it is impossible to see the changes while algorithm is working. Are there any suggestions how to do it?
python image matrix video cv2
add a comment |
up vote
0
down vote
favorite
I have an algorithm, which after each iteration creates a matrix. After some operations on matrix it is plotted to the user. if I run program 6 times I will get:
My goal is to changing image dynamically, like a movie.
I have no idea from which side to start. I found some ways of creating video from images in python and then wrap it in the video player. But it seems to be a bit complicated and it is impossible to see the changes while algorithm is working. Are there any suggestions how to do it?
python image matrix video cv2
1
you might want to take a look at this question
– Kevin He
Nov 8 at 19:17
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an algorithm, which after each iteration creates a matrix. After some operations on matrix it is plotted to the user. if I run program 6 times I will get:
My goal is to changing image dynamically, like a movie.
I have no idea from which side to start. I found some ways of creating video from images in python and then wrap it in the video player. But it seems to be a bit complicated and it is impossible to see the changes while algorithm is working. Are there any suggestions how to do it?
python image matrix video cv2
I have an algorithm, which after each iteration creates a matrix. After some operations on matrix it is plotted to the user. if I run program 6 times I will get:
My goal is to changing image dynamically, like a movie.
I have no idea from which side to start. I found some ways of creating video from images in python and then wrap it in the video player. But it seems to be a bit complicated and it is impossible to see the changes while algorithm is working. Are there any suggestions how to do it?
python image matrix video cv2
python image matrix video cv2
edited Nov 8 at 19:39


martineau
64.5k887172
64.5k887172
asked Nov 8 at 18:44
Sergey Vladimirovich
94110
94110
1
you might want to take a look at this question
– Kevin He
Nov 8 at 19:17
add a comment |
1
you might want to take a look at this question
– Kevin He
Nov 8 at 19:17
1
1
you might want to take a look at this question
– Kevin He
Nov 8 at 19:17
you might want to take a look at this question
– Kevin He
Nov 8 at 19:17
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You can use FFMPEG
def convert():
os.system("ffmpeg -r 1 -i img%01d.png -vcodec mpeg4 -y movie.mp4")
Alternatively, you can use ImageIO to generate a GIF. You can set the parameters for duration of each frame.
import imageio
with imageio.get_writer('/path_to_video.gif', mode='I') as writer:
for filename in filenames:
image = imageio.imread(filename)
writer.append_data(image)
Read the manual on website for more detailed instructions.
Or with cv2,
import cv2
img1 = cv2.imread('1.jpg')
img2 = cv2.imread('2.jpg')
img3 = cv2.imread('3.jpg')
height , width , layers = img1.shape
video = cv2.VideoWriter('video.avi',-1,1,(width,height))
video.write(img1)
video.write(img2)
video.write(img3)
cv2.destroyAllWindows()
video.release()
1
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can use FFMPEG
def convert():
os.system("ffmpeg -r 1 -i img%01d.png -vcodec mpeg4 -y movie.mp4")
Alternatively, you can use ImageIO to generate a GIF. You can set the parameters for duration of each frame.
import imageio
with imageio.get_writer('/path_to_video.gif', mode='I') as writer:
for filename in filenames:
image = imageio.imread(filename)
writer.append_data(image)
Read the manual on website for more detailed instructions.
Or with cv2,
import cv2
img1 = cv2.imread('1.jpg')
img2 = cv2.imread('2.jpg')
img3 = cv2.imread('3.jpg')
height , width , layers = img1.shape
video = cv2.VideoWriter('video.avi',-1,1,(width,height))
video.write(img1)
video.write(img2)
video.write(img3)
cv2.destroyAllWindows()
video.release()
1
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
add a comment |
up vote
2
down vote
accepted
You can use FFMPEG
def convert():
os.system("ffmpeg -r 1 -i img%01d.png -vcodec mpeg4 -y movie.mp4")
Alternatively, you can use ImageIO to generate a GIF. You can set the parameters for duration of each frame.
import imageio
with imageio.get_writer('/path_to_video.gif', mode='I') as writer:
for filename in filenames:
image = imageio.imread(filename)
writer.append_data(image)
Read the manual on website for more detailed instructions.
Or with cv2,
import cv2
img1 = cv2.imread('1.jpg')
img2 = cv2.imread('2.jpg')
img3 = cv2.imread('3.jpg')
height , width , layers = img1.shape
video = cv2.VideoWriter('video.avi',-1,1,(width,height))
video.write(img1)
video.write(img2)
video.write(img3)
cv2.destroyAllWindows()
video.release()
1
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can use FFMPEG
def convert():
os.system("ffmpeg -r 1 -i img%01d.png -vcodec mpeg4 -y movie.mp4")
Alternatively, you can use ImageIO to generate a GIF. You can set the parameters for duration of each frame.
import imageio
with imageio.get_writer('/path_to_video.gif', mode='I') as writer:
for filename in filenames:
image = imageio.imread(filename)
writer.append_data(image)
Read the manual on website for more detailed instructions.
Or with cv2,
import cv2
img1 = cv2.imread('1.jpg')
img2 = cv2.imread('2.jpg')
img3 = cv2.imread('3.jpg')
height , width , layers = img1.shape
video = cv2.VideoWriter('video.avi',-1,1,(width,height))
video.write(img1)
video.write(img2)
video.write(img3)
cv2.destroyAllWindows()
video.release()
You can use FFMPEG
def convert():
os.system("ffmpeg -r 1 -i img%01d.png -vcodec mpeg4 -y movie.mp4")
Alternatively, you can use ImageIO to generate a GIF. You can set the parameters for duration of each frame.
import imageio
with imageio.get_writer('/path_to_video.gif', mode='I') as writer:
for filename in filenames:
image = imageio.imread(filename)
writer.append_data(image)
Read the manual on website for more detailed instructions.
Or with cv2,
import cv2
img1 = cv2.imread('1.jpg')
img2 = cv2.imread('2.jpg')
img3 = cv2.imread('3.jpg')
height , width , layers = img1.shape
video = cv2.VideoWriter('video.avi',-1,1,(width,height))
video.write(img1)
video.write(img2)
video.write(img3)
cv2.destroyAllWindows()
video.release()
answered Nov 8 at 19:17


Aravind Voggu
751413
751413
1
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
add a comment |
1
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
1
1
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
Thanks! I also found another way of dinamically representation of images: matplotlib.org/2.1.2/gallery/animation/image_slices_viewer.html
– Sergey Vladimirovich
Nov 9 at 10:12
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214221%2fhow-to-create-a-video-from-images%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
you might want to take a look at this question
– Kevin He
Nov 8 at 19:17