Opened 5 weeks ago

Last modified 5 weeks ago

#6971 new defect

ffmpeg drops frames after deinterlacing

Reported by: CaryKnoop Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: cuvid
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

NVIDIA's encoder supports deinterlacing. This optionally includes deinterlacing with frame doubling. In case frame doubling is wanted the NVIDIA decoder correctly doubles the frames, however ffmpeg does not pass this on to the encoder but instead drops all doubled frames.

Regardless of the NVIDIA cuvid parameter settings -deint (1, 2) and -drop_second_field (0, 1) frames get dropped by ffmpeg.

How to reproduce:

For full hardware decoding and encoding:
% ffmpeg -hwaccel cuvid -c:v mpeg2_cuvid -deint 2 -drop_second_field 0 -i <interlaced mpeg-2 file> -c:v h264_nvenc -b:v 80M -profile:v high -preset slow <out file>

Or for hardware decoding and encoding but passing the intermediate results to system buffers:
% ffmpeg  -c:v mpeg2_cuvid -deint 2 -drop_second_field 0 -i <interlaced mpeg-2 file>  -c:v h264_nvenc -b:v 80M -profile:v high -preset slow <out file>

ffmpeg version N-89825-g1b5d3c08e3 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      56.  7.100 / 56.  7.100
  libavcodec     58.  9.100 / 58.  9.100
  libavformat    58.  5.100 / 58.  5.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7. 11.101 /  7. 11.101
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100

CUDA library: 9,1
NVIDIA Driver: 388.19

Change History (3)

comment:1 Changed 5 weeks ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords cuvid added
  • Version changed from 3.4 to git-master

Please provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:2 follow-up: Changed 5 weeks ago by CaryKnoop

Full command line with console output:

ffmpeg -hwaccel cuvid -c:v mpeg2_cuvid -deint 2 -drop_second_field 0 -i touched.demuxed.m2v -c:v h264_nvenc -b:v 80M -profile:v high -preset slow out1.mp4
ffmpeg version N-89825-g1b5d3c08e3 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      56.  7.100 / 56.  7.100
  libavcodec     58.  9.100 / 58.  9.100
  libavformat    58.  5.100 / 58.  5.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7. 11.101 /  7. 11.101
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, mpegvideo, from 'touched.demuxed.m2v':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, smpte170m, top first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (mpeg2_cuvid) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
Output #0, mp4, to 'out1.mp4':
  Metadata:
    encoder         : Lavf58.5.100
    Stream #0:0: Video: h264 (h264_nvenc) (High) (avc1 / 0x31637661), cuda, 720x480 [SAR 8:9 DAR 4:3], q=-1--1, 80000 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.9.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/80000000 buffer size: 160000000 vbv_delay: -1
Past duration 0.999992 too large
frame= 4362 fps=1068 q=12.0 Lsize=  122530kB time=00:02:25.51 bitrate=6898.1kbits/s dup=18 drop=4338 speed=35.6x
video:122510kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.015960%

comment:3 in reply to: ↑ 2 Changed 5 weeks ago by cehoyos

Replying to CaryKnoop:

frame= 4362 fps=1068 q=12.0 Lsize=  122530kB time=00:02:25.51 bitrate=6898.1kbits/s dup=18 drop=4338 speed=35.6x

Possible work-around is to specify -r 60000/1001 as output frame rate.

Note: See TracTickets for help on using tickets.