ffmpeg的blackframe实现视频黑场画面检测
1 参数简介
- amount:
设置黑场的判断阈值,高于此阈值的认为此帧为黑场,该值为一个百分比。默认值98。 - threshold, thresh:
设置黑场像素的判断阈值,低于此阈值的像素认为是黑场像素点。默认值32。
2 测试命令
ffmpeg -loglevel info -i ~/test.mp4 -vf blackframe=95:30 -f null -
3 测试效果
部分检测结果日志如下
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1081 pblack:97 pts:693120 t:43.320000 type:P last_keyframe:934
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1082 pblack:97 pts:693760 t:43.360000 type:P last_keyframe:934
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1083 pblack:97 pts:694400 t:43.400000 type:P last_keyframe:934
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1084 pblack:97 pts:695040 t:43.440000 type:I last_keyframe:1084
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1085 pblack:97 pts:695680 t:43.480000 type:B last_keyframe:1084
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1086 pblack:97 pts:696320 t:43.520000 type:B last_keyframe:1084
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1087 pblack:97 pts:696960 t:43.560000 type:B last_keyframe:1084
[Parsed_blackframe_0 @ 0x7f9f608229c0] frame:1088 pblack:97 pts:697600 t:43.600000 type:B last_keyframe:1084
输出信息包含:帧id、画面黑屏程度、时间戳、帧类型、当前gop的idr帧的位置;