Mtillmann/chaptertool

support PySceneDetect scene CSV format

schtritoff opened this issue · 7 comments

Hi

I'm extracting scenes/chapters from a video file by using PySceneDetect since it is really established solution. The problem is that PySceneDetect is focused on scene detection and then video splitting; to output detected scenes to some wide used format is not prioritized even though this is on roadmap https://github.com/Breakthrough/PySceneDetect/blob/master/docs/features.md#version-roadmap

Is there a way to support PySceneDetect CSV scene (chapter) format (example attached) as an import so that it can be edited and converted to other formats supported by your tool?
kazeta5.23-04-15_20-13.00-Scenes.csv

The CSV is generated on list-scenes command and is handled by this piece of code: https://github.com/Breakthrough/PySceneDetect/blob/aa97ed212584447ecd69cb97bf72b4d14277949e/scenedetect/scene_manager.py#L182

That's a good suggestion and I think it'll be easy to implement but I don't know when I'll come around to do it

Found implementation of PySceneDetect scene CSV file parser in python - should make implementation easier: https://github.com/Mirellanmawl/PySceneDetect-CSV-to-Vegas-EDL/blob/44ecab10f12f480858b42d97e97b2ecd419b5208/PySceneDetect%20CSV%20to%20Vegas%20EDL.py#L9

Thanks! I'll ping you here when I've made some progress. Are you interested in CLI or Browser usage?

CLI since I'm trying to automate these steps:

  • capture raw video
  • process audio and video using avisynth
  • detect scenes/chapters using PySceneDetect, convert resulting scenes CSV using your chaptertool to some supported chapter file like nero, apple or matroska
  • mux audio, video and chapters to resulting MKV or MP4 file

Found implementation of PySceneDetect scene CSV file parser in python - should make implementation easier: https://github.com/Mirellanmawl/PySceneDetect-CSV-to-Vegas-EDL/blob/44ecab10f12f480858b42d97e97b2ecd419b5208/PySceneDetect%20CSV%20to%20Vegas%20EDL.py#L9

Another thing found regarding PySceneDetect scene CSV file - it could have first line omitted when generated by list-scenes -s switch (reference Breakthrough/PySceneDetect#136 (comment)) and then it emits just a simple standard CSV file - attached here kazeta5.23-04-15_20-13.00-Scenes-without-extra-row.csv.

I've added the format and published on npm. You should be able to use it instantly if you use npx

Sorry for commenting on a closed issue. I cannot get convert to recognize the --format flag. It always outputs JSON:

$ npx chaptertool@latest convert ./Scenes.csv --format mkvmergesimple
{
  imagePrefix: '',
  writeEndTimes: true,
  psdFramerate: 23.976,
  psdOmitTimecodes: false
}
{"version":"1.0.0","chapters":[{"startTime":0,"endTime":0.099},{"startTime":0.1,"endTime":42.174},{"startTime":42.175,"endTime":108.24},{"startTime":108.241,"endTime":206.806},{"startTime":206.807,"endTime":471.67},{"startTime":471.671,"endTime":524.256},{"startTime":524.257,"endTime":723.589},{"startTime":723.59,"endTime":820.053}]}

This is in GitBash on Windows. BTW I tried generate too but if I try to set a flag like scene-value I get Node errors.

My goal is to auto detect camera cuts and write them to my MKVs as chapter markers.