3

Good day, there was a bit of a problem when I working with ffmpeg. We need to find timecodes of scene change detection in the video. Use the following command:

ffmpeg -i inputVideo.mp4 -f image2 -vf "select = gt (scene \ ,. 5)" -vsync vfr thumb% 04d.png

It creates an image from scene change detection. I do not know how to add timecode to a text file. Thanks in advance for your help!)

P.S. Sorry for my bad english)

2 Answers2

1

The idea is to use ffprobe with the Libavfilter input virtual device (lavfi).

You can do this to list the timestamps in the console:

ffprobe -show_frames -print_format compact -f lavfi \
"movie=test.mp4,select=gt(scene\,.8)" | egrep -o "pkt_pts_time=[0-9.]+"

where .8 is the scene detection threshold.

The -print_format also supports CSV, JSON, XML which makes it easier to import the data in other programs.

William Miller
  • 9,839
  • 3
  • 25
  • 46
aergistal
  • 29,947
  • 5
  • 70
  • 92
1

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:

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

Legolas
  • 653
  • 1
  • 9
  • 17