Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1504 closed enhancement (fixed)

Split an input video into multiple output video chunks

Reported by: burek Owned by:
Priority: wish Component: avformat
Version: unspecified Keywords: segment split
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

So far, people can use -ss and -t to cut the video chunk out of the input video. But if they want to cut the video to multiple output chunks, they would have to start ffmpeg several times (probably in a batch script), changing -ss value (and maybe even -t too), which complicates things a little bit, since ffmpeg has to skip same starting interval of the input over and over again.

Because of this, it might be usable to somehow change/add this feature that will allow users to specify cut points and get the multiple outputs, just like image2 does, numbering each output sequentially.

An example usage might be something like this:

ffmpeg -i input.avi -ss2 10,20,40,50,90,120,180 -vcodec copy output02%d.avi

This would instruct ffmpeg to produce several outputs, each of them generated based on cut points (defined in seconds).

Change History (4)

comment:1 Changed 4 years ago by saste

  • Keywords segment split added
  • Status changed from new to open

That's what the segment format is supposed to do:

ffmpeg -i input.avi -f segment -segment_times 10,20,40,50,90,120,180 -vcodec copy output02%d.avi

Note: -segment_times option is still not integrated, but I have a patch waiting for review. The only problem is that the input file is required to have enough key-frames set at the right point, and for accurate splitting you may need to transcode and use -force_key_frames (and there is no magical way to get around that, since a segment must start with a key frame).

comment:2 follow-up: Changed 4 years ago by burek

cool man :) I thought that -segment is used for that apple's http segmented streaming thing and I didn't pay closer attention to it so far :) anyway, if a user doesn't use -vcodec copy but instead re-encodes his/her video, then I guess there is no need to pay attention to key frames, right?

also, maybe offtopic, but a lot of time people get gray images, when they try to extract a single frame from a movie, using -ss and -t, so I'd like to ask is it the -force_key_frames that needs to be used to overcome this issue or the problem is something else?

comment:3 Changed 4 years ago by saste

  • Analyzed by developer set
  • Component changed from undetermined to avformat
  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from open to closed

Should be addressed in:

commit 2058b52cf8a4eea9bf046f72b98e89fe9b36d3e3
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Sat Jan 28 22:36:38 2012 +0100

    lavf/segment: add -segment_times option
    
    Address trac ticket #1504.

comment:4 in reply to: ↑ 2 Changed 4 years ago by saste

Replying to burek:

cool man :) I thought that -segment is used for that apple's http segmented streaming thing and I didn't pay closer attention to it so far :) anyway, if a user doesn't use -vcodec copy but instead re-encodes his/her video, then I guess there is no need to pay attention to key frames, right?

It depends on the GOP size set and on the key frames locations, keep in mind that a video is always split at gop boundaries, check also -force_key_frames and the -segment_time_delta option.

Note: See TracTickets for help on using tickets.