Ask Your Question

How to trim a video based on a condition

asked 2018-06-29 00:30:30 -0500

papabiceps gravatar image

updated 2018-06-29 00:34:02 -0500

I have a video from drone. I want to delete the part of video that has takeoff included. I want to retain the part where the drone is flying. Can someone suggest a method in OpenCV to achieve this ?

edit retag flag offensive close merge delete



maybe you can use global motion

berak gravatar imageberak ( 2018-06-29 02:32:28 -0500 )edit

This media trimmer is also available.

kkmin gravatar imagekkmin ( 2020-03-20 05:50:17 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-06-29 02:18:16 -0500

holger gravatar image

updated 2018-06-29 02:19:17 -0500

Well opencv can read frames from video but its mainly an image processing library - not a video cut software.

  • If you want to do it the easy way and you have the timestamps when takeoff is finished, just use ffmpeg.
  • If you want to do this automatically and often for different videos - well then maybe this could be a opencv related question.
edit flag offensive delete link more


trimming the video isn't the issue, I want to automate the process using OpenCV. I want to find from which frame the drone starts to move

papabiceps gravatar imagepapabiceps ( 2018-06-29 02:20:17 -0500 )edit

Well you got an interesting task here, i don't know the solution but maybe i can give some ideas. The good thing is that the video is from the 1st person view of the drone.

I found this link.

If i understanding this correct

  1. Get the first frame(no movent) and use it as an anchor.
  2. Do some preprocessing on that image (gray scaling, blurring)
  3. Get the next frame, do the same processing on this image
  4. Compute a diff between first frame and current frame. If the diff is bigger than a certain delta , the background changed and the drone is most likely moving.
  5. Repeat on every following screen until you detect a movement (diff >= delta)
holger gravatar imageholger ( 2018-06-29 03:46:50 -0500 )edit

Question Tools

1 follower


Asked: 2018-06-29 00:30:30 -0500

Seen: 2,780 times

Last updated: Jun 29 '18