FFMPEG: Get the Scene Change Detection value for a

2019-01-25 23:40发布

I'm trying to measure how much a movies is "fast" (more action in the screen and quick scene chances). I don't want just a single value for the movie, but values along the movie to see how the action varies during it. After normalize the frame rate of the movies (10 fps), my idea is to compare each frame with the previous. I'm not only interest if the scene has changed, but also, if there was no cut, how much movement there is. Not only people/object movement but also, camera movement. In summary the paced (I think that the term) of the scenes.

My idea was to use the scene function from ffmpeg as a metric. But looking at the document and examples online I'm thinking I can only use the value of the Scene Change Detection as a threshold to return frames informations, but I can't get ffmpeg to return the value. Is that right? There is any way I can make it return the value?

标签: video ffmpeg
2条回答
ら.Afraid
2楼-- · 2019-01-26 00:24

I found it hard to parse the ffmpeg output, so I created a wrapper in Python:

pip3 install scenecut_extractor

It will by default extract the scene cuts based on a threshhold, so it'll give you all that are above the parameter:

$ scenecut_extractor /path/to/file.mp4

Will output JSON by default:

[
  {
    "frame": 114,
    "pts": 114.0,
    "pts_time": 3.8,
    "score": 0.445904
  },
  {
    "frame": 159,
    "pts": 159.0,
    "pts_time": 5.3,
    "score": 0.440126
  }
]

You can set -t 0 to extract everything. Check -h for more options.

查看更多
放我归山
3楼-- · 2019-01-26 00:32

Use

ffmpeg -i in.mp4 -vf select='gte(scene,0)',metadata=print:file=scenescores.txt -an -f null -

The text file created will have output like this:

...
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
...
查看更多
登录 后发表回答