PySceneDetect icon indicating copy to clipboard operation
PySceneDetect copied to clipboard

QP file output

Open tormento opened this issue 1 year ago • 11 comments

x265 (and other software) accepts a .qp file to force a frame type to be applied to a certain frame.

An example is:

0 I -1
1640 I -1
3789 I -1
17191 I -1
31784 I -1
33927 I -1

to have proper scene change cuts.

Here you can find the syntax.

It can be derived by chapters but it's almost of no use when wanting a clean cut frame per each scene.

Would you mind to add that kind of output?

tormento avatar Apr 10 '24 10:04 tormento

Thanks, this falls under some of the other open issues to expand on output formats. I think we should add a new command like export-scenes that is dedicated for this purpose, so that the cuts can be saved in various formats. Updated #344 to include a link to this issue.

I would imagine the command to look something like export-scenes -o "cuts.qp" and have the format auto-detected from extension where possible, or explicitly specified with another flag. We could also allow specifying export-scenes several times to generate the output in different formats.

Breakthrough avatar Apr 17 '24 21:04 Breakthrough

Thanks, do you have any ETA?

tormento avatar Apr 18 '24 13:04 tormento

Unfortunately no ETA at this time, but in v0.6.3 you can now generate a list of cuts as frame numbers instead of timecodes with a config file. To do this, you can add the following to a config file:

[list-scenes]
cut-format = frames

And then use the list-scenes command to generate a CSV file, the first row will be the frames that you need to add I frames for. So the row would contain the following from your example:

1640,3789,17191,31784,33927

You might be able to wrangle that into a QP file with some bash magic or write a small Python script. If you're using the Python API, the detect function should already return the info you need.

Breakthrough avatar Apr 18 '24 23:04 Breakthrough

Excel can do magic tricks ;)

tormento avatar Apr 19 '24 09:04 tormento

Tried your release, sorry for the delay.

It works ok but the generated CSV is not properly "standard".

I mean: looking at the file, we have a first part with Timecode list and a second part with Scene Number, that are CSV formatted in a really different way each other.

Please, write two files so that I can directly import the Scene number and frame in Excel.

When you will have time (if you want to ease my CSV file "postprocessing" :) ), simply output a file with a column of plain scene start frames, almost such as the example I did in the first post.

tormento avatar Jun 19 '24 15:06 tormento

@tormento if you use the --skip-cuts option the file will omit the first row to allow it to be imported directly into Excel. This is not done by default for historical reasons, and will be fixed when we have a replacement for the list-scenes command in a future version.

The start frame column should align with the cut points you need for I frames.

Breakthrough avatar Jun 19 '24 23:06 Breakthrough