用x264生成所有P帧内刷新H264



我正在尝试使用ffmpeg和x264生成只有p帧的定期内刷新h264流,但我总是在开始时得到I帧。

是否有一种方法与x264创建一个p帧仅流?

我使用的命令:

ffmpeg -f lavfi -re -i testsrc=duration=5:size=1920x1080:rate=30000/1001 -s 1920x1080 -pix_fmt yuv420p -f rawvideo out.yuv
x264 --input-res 1920x1080 --intra-refresh out.yuv --b-pyramid none -b 0 --ref 0  -o out.264

验证:

ffprobe -show_frames out.264 |grep pict_type=I

或者只是查看x264输出,例如

yuv [info]: 1920x1080p 0:0 @ 25/1 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.0, 4:2:0, 8-bit
x264 [info]: frame I:1     Avg QP:13.63  size: 12189
x264 [info]: frame P:149   Avg QP:13.59  size:   874
x264 [info]: mb I  I16..4: 78.7% 18.6%  2.7%
x264 [info]: mb P  I16..4:  2.3%  0.1%  0.0%  P16..4:  3.2%  0.3%  0.0%  0.0%  0.0%    skip:94.1%
x264 [info]: 8x8 transform intra:7.6% inter:91.5%
x264 [info]: coded y,uvDC,uvAC intra: 1.3% 18.9% 3.6% inter: 0.1% 1.1% 0.1%
x264 [info]: i16 v,h,dc,p: 86%  6%  1%  7%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 22% 36%  0%  0%  0%  0%  0%  0%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 30% 32%  3%  1%  3%  0%  3%  0%
x264 [info]: i8c dc,h,v,p: 28%  7% 55%  9%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: kb/s:189.96
encoded 150 frames, 66.76 fps, 189.96 kb/s

感谢@Gyan和@nobody555:

ffmpeg -f lavfi -re -i testsrc=duration=60:size=1920x1080:rate=30000/1001 -s 1920x1080 -pix_fmt yuv420p -f rawvideo -|x264 --input-res 1920x1080 --intra-refresh -o - -|ffmpeg -r "30000/1001" -fflags +genpts -i - -c copy -movflags frag_keyframe+empty_moov -f mp4 -|ffmpeg -i - -ss 200ms -c copy -f mpegts out.ts -y

最新更新