x264 low latency low bit rate high quality parameter tuning

H264 decoding delay optimization_H264 encoding parameter optimization:
Reference article: Video Codecs Analysis and Tuning, document download address: http://www.yuvsoft.com/pdf/x264_parameters_comparison.pdf
The article compares 48 different x264 parameter combinations in detail, Comparing the following 6 types of optimal x264 compilation parameters, I converted the x264 parameters in the article into ffmpge command parameters as follows:
1)fastest preset
ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -me_method dia -directpred 1 -me_range 16 -subq 1 -b_qfactor 1.5 -bf 1 -acodec libfaac sample_fastest.mp4

2)fast preset
ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -subq 1 -acodec libfaac sample_fast.mp4
3)tradeoff preset
ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -subq 3 -acodec libfaac sample_tradeoff.mp4
4)good preset
ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -bf 3 -bframebias 5 -flags2 +dct8x8+wpred+bpyramid -trellis 1 -acodec libfaac sample_good.mp4

5)best preset
ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -bf 4 -flags2 +dct8x8+wpred+bpyramid -trellis 1 -refs 10 -directpred 3 -me_method umh -subq 7 -acodec libfaac sample_best.mp4

6) extra quality preset
ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -bf 4 -flags2 +dct8x8+wpred+bpyramid -refs 8 -directpred 3 -me_method umh -subq 7 -pass 1 -acodec libfaac > dev&null
ffmpeg- i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec libx264 -bf 4 -flags2 +dct8x8+wpred+bpyramid -refs 8 -directpred 3 -me_method umh -subq 7 -pass 2 -acodec libfaac sample_extra.mp4 The table below
shows the default parameters down Encoding speed and relative percentage of average bitrate:
Preset Name Speed, % Average bitrate%
Fastest 47 114
Fast 56 109
Tradeoff 70 102
Good 121 89
Best 369 77
Extra Quality 710 72

I tested a racing video with a resolution of 1280 x 720 and 20 frames. The original size of the video is 100442K. The video is encoded using Sorenson Video 3, and the audio is encoded using
MPEG-1 Layer
3. Using the above five parameters, the encoding results are 53897K, 59303K, 60251K, and 63670K. , 55405K, 55405K. I personally prefer the best
preset parameter.
When using the h264 video encoded with the following best parameters, the maximum CPU utilization rate does not exceed 4% during playback, but the effect is significantly higher than that of FLV ffmpeg -i NFSCAR_x360_trackDrift_HD720P.mov -f mp4 -vcodec
libx264
-bf 4 -flags2 +bpyramid+wpred +8x8dct -trellis 1 -refs 10 -directpred 3
-me_method umh -subq 7 -s 352*288 -r 7.5 -aspect 16:9 -acodec libfaac
-ab 32k sample_best_352_288_7.mp4
ffmpeg -i NFSCAR_x360_trackDrift_HD 720P.mov -f flv -vcodec flv -acodec libmp3lamesample_352_288.flv
video size is 4212K (x264), 4816K (Flash/Sorenson)

Summary: x264:
profile: baseline
preset: ultrafast
tune: zerolatency
constant bit rate crf: 28
GOP: 50
frame rate: 25
bit rate as shown in Table
1) x264 --preset ultrafast --tune zerolatency --bframes 0 --qp 20 - -keyint 60 --min-keyint 60 --bitrate 1024 --vbv-maxrate 1024 --vbv-bufsize 1024 --profile baseline --level 3 --input-res 1920x1080 --fps 30 --output output.h264 input .mp4
x264 --preset ultrafast --tune zerolatency --bframes 0 --qp 20 --keyint 60 --min-keyint 60 --bitrate 1024 --vbv-maxrate 1024 --vbv-bufsize 1024 --profile baseline - -level 3 --input-res 1080x720 --fps 30 --output output.h264 input.mp4

2)ffmpeg -i input.mp4 -c:v libx264 -preset ultrafast -tune zerolatency -profile:v baseline -b:v 1500k -s 1280x720 -r 25 -c:a aac -b:a 128k -f flv rtmp://yourserver.com/app/streamkey

3) Higher video quality:
ffmpeg -i input.mp4 -c:v libx264 -profile:v baseline -level 3.0 -preset ultrafast -tune zerolatency -b:v 2M -maxrate 2M -bufsize 1M -c:a aac -b :a 128k -f flv rtmp://server/live/stream
This command uses the x264 encoder, sets the Baseline Profile and Level 3.0, uses the ultrafast preset and the zerolatency option to achieve lower latency, and sets Constant bit rate and maximum bit rate to ensure the balance of video quality and compression bit rate. Adjustments are required on a case-by-case basis. In this command, the output format is FLV, and the video stream can be pushed to the specified server through the RTMP protocol.

4) This command uses the x264 encoder, sets a lower CRF value and the maximum bit rate, controls the encoding quality and bit rate by adjusting the QP parameter, and uses some other parameters to achieve better performance and effect. Adjustments are required on a case-by-case basis. In this command, the output format is H.264, which can be converted as needed.
x264 --preset faster --tune film --crf 28 --vbv-maxrate 1000 --vbv-bufsize 2000 --level 3.1 --profile baseline --output output.h264 input.mp4

Guess you like

Origin blog.csdn.net/huapeng_guo/article/details/131954667