Opened 7 months ago

Last modified 7 months ago

#7746 new defect

nvenc HEVC -b_ref_mode produces invalid pts/dts

Reported by: oviano Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: nvenc
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

With latest ffmpeg-master code on Windows, when I enable the new nvenc HEVC encoder option "b_ref_mode" with "middle", and 4 b-frames, I find that calls to avcodec_receive_packet are returning invalid dts/pts combinations.

To be more precise dts is frequently greater than pts by 1. This then causes av_interleaved_write_frame to fail with an invalid argument error.

Similar behaviour is exhibited in ffmpeg itself, except instead of totally failing, ffmpeg spews a huge amount of output and tries to guess new values.

In both cases, if I omit the new "b_ref_mode" value, but keep b-frames, then this issue does not occur.

I can work around it, of course, but I suppose something needs adjusting in the nvenc code to avoid this?

C:\Program Files\Emu Server>ffmpeg -analyzeduration 100M -probesize 100M -i c:\Users\Oliver\Desktop\capture.asf -vcodec hevc_nvenc -pix_fmt yuv420p -preset slow -rc vbr_hq -vb 20000k -bufsize 20000k -maxrate 30000k -g 50 -b_ref_mode middle -bf 4 -rc-lookahead 32 -acodec aac -ab 256k -af aresample=async=1000 -r 50.000000 -f mpegts c:\Users\Oliver\Desktop\encode.ts -y
ffmpeg version N-93129-g9e1e521393 Copyright (c) 2000-2019 the FFmpeg developers

built with gcc 8.2.1 (GCC) 20190212
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --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-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.101 / 58. 47.101
libavformat 58. 26.101 / 58. 26.101
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100

Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, asf, from 'c:\Users\Oliver\Desktop\capture.asf':

Metadata:

encoder : Lavf58.12.100

Duration: 00:01:00.55, start: 0.000000, bitrate: 290954 kb/s

Stream #0:0: Video: huffyuv (HFYU / 0x55594648), yuv422p, 1920x1080, 25 fps, 25 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s

Stream mapping:

Stream #0:0 -> #0:0 (huffyuv (native) -> hevc (hevc_nvenc))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))

Press [q] to stop, ? for help
Output #0, mpegts, to 'c:\Users\Oliver\Desktop\encode.ts':

Metadata:

encoder : Lavf58.26.101
Stream #0:0: Video: hevc (hevc_nvenc) (Main), yuv420p, 1920x1080, q=-1--1, 20000 kb/s, 50 fps, 90k tbn, 50 tbc
Metadata:

encoder : Lavc58.47.101 hevc_nvenc

Side data:

cpb: bitrate max/min/avg: 30000000/0/20000000 buffer size: 20000000 vbv_delay: -1

Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 256 kb/s
Metadata:

encoder : Lavc58.47.101 aac

[mpegts @ 000002b41905ad40] Invalid DTS: 9000 PTS: 5400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 12600 PTS: 9000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 27000 PTS: 23400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 30600 PTS: 27000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 45000 PTS: 41400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 48600 PTS: 45000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 63000 PTS: 59400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 66600 PTS: 63000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 81000 PTS: 77400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 84600 PTS: 81000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 99000 PTS: 95400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 102600 PTS: 99000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 117000 PTS: 113400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 120600 PTS: 117000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 135000 PTS: 131400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 138600 PTS: 135000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 153000 PTS: 149400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 156600 PTS: 153000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 171000 PTS: 167400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 189000 PTS: 185400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 192600 PTS: 189000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 207000 PTS: 203400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 210600 PTS: 207000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 225000 PTS: 221400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 228600 PTS: 225000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 243000 PTS: 239400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 246600 PTS: 243000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 261000 PTS: 257400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 264600 PTS: 261000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 279000 PTS: 275400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 282600 PTS: 279000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 297000 PTS: 293400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 300600 PTS: 297000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 315000 PTS: 311400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 318600 PTS: 315000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 333000 PTS: 329400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 336600 PTS: 333000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 351000 PTS: 347400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 369000 PTS: 365400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 372600 PTS: 369000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 387000 PTS: 383400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 390600 PTS: 387000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 405000 PTS: 401400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 408600 PTS: 405000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 423000 PTS: 419400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 426600 PTS: 423000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 441000 PTS: 437400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 444600 PTS: 441000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 459000 PTS: 455400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 462600 PTS: 459000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 477000 PTS: 473400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 480600 PTS: 477000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 495000 PTS: 491400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 498600 PTS: 495000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 513000 PTS: 509400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 516600 PTS: 513000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 531000 PTS: 527400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 549000 PTS: 545400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 552600 PTS: 549000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 567000 PTS: 563400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 570600 PTS: 567000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 585000 PTS: 581400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 588600 PTS: 585000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 603000 PTS: 599400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 606600 PTS: 603000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 621000 PTS: 617400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 624600 PTS: 621000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 639000 PTS: 635400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 642600 PTS: 639000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 657000 PTS: 653400 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 660600 PTS: 657000 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 685800 PTS: 682200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 689400 PTS: 685800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 703800 PTS: 700200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 707400 PTS: 703800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 721800 PTS: 718200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 725400 PTS: 721800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 739800 PTS: 736200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 743400 PTS: 739800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 757800 PTS: 754200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 761400 PTS: 757800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 775800 PTS: 772200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 779400 PTS: 775800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 793800 PTS: 790200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 797400 PTS: 793800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 811800 PTS: 808200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 815400 PTS: 811800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 829800 PTS: 826200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 833400 PTS: 829800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 847800 PTS: 844200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 865800 PTS: 862200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 869400 PTS: 865800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 883800 PTS: 880200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 887400 PTS: 883800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 901800 PTS: 898200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 905400 PTS: 901800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 919800 PTS: 916200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 923400 PTS: 919800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 937800 PTS: 934200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 941400 PTS: 937800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 955800 PTS: 952200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 959400 PTS: 955800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 973800 PTS: 970200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 977400 PTS: 973800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 991800 PTS: 988200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 995400 PTS: 991800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1009800 PTS: 1006200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1013400 PTS: 1009800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1027800 PTS: 1024200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1045800 PTS: 1042200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1049400 PTS: 1045800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1063800 PTS: 1060200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1067400 PTS: 1063800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1081800 PTS: 1078200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1085400 PTS: 1081800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1099800 PTS: 1096200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1103400 PTS: 1099800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1117800 PTS: 1114200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1121400 PTS: 1117800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1135800 PTS: 1132200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1139400 PTS: 1135800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1153800 PTS: 1150200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1157400 PTS: 1153800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1171800 PTS: 1168200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1175400 PTS: 1171800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1189800 PTS: 1186200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1193400 PTS: 1189800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1207800 PTS: 1204200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1225800 PTS: 1222200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1229400 PTS: 1225800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1243800 PTS: 1240200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1247400 PTS: 1243800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1261800 PTS: 1258200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1265400 PTS: 1261800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1279800 PTS: 1276200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1283400 PTS: 1279800 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1297800 PTS: 1294200 in output stream 0:0, replacing by guess
[mpegts @ 000002b41905ad40] Invalid DTS: 1301400 PTS: 1297800 in output stream 0:0, replacing by guess
frame= 366 fps=128 q=25.0 Lsize= 20787kB time=00:00:15.49 bitrate=10986.8kbits/s speed=5.44x
video:18729kB audio:486kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.182553%
[aac @ 000002b418fc5a40] Qavg: 198.825
Exiting normally, received signal 2.

Change History (2)

comment:1 Changed 7 months ago by cehoyos

  • Keywords HEVC b_ref_mode removed
  • Priority changed from important to normal

Is specific input necessary to reproduce or is the issue reproducible with testsrc2?

comment:2 Changed 7 months ago by oviano

I don't think so - I tried about three different files all with the same outcome.

However, here is a link to file that produced the example above, in Dropbox, if that is helpful.

https://www.dropbox.com/s/qk0kbzrsx3matur/capture.asf?dl=0

Note: See TracTickets for help on using tickets.