I would like to trim - cut off frames at the beginning and end - a video that can be in a variety of different formats, and then save the trimmed video.
Are there any libraries or suggestions on how to do this?
Thanks!
I've been using ffmpeg and the subprocess module of python to extract video thumbnails, but it seems ffmpeg can do pretty much anything.
Once you install ffmpeg, you can trim off the first second of video like so
> ffmpeg -i sample.mov -ss 1 trim.mov
So using the subprocess module of python
import subprocess
seconds = "1" # has to be a string
subprocess.call(['ffmpeg', '-i', inputfilename, '-ss', seconds, outputfilename])
will take off the first second. For specific frames, there are flags like -vframes and -dframes, but I haven't actually used them. Documentation of ffmpeg here.
There's also pyffmpeg, a python wrapper for ffmpeg. But I haven't used it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With