<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hi,<div><br></div><div>I've encounter strange issue while working with libx265 2.7 and ffmpeg 4.0: while encoding, within ten minutes (maybe more maybe less), in my encoded stream grey frames appear (one or several times in a row) and then they disappear with large grey pixels and original stream images return back and everything goes fine. Then problem repeats.</div><div><br></div><div>Input stream decodes well, ffmpeg print no error, resulted HEVC bitstream successfully decoded by VLC or any other software (ffplay) (or hardware, I've tried <span style="color:rgb(0,0,0);font-family:Verdana,Arial,"Bitstream Vera Sans",Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Amlogic S905) but</span> while playing video sequence contains grey frame and looks corrupted sometimes. <span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Here is example of corrupted output sequence: <a href="https://yadi.sk/d/BNC7n7dJ3VVdxD" target="_blank">https://yadi.sk/d/BNC7n7dJ3VVdxD</a></span></div><div><br></div><div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">It has random nature, it does not depend on input stream, it doesn't depend on particular subsequence within input stream (I've tried to reencode same sequence and everything went fine without any image degradation).</span><br></div><div><br></div><div>The description is very close to this ffmpeg bug: <a href="https://trac.ffmpeg.org/ticket/6814" target="_blank">https://trac.ffmpeg.org/ticket/6814</a> </div><div>but in my case I definitely has no decoder corruption, and FFmpeg definitely (I've checked it with function and check raw frames) sends to libx265 encoder well decoded frames. So it looks like libx265 encoder bug.</div><div><br></div><div>A csv sheet with metrics from libx265 while output stream contains grey frame: <a href="https://yadi.sk/i/xVSfm6ph3VW47j">https://yadi.sk/i/xVSfm6ph3VW47j</a></div><div><br></div><div>Also that grey frames actually YUV with every byte == 128</div><div><br></div><div>I've checked: master libx265, release 2.7, release 2.6 -- problem everywhere.</div><div><br></div><div>This is my encoding commands (maybe here is error in codec params?):</div><div><br></div><div>ffmpeg -threads auto -i pipe:0 -s 1920x1080 -codec:0 libx265 -preset:0 ultrafast -x265-params:0 hdr=1:colorprim=9:transfer=18:colormatrix=9:fps=50:keyint=50:min-keyint=50:bframes=3:hrd=1:ref=3:vbv-maxrate=20000:vbv-bufsize=40000:bitrate=18000:rc-lookahead=4:no-scenecut=1:repeat-headers=1:no-open-gop=1:aud=1:no-info=1:level-idc=5.1:min-cu-size=16:merange=42:lookahead-threads=10:frame-threads=10:csv=ffmpeg-4.0-2.7.csv:csv-log-level=1 -streamid 0:101 -map '#0xc8' -codec:1 copy -threads:1 2 -streamid 1:110 -map '#0xca' -muxrate 26000000 -max_delay 2500000 -f:0 mpegts pipe:1 < /tmp/<a href="http://pipe.in" target="_blank">pipe.in</a> > /tmp/pipe.ts</div><div><br></div><div><br></div><div><div>ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers</div><div>  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609</div><div>  configuration: --prefix=/usr/local --pkg-config-flags=--static --enable-static --enable-nonfree --disable-shared --enable-runtime-cpudetect --extra-cflags=-ftree-vectorize --extra-cflags='-march=native' --extra-cflags=-O3 --extra-cflags=-fuse-linker-plugin --enable-pic --enable-lto --ar=gcc-ar --ranlib=true --enable-gpl --enable-libx264 --enable-libx265 --enable-libmp3lame --extra-libs=-lpthread</div></div><div><br></div><div><br>libx265 version info:<br><div>x265 [info]: HEVC encoder version 2.7</div><div>x265 [info]: build info [Linux][GCC 5.4.0][64 bit] 10bit</div><div>x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2</div></div><div><br></div><div>My CPU setup:</div><div><div># lscpu </div><div>Architecture:          x86_64</div><div>CPU op-mode(s):        32-bit, 64-bit</div><div>Byte Order:            Little Endian</div><div>CPU(s):                88</div><div>On-line CPU(s) list:   0-87</div><div>Thread(s) per core:    2</div><div>Core(s) per socket:    22</div><div>Socket(s):             2</div><div>NUMA node(s):          2</div><div>Vendor ID:             GenuineIntel</div><div>CPU family:            6</div><div>Model:                 79</div><div>Model name:            Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz</div><div>Stepping:              1</div><div>CPU MHz:               2195.105</div><div>BogoMIPS:              4391.78</div><div>Virtualization:        VT-x</div><div>L1d cache:             32K</div><div>L1i cache:             32K</div><div>L2 cache:              256K</div><div>L3 cache:              56320K</div><div>NUMA node0 CPU(s):     0-21,44-65</div><div>NUMA node1 CPU(s):     22-43,66-87</div><div>Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch arat epb pln pts dtherm intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdseed adx smap xsaveopt cqm_llc cqm_occup_llc</div></div><div><br></div><div><br></div><div>Here is also x265 command specified same parameters (raw decoded stream needed):</div><div>x265 --input - --input-res 1920x1080 -p ultrafast --fps 50 --hrd --aud --repeat-headers --bitrate 18000 --vbv-maxrate 20000 --vbv-bufsize 40000 --bframes 3 --no-scenecut --rc-lookahead 4 --min-keyint 50 --keyint 50 --no-open-gop --ref 3 --merange 42 --min-cu-size 16 --frame-threads 10 --level-idc 5.1 --lookahead-slices 8 --lookahead-threads 10 --colorprim bt2020 --transfer arib-std-b67 --hdr --no-info --input-depth 10 --output-depth 10 -o out.h265</div><div><br></div><div><br></div><div>Mpegts input stream: <a href="https://yadi.sk/d/NtTPUVnq3VVuFG" target="_blank">https://yadi.sk/d/NtTPUVnq3VVuFG</a></div><div><br></div><div>Can be decoded with command: ffmpeg3 -re -i uhd_input.ts -s 1920x1080 -f rawvideo pipe:1 > /tmp/pipe.yuv</div><div><br></div><div>How can I investigate it further? Do you already encounter that?</div></div></div></div>