2

I have webm videos that output the error:

Discarding interframe without a prior keyframe!

When played in VLC. How can I recode/fix the files in linux to solve this error.

There is a way to check this problems in a video without playing it?

2
  • Where do you get this error? In VLC directly? What kind of files are those? They shouldn't (and can't) be encoded with missing keyframes. Are the files captures from some streams?
    – slhck
    Apr 30, 2013 at 18:41
  • @slhck this occurs when I fastforward the begining of videos. In some videos. I remember coding it myself year ago from avi's.
    – Zhen
    Apr 30, 2013 at 18:44

1 Answer 1

3

An inter-frame is a frame that requires the decoder to read the previous keyframe (intra-frame) to be able to construct the image. This is because an inter-frame, roughly speaking, only contains the difference between the previous keyframe and itself.

When you fast-forward a video to a certain point, you might not hit a keyframe. In fact, chances are higher that you hit an inter-frame, as keyframes are only inserted every N frames (for example 16). So, what the player does when you hit an inter-frame, is that it has to discard this frame—and all subsequent ones—until it finds the next keyframe. From there, it can start decoding and will show you a picture.

The VP8 implementation in libavcodec (the library that VLC uses to decode WebM/VP8 video), mentions this as well:

// Given that arithmetic probabilities are updated every frame, it's quite 
// likely that the values we have on a random interframe are complete junk 
// if we didn't start decode on a keyframe. So just don't display anything 
// rather than junk.
if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] ||
                     !s->framep[VP56_FRAME_GOLDEN] ||
                     !s->framep[VP56_FRAME_GOLDEN2])) {
    av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n");
    return AVERROR_INVALIDDATA;

Having to wait for keyframes is the main reason fast-forwarding and then resuming playback may take a while, unless the player maintains a buffer for the area behind the playhead.

To summarize: you didn't do anything wrong. You can't encode a video without keyframes, or forcefully remove keyframes either. And since VLC relies on libavcodec, where the above is hardcoded, you can't change that error message either (actually, it's just a warning).

If VLC does hang for you because of that, there might be a bug related to this part of the code, but from what I've read that should have been fixed.

You must log in to answer this question.

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