Breakthrough / PySceneDetect

:movie_camera: Python and OpenCV-based scene cut/transition detection program & library.
https://www.scenedetect.com/
BSD 3-Clause "New" or "Revised" License
2.97k stars 374 forks source link

Extend image_name_template to allow timestamp #394

Closed Veldhoen closed 3 weeks ago

Veldhoen commented 2 months ago

Problem/Use Case

The current implementation for image_name_template allows four placeholders (of which FRAME_NUMBER is not described in the documentation).

                    VIDEO_NAME=video.name,
                    SCENE_NUMBER=scene_num_format % (i + 1),
                    IMAGE_NUMBER=image_num_format % (j + 1),
                    FRAME_NUMBER=image_timecode.get_frames()), image_extension)

In our use case, we would like to use the image timstamp in the filename, to be able to directly match the image with the right location in the video. Specifically, we would like to use the timestamp as in milliseconds from start, so we can use integers to refer to them.

Proposed Implementation:

In terms of implementation, it is pretty trivial to add this option just by adding FRAME_TIMESTAMP_MS = int(image_timecode.get_seconds()*1000). (using FrameTimeCode.get_seconds)

To enable users to use this, all that needs to be done is extend the documentation specifying $FRAME_TIMESTAMP_MS as one of the template options.

Breakthrough commented 2 months ago

Thank you for the suggestion and PR,. Note that I will likely rename the variable to $TIMESTAMP_MS (just shorter to type) in the next official release, so if you depend on this you may want to update your PR and use cases accordingly.

I'd also like to add $TIMECODE as well before closing this out. Thank you!