-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Read/write original files as arrays
For further processing and training purposes, I think it is nice to be able to read the original files of MgVideo and MgAudio objects as arrays.
I understand that this could be done by opencv or librosa, but a shortcut function would be handy, for example:
video = musicalgestures.MgVideo('/path/to/a/video.mp4')
video_array, fps = video.numpy() # returns a numpy array of the video file
On the other hand, we can also consider to add the function that inits an MgVideo object from an array, for example:
video_array, fps = video.numpy()
new_object = musicalgesture.MgVideo(array=video_array, fps=fps, path='your/cutsom/path', filename='your_filename.avi') # this inits a new MgVideo object and saves the array as a file, maybe have a default path and filename if not specified
The function name, style, parameters and default values need to be further discussed.
Memory-based processing flow
Current workflow creates a new file after each line of processing is done, this might become a issue if we run a batch process of a large dataset, say 100,000 video files (although I guess other performance issues are more critical in such a situation...)
So I suggest we could have a flag that tells the program not to save a new file, but return an array instead. For example:
video = musicalgestures.MgVideo('/path/to/a/video.mp4')
video_grid = video.grid(height=300, rows=1, cols=9, return_array=True) # video_grid will be a numpy array, and no files will be created
In fact, I would recommend using memory-based flow as a default, since it's safer in terms of storage management. I would suggest only creating new files when the user flags that they want so.