0

I'm trying to record a live video (using H.264 codec) from a series of pictures that i receive by socket using python.

I tried to use the MoviePy package (documentation here : github.com/Zulko/moviepy) on python to do that but i didn't figured it out.

If anyone have a guide on how to get started with python and saving pictures I receive as frames in real time using ffmpeg, I would really appreciate it .

what I have is something like this , but it gives only the last captured image in the video it doesn't save continuously the stream of images :

from moviepy.editor import *
import numpy as np

while True:
   data = sock.recv()
   image = np.fromstring(data)
   folder = [image] 
   cv = ImageSequenceClip(folder, fps = 1)
   cv.write_videofile("video.mp4")
zerzer
  • 573
  • 2
  • 6
  • 20
  • What do you do with `image`? – Peter Wood Mar 31 '15 at 11:26
  • @PeterWood i've updated the lines of code , I convert the string buffer to a numpy array which will be a two dimensions matrix after a reshape – zerzer Mar 31 '15 at 11:34
  • I think you need to create the list outside of the loop and append to it. `folder = []` before, and `folder.append(image)` inside. – Peter Wood Mar 31 '15 at 11:40
  • @PeterWood i thought about your solution but since i'm trying to save a non-stop image stream it will occupy a huge amount of space in the access memory, i need to save it to disk in real time – zerzer Mar 31 '15 at 11:45
  • In your loop you are re-writing the file every time you get a new image. – Peter Wood Mar 31 '15 at 12:01
  • yes that's the problem ! i don't know how to force ffmpeg to append the received image at the end of the video wihout overwriting the existing file – zerzer Mar 31 '15 at 12:02
  • possible duplicate of [Can you "stream" images to ffmpeg to construct a video, instead of saving them to disk?](http://stackoverflow.com/questions/13294919/can-you-stream-images-to-ffmpeg-to-construct-a-video-instead-of-saving-them-t) – Peter Wood Mar 31 '15 at 12:35

0 Answers0