SVT-HEVC icon indicating copy to clipboard operation
SVT-HEVC copied to clipboard

when encoding 720p YUV to HEVC, real bitrate is bigger than required

Open waterflag0614 opened this issue 6 years ago • 17 comments

SvtHevcEncApp -i mobile-8bit-yuv420p-720p.yuv -errlog -w 1280 -h 720 -profile 2 -fps-num 30 -fps-denom 1 -rc 1 -lad 20 -tbr 1000000 -intra-period 29 -tune 1 -encMode 1 -latency-mode 0 -irefresh-type 2 -n 250 -b outbitrate.hevc

filesize: 2471729 bytes bitrate:2372.86 Kbps

required bitrate: 1000Kbps mobile-8bit-yuv420p-720p.yuv is bigger than 10M, can not be uploaded. The first 100 frames are black, the follow are normal video stream with a smaller portions of video changing in mobile-8bit-yuv420p-720p.yuv.

waterflag0614 avatar Feb 27 '19 09:02 waterflag0614

@waterflag0614 Thanks for posting the issue. We will investigate.

tianjunwork avatar Feb 27 '19 21:02 tianjunwork

@waterflag0614 Send please the yuv file (ore the original one) to the mega.nz service.

Ilya87 avatar Mar 05 '19 02:03 Ilya87

I had sent yuv to the mega.nz service. https://mega.nz/#!1kRhzSAS!sZtGH0y3_Resd0zcVU9BMRXwH-RoIVV2NM61NLnwKoY

waterflag0614 avatar Mar 05 '19 08:03 waterflag0614

@waterflag0614 Seems to me your sample isn't valid. 1 - It looks damaged (see encoded file in the link below) 2 - Your sample is semi-planar NV12 https://wiki.videolan.org/YUV#NV12, NOT yuv420p 3 - See my link https://mega.nz/#F!fhdFnSCR!UMlZqkOUE_I508bjYpJ2bA with valid example (read txt inside). 4 - command to create valid raw yuv420p - ffmpeg.exe -i input -t 5 -c:v rawvideo -pix_fmt yuv420p outpuy.yuv, where -t 5 means 5 second of input.

Ilya87 avatar Mar 06 '19 18:03 Ilya87

mobile-8bit-yuv420p-720p.yuv is yuv420p, and is created by ffmpeg -video_size 1280x720 -pix_fmt yuv420p10le -i input.YUV -pix_fmt yuv420p -vframes 250.

waterflag0614 avatar Mar 13 '19 09:03 waterflag0614

https://mega.nz/#!Rl5XlCZD!xIc_snY9VyiM4EyoP2nZk0bnXIz7RvJxntnvIDqUsKM

play YUV: ffplay -video_size 1280x720 -pixel_format yuv420p mobile_1280x720_yuv420p_288.yuv

waterflag0614 avatar Mar 14 '19 02:03 waterflag0614

@waterflag0614 mobile-8bit-yuv420p-720p.yuv is yuv420p If you are not shure, use yuvplayer (https://sourceforge.net/projects/raw-yuvplayer/), please. It allows you to select colorspace, resolution, etc. Now your example looks good to me. 288 frames (not 400 as in previous example), video still start from 101 frame and colorspace is yuv420p.

Ilya87 avatar Mar 16 '19 06:03 Ilya87

@waterflag0614 the solution is found - change the lad parameter as it is recommended in User Guide "When RateControlMode is set to 1 it's best to set this parameter to be equal to the Intra period value (such is the default set by the encoder)" -lad 29 (for -intra-period 29). For the latest sample I used command SvtHevcEncApp -i mobile_1280x720_yuv420p_288.yuv -interlaced-video 1 -errlog -w 1280 -h 720 -profile 2 -fps-num 30 -fps-denom 1 -rc 1 -lad 29 -tbr 1000000 -intra-period 29 -tune 1 -encMode 1 -latency-mode 0 -irefresh-type 2 -n 250 -b outbitrate.hevc 973.29 kbit/s - without -interlaced-video option 1003.48 - with -interlaced-video 1 option

Ilya87 avatar Mar 16 '19 06:03 Ilya87

Is it normal the setting of the value of '-lad' affected the value of BitRate, and caused that the value of Bitrate is abnormal?

waterflag0614 avatar Mar 18 '19 06:03 waterflag0614

@waterflag0614 Yes, it is normal if developers implemented such prediction model for bitrate.

Ilya87 avatar Mar 18 '19 07:03 Ilya87

Thanks for your answer. I have another question. Can the value of '-lad' affect the value of PSNR? For example, the larger the value of '-lad', the larger the value of PSNR.

waterflag0614 avatar Mar 18 '19 07:03 waterflag0614

@waterflag0614 Quatation from the x265 cli: The longer the lookahead buffer the more accurate scenecut decisions will be, and the more effective cuTree will be at improving adaptive quant. Having a lookahead larger than the max keyframe interval is not helpful.

Ilya87 avatar Mar 18 '19 07:03 Ilya87

Thanks very match. Could I confirm one more question with you? In VBR mode, when the same command line is executed, the value of real bit rate is different each time. Is the range of bit rate change limited? For example, The actual bit rate fluctuates by 10% over the required bit rate.

waterflag0614 avatar Mar 18 '19 08:03 waterflag0614

@tianjunwork Could you give me an answer to the above question.

waterflag0614 avatar Apr 10 '19 07:04 waterflag0614

«when the same command line is executed, the value of real bit rate is different each time.»

1 – When run on the same yuv file?

If yes, it' s a bug, otherwise it's normal behaviour. There is no CONSTANT (such as for audio mpeg layer 3) bitrate mode neither ASP, nor AVC standards.

Ilya87 avatar Apr 10 '19 10:04 Ilya87

yes, I run SvtHevcEncApp command line on the same yuv file. sample: I executed the following command line and repeated it three times. SvtHevcEncApp -i mobile_1280x720_yuv420p_288.yuv -errlog -w 1280 -h 720 -profile 2 -fps-num 30 -fps-denom 1 -rc 1 -tbr 1000000 -intra-period 29 -tune 1 -encMode 1 -irefresh-type 2 -n 250 -b outbitrate.hevc first time:
Byte Count: 1043419 Bitrate: 1001.68kbps second time: Byte Count: 1016863 Bitrate: 976.19kbps three time: Byte Count: 1038338 Bitrate: 996.80kbps

This happens to any input stream.

waterflag0614 avatar Apr 11 '19 09:04 waterflag0614

@waterflag0614 for VBR mode, there is no setting for min/max bitrate yet in SVT. The VBR rate control is a demo only rate control for now, that’s why it does not have a max min rate. It is designed to keep the bitrate as close as possible to the target bitrate limiting the deviations on a best effort. It does not guarantee that the bitrate would be capped to a maximum bitrate.

tianjunwork avatar Apr 11 '19 18:04 tianjunwork