How can I make a video from array of images in matplotlib?

For a future myself, here is what I ended up with: def generate_video(img): for i in xrange(len(img)): plt.imshow(img[i], cmap=cm.Greys_r) plt.savefig(folder + “/file%02d.png” % i) os.chdir(“your_folder”) subprocess.call([ ‘ffmpeg’, ‘-framerate’, ‘8’, ‘-i’, ‘file%02d.png’, ‘-r’, ’30’, ‘-pix_fmt’, ‘yuv420p’, ‘video_name.mp4’ ]) for file_name in glob.glob(“*.png”): os.remove(file_name)

FFmpeg – Overlay one video onto another video?

If you just want a ffmpeg command, try ffmpeg -i input.mov -i overlay.mov \ -filter_complex “[1:v]setpts=PTS-10/TB[a]; \ [0:v][a]overlay=enable=gte(t\,5):shortest=1[out]” \ -map [out] -map 0:a \ -c:v libx264 -crf 18 -pix_fmt yuv420p \ -c:a copy \ output.mov This starts the overlay at 5 seconds with the overlaid video start point being 00:15. setpts=PTS-10/TB is setpts=PTS+(overlay_delay-video_trim_in)/TB overlay=enable=gte(t\,5) is … Read more

How to read a frame from YUV file in OpenCV?

I wrote a very simple python code to read YUV NV21 stream from binary file. import cv2 import numpy as np class VideoCaptureYUV: def __init__(self, filename, size): self.height, self.width = size self.frame_len = self.width * self.height * 3 / 2 self.f = open(filename, ‘rb’) self.shape = (int(self.height*1.5), self.width) def read_raw(self): try: raw = self.f.read(self.frame_len) yuv … Read more

How can HTML5 video’s byte-range requests (pseudo-streaming) work?

I assume your video is in an Mp4 container. The mp4 file format contains a hierarchical structure of ‘boxes’. One of these boxes is the Time-To-Sample (stts) box. This box contains the time of every frame (in a compact fashion). From here you can find the ‘chunk’ that contains the frame using the Sample-to-Chunk (stsc) … Read more

Is there a way to use ffmpeg to determine the encoding of a file before transcoding?

Use ffprobe Example command $ ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nokey=1:noprint_wrappers=1 input.mp4 Result h264 Option descriptions -v error Omit extra information except for fatal errors. -select_streams v:0 Select only the first video stream. Otherwise the codec_name for all other streams in the file, such as audio, will be shown as well. -show_entries … Read more

Android make animated video from list of images

Android do not support for AWT’s BufferedBitmap nor AWTUtil, that is for Java SE. Currently the solution with SequenceEncoder has been integrated into jcodec’s Android version. You can use it from package org.jcodec.api.SequenceEncoder. Here is the solution for generating MP4 file from series of Bitmaps using jcodec: try { File file = this.GetSDPathToFile(“”, “output.mp4”); SequenceEncoder … Read more