Python Library For Splitting Video
I need to split big video file into smaller pieces by time. Give me your suggestions, please, and if you can some tips for library usage. Thanks.
Solution 1:
OpenCV has Python wrappers.
As you're interested in video IO, have a look at QueryFrame and its related functions there.
In the end, your code will look something like this (completely untested):
import cv
capture = cv.CaptureFromFile(filename)
while Condition1:
# Need a frame to get the output video dimensions
frame = cv.RetrieveFrame(capture) # Will return None if there are no frames# New video file
video_out = cv.CreateVideoWriter(output_filenameX,
CV_FOURCC('M','J','P','G'), capture.fps, frame.size(), 1)
# Write the frames
cv.WriteFrame(video_out, frame)
while Condition2:
# Will return None if there are no frames
frame = cv.RetrieveFrame(capture)
cv.WriteFrame(video_out, frame)
By the way, there are also ways to do this without writing any code.
Solution 2:
Check youtube-upload, it splits the videos using ffmpeg.
Youtube-upload is a command-line script that uploads videos to Youtube. If a video does not comply with Youtube limitations (<2Gb and <15'), it will be automatically splitted before uploading. Youtube-upload should work on any platform (GNU/Linux, BSD, OS X, Windows, ...) that runs Python and FFmpeg.
Post a Comment for "Python Library For Splitting Video"