Source code for analysis.lib.movie
'''test script for the creation of a movie
(should be modified for general use)
Created on 12 mars 2018
@author: Catalano Camille
'''
import os
from common.io.events import EclairsCalEvtData
[docs]def create_movie(event_file, movie_name, folder_path, t_window, t_step, method='sliding_window'):
"""
create a movie from an event fits file
to create the movie, the event file is read and cut in 10 images of (time_event / 50) integration time.
the movie is save in a mp4 format.
.. note:: event file is EclairsCalEvtData object style.
:param event_file: path to the event file
:param movie_name: name of the movie file (without extension)
:param folder_path: path of the directory where to save the movie
:type event_file: string (PATH)
:type movie_name: string
:type folder_path: string (PATH)
:param t_window: integration time to build images in s
:type t_window: float
:param t_step: step between two beginning time of windows in s
:type t_step: float
:param method: construction method: 'sliding_window' or 'cumulative'. Default='sliding_window'
:type method: string
"""
x_event=EclairsCalEvtData()
x_event.read(event_file)
try:
os.system('mkdir ' + folder_path + '/tmp')
except FileExistsError:
os.system('rm -r ' + folder_path + '/tmp')
x_event.sort_with_time()
x_event.save_images(t_window, t_step, folder_path + '/tmp', method)
os.system('ffmpeg -r 3 -i ' + folder_path + '/tmp/img%02d.png -vcodec mpeg4 -y ' + folder_path + '/' + movie_name + '.mp4')
os.system('rm -r ' + folder_path + '/tmp')