Reputation: 59
Are there any libraries in python that allow the input of a video file and then output 4 equal quadrants of that video files (eg: top left, top right, bottom left, bottom right)?
At the moment I have only seen examples that split the video in terms of length (eg: a 20 minute video into 5 minute sections)
I know its probably possible by using something like opencv to split the video into frames and then split each frame into 4 and the make the individual frames back into the video but I think this is very resource hungry and not the most efficient solution.
Any suggestions or examples will be appreciated.
Upvotes: 2
Views: 3408
Reputation: 1565
You are right about OpenCV
. You don't need to split into frames. You can used OpenCV
or scikit-video
to read videos into 4 dimensional array (height, width, frames, channel)
. Then once you have size of weidth and height, you can just extract 4 videos by indexing. e.g. if (400,600, 122, 3)
is your video dimension, you can get 4 videos by:
v1=vid[:200,:300,:,:]
v2=vid[200:,:300,:,:]
v3=vid[200:,300:,:,:]
v4=vid[:200,300:,:,:]
You can find solution using ffmpeg
on: related question
This may be memory-wise cheaper (specially required RAM) compared to OpenCV
or scikit-video
solution. But the solution I mentioned above using scikit-video is not computationally expensive.
read/write videos with scikit-video
Upvotes: 3