0

I'm using ffmpeg to trim a Zoom video recording (format: ISO Media, MP4 v2 [ISO 14496-14]) via this command:

ffmpeg \
  -ss 00:11:42 \
  -to 01:11:22 \
  -i input-original.mp4 \
  -c copy \
  output-trimmed.mp4

The input file looks great, but the output has a few dropped frames at the beginning, so for the first few seconds it looks like this:

enter image description here

A few seconds later, it goes back to normal and it doesn't have any other issues. I'm wondering if there is a way to fix this problem.

EDIT: Actually, this seems to be a VLC-specific problem. Once I upload it to Vimeo, the weird frames go away. Still, I'd like to know if there is a way to prevent this.

  • 1
    It's probably not a FFmpeg issue — the resulting video should be good (if the source was good, naturally). Try ffplay output-trimmed.mp4 for playing it back. – MarianD Nov 14 at 4:40
1

Try to place the -ss and -to after the input:

ffmpeg \
  -i input-original.mp4 \
  -ss 00:11:42 \
  -to 01:11:22 \
  -c copy \
  output-trimmed.mp4

According to @Gyan (https://stackoverflow.com/questions/45004159/ffmpeg-ss-and-t-for-cutting-mp3)

When -ss and -t are placed before the input, ffmpeg resorts to fast seek which relies on the index of the input to allow ffmpeg to start and stop seeking. MP3s don't have indices, so ffmpeg estimates duration via bitrate. This can be inaccurate.

When -ss and -t are placed after the input, ffmpeg counts demuxed packets. This will be accurate.

If it doesn't work you can also try to convert your video to intra-frame format (try ffvhuff), trim it and then convert it back to mp4 but this will slightly decrease the quality of the trimmed output. Keep in mind that ffvhuff will create huge file in size so make sure you have enough free space if you want to go this way.

1

You can achieve the desired video without any broken or black frames by decoding and re-encoding the video. Although you need to know video codec and bit-rate in order to achieve so

ffmpeg -i input-original.mp4 -ss 00:11:42 -strict -2 -to 01:11:22 -codec:v h264 -b:v 100k;

Note: If this does not work, try to change -to switch to -t and specify the duration.
Hope this helps.

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.