4

Does anyone know of a software that could be installed/compiled for linux that is able to cut video by the frame? Thanks.

1
  • I think any video editor will have this basic feature. Even VLC might be able to do it.
    – jiggunjer
    Jan 3, 2016 at 23:19

1 Answer 1

7

ffmpeg can do it. If the video codec is inter-coded and you want precise frame accuracy, you'll have to re-encode the video. If you need to not re-encode the video, then ffmpeg will cut from the nearest GOP boundary before the specified cut point.

Cut and stream-copy:

ffmpeg -i input -ss T -t D -c copy -fflags +genpts output

-ss T specifies the starting point expressed as timecode in the format of S+[.m...] e.g. 24 or 65.22 or [HH:]MM:SS[.m...] e.g. 02:34:11.644

-t D specifies the duration in the same format.

This won't be frame accurate if the start point isn't at a GOP boundary.

Cut and re-encode:

ffmpeg -i input -ss T -t D -fflags +genpts output

Same as above, but this will be frame-accurate.

If you need to specify in and out points by frame numbers:

ffmpeg -i input -vf trim=start_frame=n:end_frame=m -af atrim=start=s:end=t -fflags +genpts output

n and m are the frame numbers of the video in and out points. s and t are the timecodes for the corresponding audio.

The codecs chosen for the re-encoded videos will be according to whichever defaults ffmpeg has set for the output container e.g. H.264 and AAC for MP4.

2
  • Thanks a ton for your help. I have been trying ffmpeg but I haven't been able to figure it out fully. Thanks again.
    – Techlord
    Jan 3, 2016 at 7:08
  • It does not work. The first frame is just duplicated up until the point when it appears. The sound timings are NOT in frames, but in time, what is the point of using frames in video filter than? Turns out ffmpeg, can't do it, after all. Aug 31, 2023 at 4:47

Not the answer you're looking for? Browse other questions tagged .