发布于 2016-11-19 04:57:03
使用
ffmpeg -i in.mp4 -vf "select='gte(scene,0)',metadata=print:file=scenescores.txt" -an -f null -
创建的文本文件的输出如下:
...
frame:1440 pts:737280 pts_time:48
lavfi.scene_score=0.003069
frame:1441 pts:737792 pts_time:48.0333
lavfi.scene_score=0.001593
frame:1442 pts:738304 pts_time:48.0667
lavfi.scene_score=0.000077
frame:1443 pts:738816 pts_time:48.1
lavfi.scene_score=0.002219
...
发布于 2018-09-13 15:47:37
我发现很难解析ffmpeg输出,所以我创建了Python中的包装器。
pip3 install scenecut_extractor
默认情况下,它将提取基于阈值的场景裁剪,因此它将为您提供参数之上的所有内容:
$ scenecut_extractor /path/to/file.mp4
默认情况下将输出JSON:
[
{
"frame": 114,
"pts": 114.0,
"pts_time": 3.8,
"score": 0.445904
},
{
"frame": 159,
"pts": 159.0,
"pts_time": 5.3,
"score": 0.440126
}
]
您可以设置-t 0
来提取所有内容,即每个帧的概率。查看-h
以获得更多选项,例如输出到CSV:
$ scenecut_extractor test/test.mp4 -of csv
frame,pts,pts_time,score
24,12288.0,0.96,1.0
49,25088.0,1.96,1.0
74,37888.0,2.96,1.0
99,50688.0,3.96,1.0
124,63488.0,4.96,1.0
149,76288.0,5.96,1.0
174,89088.0,6.96,1.0
发布于 2021-12-13 23:14:27
根据@slhck复制我的bash解决方案的建议,我给出了另一条评论。
{ echo "frame pts pts_time lavfi.scene_score"; ffmpeg -v 0 -i $INPUT -vf "select='gte(scene,0)',metadata=print:file=/dev/stdout" -f null - | awk 'ORS=NR%2?" ":"\n"' | awk '{$1=$1};1' | sed 's/fi.//' | tr -d '[:alpha:]_:=' | sed 's/ /,/g'; } > scenescores.csv
https://stackoverflow.com/questions/40688062
复制相似问题