-
Notifications
You must be signed in to change notification settings - Fork 511
Html export #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Html export #104
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,10 @@ | |
| from scenedetect.platform import get_csv_writer | ||
| from scenedetect.stats_manager import FrameMetricRegistered | ||
|
|
||
| from scenedetect.simpletable import SimpleTableCell, SimpleTableImage | ||
| from scenedetect.simpletable import SimpleTableRow, SimpleTable, HTMLPage | ||
|
|
||
|
|
||
|
|
||
| ## | ||
| ## SceneManager Helper Functions | ||
|
|
@@ -136,6 +140,96 @@ def write_scene_list(output_csv_file, scene_list, cut_list=None): | |
| '%d' % duration.get_frames(), duration.get_timecode(), '%.3f' % duration.get_seconds()]) | ||
|
|
||
|
|
||
| def write_scene_list_html(output_html_filename, scene_list, cut_list=None, css=None, css_class='mytable', | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would like to have this function in it's own .py file, just because it has nothing to do with the SceneManager class itself. That being said, this is something I can tackle myself - just a small comment :)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I put it there because this is also where the
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good points @wjs018, I'll make a note to see if I can modify write_scene_list to also just take the output file path as a string, instead of a file handle, to make it consistent. Also good point in that write_scene_list and write_scene_list_html belong together - perhaps I will move them into a new sub-module (e.g. |
||
| image_filenames=None, image_width=None, image_height=None): | ||
| """Writes the given list of scenes to an output file handle in html format. | ||
|
|
||
| Arguments: | ||
| output_html_filename: filename of output html file | ||
| scene_list: List of pairs of FrameTimecodes denoting each scene's start/end FrameTimecode. | ||
| cut_list: Optional list of FrameTimecode objects denoting the cut list (i.e. the frames | ||
| in the video that need to be split to generate individual scenes). If not passed, | ||
| the start times of each scene (besides the 0th scene) is used instead. | ||
| css: String containing all the css information for the resulting html page. | ||
| css_class: String containing the named css class | ||
| image_filenames: dict where key i contains a list with n elements (filenames of | ||
| the n saved images from that scene) | ||
| image_width: Optional desired width of images in table in pixels | ||
| image_height: Optional desired height of images in table in pixels | ||
| """ | ||
| if not css: | ||
| css = """ | ||
| table.mytable { | ||
| font-family: times; | ||
| font-size:12px; | ||
| color:#000000; | ||
| border-width: 1px; | ||
| border-color: #eeeeee; | ||
| border-collapse: collapse; | ||
| background-color: #ffffff; | ||
| width=100%; | ||
| max-width:550px; | ||
| table-layout:fixed; | ||
| } | ||
| table.mytable th { | ||
| border-width: 1px; | ||
| padding: 8px; | ||
| border-style: solid; | ||
| border-color: #eeeeee; | ||
| background-color: #e6eed6; | ||
| color:#000000; | ||
| } | ||
| table.mytable td { | ||
| border-width: 1px; | ||
| padding: 8px; | ||
| border-style: solid; | ||
| border-color: #eeeeee; | ||
| } | ||
| #code { | ||
| display:inline; | ||
| font-family: courier; | ||
| color: #3d9400; | ||
| } | ||
| #string { | ||
| display:inline; | ||
| font-weight: bold; | ||
| } | ||
| """ | ||
|
|
||
| # Output Timecode list | ||
| timecode_table = SimpleTable([["Timecode List:"] + | ||
| (cut_list if cut_list else [start.get_timecode() for start, _ in scene_list[1:]])], | ||
| css_class=css_class) | ||
|
|
||
| # Output list of scenes | ||
| header_row = ["Scene Number", "Start Frame", "Start Timecode", "Start Time (seconds)","End Frame", | ||
| "End Timecode", "End Time (seconds)", "Length (frames)", "Length (timecode)", "Length (seconds)"] | ||
| for i, (start, end) in enumerate(scene_list): | ||
| duration = end - start | ||
|
|
||
| row = SimpleTableRow([ | ||
| '%d' % (i+1), | ||
| '%d' % start.get_frames(), start.get_timecode(), '%.3f' % start.get_seconds(), | ||
| '%d' % end.get_frames(), end.get_timecode(), '%.3f' % end.get_seconds(), | ||
| '%d' % duration.get_frames(), duration.get_timecode(), '%.3f' % duration.get_seconds()]) | ||
|
|
||
| if image_filenames: | ||
| for image in image_filenames[i]: | ||
| row.add_cell(SimpleTableCell(SimpleTableImage(image, width=image_width, height=image_height))) | ||
|
|
||
| if i == 0: | ||
| scene_table = SimpleTable(rows=[row], header_row=header_row, css_class=css_class) | ||
| else: | ||
| scene_table.add_row(row=row) | ||
|
|
||
| # Write html file | ||
| page = HTMLPage() | ||
| page.add_table(timecode_table) | ||
| page.add_table(scene_table) | ||
| page.css = css | ||
| page.save(output_html_filename) | ||
|
|
||
|
|
||
| ## | ||
| ## SceneManager Class Implementation | ||
| ## | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.