Opened 3 years ago

Last modified 2 years ago

#9097 new defect

ffmpeg doesn't filter I frames only with nointra

Reported by: sergey Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: h264 regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
It was found that decoding with parameter skip_frames nointra for LibAV does not return I frames only on example stream. Only several I frames are returned and other are skipped (from int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt);).
To be precise it was found that in normal case this part of code works in another way:

ffmpeg\libavcodec\h264.c
static void decode_postinit(H264Context *h, int setup_finished)
.....................
    if (!out_of_order && pics > h->avctx->has_b_frames) {
        h->next_output_pic = out;
        if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f->key_frame || h->delayed_pic[0]->mmco_reset)) {
            h->next_outputed_poc = INT_MIN;
        } else
            h->next_outputed_poc = out->poc;
    } else {
        av_log(h->avctx, AV_LOG_DEBUG, "no picture %s\n", out_of_order ? "ooo" : "");
    }

Full decoding works find for this stream and command above returns about 52 I frames.
Other streams work fine, but there is not enough information from LibAV logs what goes wrong to understand is it LibAV fauls or not!?

How to reproduce:
It was reproduced on 3.1.1, 3.4.2, 3.4.3
Transcode example stream using ffmpeg and skip_frames nointra parameter. But the shortest way is to use ffprobe:

xxx@comp MINGW64 /d/Work/0_tmp/ffmpeg-4.3.1-2021-01-01-full_build/bin
$ ./ffprobe.exe -skip_frame nointra -show_frames -select_streams v:0 /d/Work/Bug/a1_14.ts | grep  "pict_type"
ffprobe version 4.3.1-2021-01-01-full_build-www.gyan.dev Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
...............................
Input #0, mpegts, from 'D:/Work/Bug/a1_14.ts':
  Duration: 00:00:56.56, start: 46379.615567, bitrate: 2959 kb/s
  Program 1
    Stream #0:0[0x31]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:11 DAR 20:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x33](rus): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:2[0x34](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:3[0x3c]: Subtitle: dvb_teletext ([6][0][0][0] / 0x0006), 492x250
pict_type=I
pict_type=I

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Change History (5)

comment:2 by Elon Musk, 3 years ago

Does ffmpeg returns nonintra frames with that parameters above?
Log above contradicts this as only I are shown.

comment:3 by Carl Eugen Hoyos, 3 years ago

Component: ffmpegavcodec
Keywords: h264 regression added; ffmpeg ffprobe skip_frames nointra removed
Reproduced by developer: set
Version: 4.2git-master

For future tickets: Please always test current FFmpeg git head before reporting an issue.

Regression since 7eae8cd87054713cbef51b22b93f3a0eb5036c90, related to ticket #3475.
Possible duplicate of ticket #8820.

in reply to:  2 comment:4 by sergey, 3 years ago

Replying to richardpl:

Does ffmpeg returns nonintra frames with that parameters above?
Log above contradicts this as only I are shown.

It returns only several of all I frames that are in sample video. Expected: all 52 I frames. Really: only 2 I frames.
The same result for skip_frames nokey parameter.
Additionally it isn't seen in ffprobe output difference between I and IDR frames to check what type of I frames are in the sample.

comment:5 by Balling, 2 years ago

Not all I frames are keyframes in AVC...

Note: See TracTickets for help on using tickets.