Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PHDPeter/070f6c7f499e0519202e6cc38e76c7c4 to your computer and use it in GitHub Desktop.
Save PHDPeter/070f6c7f499e0519202e6cc38e76c7c4 to your computer and use it in GitHub Desktop.
Lossless cutting of videos to small clips by OpenCv and FFMPG (PYTHON)
Ok this is my first time realy playing with vidos so here it is.
FFMPG (Try)
SO the first issue I had here was getting the cuts to be lossless, i.e. cut on the fram you want not the nearsed key frame.
I started by trying to do this with FFMPG (and I am sure smarter pepole then me can get this to work) but this tended to be not quite lossless in that the number of total fmaes for each vido varired from video to vidoe.
For my needs I had to have tight control over the total number of frames so this would not work for me.
That said below is the FFMPG code that Iwas using:
stri = "ffmpeg -ss " +str(start_in_sec)+" -i " + str(input)+" -vcodec "+str(codec) +" -c:a libmp3lame "+ " -to " +str(end_in_sec) + " -c copy " +str(output)
As the code I am doing is in python I this call will need to be used with os.system(command) .
The big noite here is that the -ss needs to be called first, as this sets the keyframs closer to the start_in_sec frame that you want.
openCV (Solve)
bad frames
testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment