Édouard Lopez
Édouard Lopez

Reputation: 43391

Splitting video in short clip result in some being empty?

I'm trying to split a video (50-100Mo) into several small clips of a few seconds each. I don't need re-encoding, hence my use of codec copy.

However some of the resulting clips don't have any video.

Fast but no video in some files

ffmpeg \
  -y \
  -i ./data/partie-1:-Apprendre-300-mots-du-quotidien-en-LSF.jauvert-laura.hd.mkv \
  -ss 0:00:07.00 \
  -codec copy \
  -loglevel error \
  -to 0:00:10.36 \
  'raw/0:00:07.00.au revoir.mkv'

I also tried -map 0 -c copy, -acodec copy -map 0:a -vcodec copy -map 0:v or no option related to codec.

Slow but complete

No argument related to audio/video encoding, it's working but pretty slow.

ffmpeg -y \
  -i "$SOURCE_VIDEO_FILE" \
  -ss 0:05:37.69 \
  -to 0:05:40.64 \
  -loglevel error
  'raw/0:05:37.69.pas la peine.mkv'

Question

How do I split a video into small chunk ~2-4s when I have no need for re-encoding?

related: https://video.stackexchange.com/q/25365/23799

Upvotes: 0

Views: 126

Answers (1)

Robin Green
Robin Green

Reputation: 33033

Your constraint can't be satisfied. Some video codecs appear to use chunks, where they start with a complete frame and then store "diffs", so in order to use -vcodec copy, ffmpeg has to honour the chunk boundaries.

Don't use -vcodec copy if you encounter this problem.

Upvotes: 2

Related Questions