4

I want to remove night footage from a Timelapse video of construction over 300 days. So I want to remove 300 nights from this video. How do I do it in an easier way? Is there a option to cut video at predefined frame/points after regular intervals in one single command? I want to avoid manual labor. I am using adobe premier pro cc 2014

  • Is it a fixed camera and an area of the frame show the sky? Actually, can you share a frame from night time? – Gyan Mar 10 '17 at 19:42
  • 1
    It's a fixed Timelapse camera. It shows progress of the whole day in 3 secs. I want to slice out middle 1 sec from it. But the problem is footage is continuous for 300 days.. so i need to slice out every third second starting from 2nd sec i.e. 2nd,5th,8th,11th and so on. This is very tedious to do individually. Is there any option by which i can set formula like.. slice out 2to3sec, 2+3to3+3sex, 2+3n to 3+3n sec and so on until the end of video, all at once? – user18315 Mar 10 '17 at 19:50
  • 1
    If you are OK with using a command line tool (ffmpeg), I'll supply a command in the morning to do this. – Gyan Mar 10 '17 at 20:10
  • I haven't used it yet but you send me a command, i'll learn to use commands. – user18315 Mar 10 '17 at 20:15
3

Using ffmpeg, a command line tool, you can use

ffmpeg -i in.mp4 -vf select='trunc(mod(t+2,3))',setpts=N/FRAME_RATE/TB -crf 23 out.mp4

The select filter is used on the video stream. This filter evaluates the supplied expression on each frame and keeps the frame if the expression evaluates to a non-zero value.

The expression used is trunc(mod(t+2,3)). The modulo function returns the remainder of the first operand when divided by the second. The first operand here is the timestamp of the evaluated frame. The truncate function truncates that result to an integer. If it is zero, the frame is discarded, else kept.

e.g. for a 25 fps video

t       t+2      mod(t+2,3)       trunc(mod(t+2,3))    select
0.00    2.00     2.00                    2             KEEP
0.04    2.04     2.04                    2             KEEP
...
0.96    2.96     2.96                    2             KEEP
1.00    3.00     0.00                    0             CUT
1.04    3.04     0.04                    0             CUT
...
1.96    3.96     0.96                    0             CUT
2.00    4.00     1.00                    1             KEEP
...
3.00    5.00     2.00                    2             KEEP
...
4.40    6.40     0.40                    0             CUT
...

Since you want to 'collapse' the video by removing the night time portions, the setpts filter is added to make all the kept frames continuous i.e. after the frame at 0.96, the next kept frame (2.00) will have the new timestamp of 1.00.

The video has to be recompressed since a filter has been used. For MP4s, default codec is H.264 and default encoder is libx264. The -crf 23 sets the bitrate control method (CRF) and value (23). Lower values retain more of the source quality at the expense of larger size. 18 to 28 are typical values.

You can get a ffmpeg binary for your platform from https://ffmpeg.org/download.html. Always get the latest nightly or snapshot build.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.