如何禁用libx264 stderr输出?

时间:2018-12-20 20:03:03

标签: ffmpeg libavcodec libav libavformat libx264

我正在编写一个使用ffmpeg库接口(libavcodec,libavformat,libavutil等)的库来处理一些视频。其中部分涉及一些我正在使用libx264的编码。一切正常,但是libx264将输出写入stderr,例如:

[libx264 @ 0x62cbc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
[libx264 @ 0x62cbc0] profile High, level 5.0, 4:2:0, 8-bit
[libx264 @ 0x62cbc0] frame I:28    Avg QP:26.78  size:144822
[libx264 @ 0x62cbc0] frame P:135   Avg QP:32.21  size: 30853
[libx264 @ 0x62cbc0] frame B:108   Avg QP:36.18  size: 15709
[libx264 @ 0x62cbc0] consecutive B-frames: 20.3% 79.7%
[libx264 @ 0x62cbc0] mb I  I16..4:  9.5% 75.9% 14.6%
[libx264 @ 0x62cbc0] mb P  I16..4:  1.1%  1.5%  1.4%  P16..4: 44.8%  9.6%  4.2%  0.0%  0.0%    skip:37.5%
[libx264 @ 0x62cbc0] mb B  I16..4:  0.3%  0.2%  0.4%  B16..8: 49.8%  4.6%  0.9%  direct: 1.0%  skip:42.7%  L0:46.9% L1:49.8% BI: 3.2%
[libx264 @ 0x62cbc0] final ratefactor: 26.71
[libx264 @ 0x62cbc0] 8x8 transform intra:68.4% inter:70.4%
[libx264 @ 0x62cbc0] direct mvs  spatial:87.0% temporal:13.0%
[libx264 @ 0x62cbc0] coded y,uvDC,uvAC intra: 76.2% 73.8% 31.6% inter: 9.7% 9.5% 4.2%
[libx264 @ 0x62cbc0] i16 v,h,dc,p:  9% 57%  7% 27%
[libx264 @ 0x62cbc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9% 21%  4%  8%  9%  7% 12%  7% 22%
[libx264 @ 0x62cbc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 28%  9%  6%  6%  6% 10%  6% 16%
[libx264 @ 0x62cbc0] i8c dc,h,v,p: 20% 50% 19% 11%
[libx264 @ 0x62cbc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x62cbc0] ref P L0: 73.2% 12.6% 10.0%  2.7%  1.1%  0.3%
[libx264 @ 0x62cbc0] ref B L0: 92.3%  5.6%  1.7%  0.4%
[libx264 @ 0x62cbc0] kb/s:7912.01

我的库无法写入stdout或stderr。如何以编程方式禁用此输出到stderr?

我意识到我可以“劫持” stderr,但这似乎是一个粗暴的黑客,我强烈希望不要这样做。

1 个答案:

答案 0 :(得分:3)

x264具有命令行参数--quiet。如果用作库,则等效于set

param->i_log_level = X264_LOG_NONE;