Python scene change detection

前端 未结 2 1888
梦毁少年i
梦毁少年i 2020-12-31 22:42

I am wondering if anyone has any experience with Python and video processing. Essentially, I would like to know if there are any libraries that would allow me to do scene de

相关标签:
2条回答
  • 2020-12-31 22:57

    OpenCV has Python bindings; I don't think it has any scene boundary algorithms / functions built it, but you can definitely use it to write your own.

    0 讨论(0)
  • 2020-12-31 23:08

    You can use FFmpeg to do the scene detection and obtain the change frames and their timestamps. The command can be combined with a python script and you can modify it according to your use case.

    You can simply use the command:

    ffmpeg inputvideo.mp4 -filter_complex "select='gt(scene,0.3)',metadata=print:file=time.txt" -vsync vfr img%03d.png
    

    This will save just the relevant information in the time.txt file like below and also save the shot change images in order:

    frame:0    pts:108859  pts_time:1.20954
    lavfi.scene_score=0.436456
    frame:1    pts:285285  pts_time:3.16983
    lavfi.scene_score=0.444537
    frame:2    pts:487987  pts_time:5.42208
    lavfi.scene_score=0.494256
    frame:3    pts:904654  pts_time:10.0517
    lavfi.scene_score=0.462327
    frame:4    pts:2533781 pts_time:28.1531
    lavfi.scene_score=0.460413
    frame:5    pts:2668916 pts_time:29.6546
    lavfi.scene_score=0.432326
    

    The frame is the serial number of the detected shot change from the starting. Also, choose your threshold value (here 0.3) appropriately for your use case to get correct outputs

    0 讨论(0)
提交回复
热议问题