3

How can I add keyframes for FLV files without reencoding? I try to use this command, but do nothing:

ffmpeg -i file.flv  -vcodec copy -acodec copy -g 0 -y tmp.flv && yamdi -i tmp.flv -o out.flv

The (source and this) result is not seekable corretly with flash player. I have a lot of flv to "repair".

Simon
  • 3,973
Zoltán
  • 33
  • 1
  • 1
  • 3

2 Answers2

10

How can I add keyframes for FLV files without reencoding?

You can't.

A keyframe, or I-frame, is a frame that stands on it's own - it doesn't require any frames before or after in order to be decoded. Other frames are P-frames (which require one or more previous frames to be decoded, and base their contents on changes made to the previous frame rather than forming a complete picture in isolation) and B-frames (the same as P-frames, but reference frames both before and after them).

In order to change a P- or B-frame to an I-frame, you need to decode and then re-write the video stream. So you can't add keyframes without re-encoding.

Have a look at the x264 encoding guide on the ffmpeg wiki for some tips on how to get a good-looking encode.

evilsoup
  • 14,056
1

When you do -vcodec copy, you are entirely copying the video codec. Then no parameters can affect the video, so also the GOP size isn't parsed again.

Try just using the gopsize, without a video codec copy:

ffmpeg -i file.flv -acodec copy -g 1 -sameq -y tmp.flv

Note the -sameq parameter means same quantizer, which should only be used when you are decoding and encoding using the same codec (like MPEG-2 to MPEG-2), like in your case where you don't want to change the codec.

Omega
  • 805