Skip to content

Commit

Permalink
Use correct frame numbers when extract_every is not 1
Browse files Browse the repository at this point in the history
  • Loading branch information
HHousen committed Jul 26, 2023
1 parent f085324 commit f12a315
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lecture2notes/end_to_end/frames_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def extract_frames(input_video_path, quality, output_path, extract_every_x_secon

logger.debug("Running command: " + command)
os.system(command)

for filename in os.listdir(output_path):
if filename.endswith(".jpg"):
new_number = int(filename.split("_")[1].split(".")[0]) * int(
extract_every_x_seconds
)
new_filename = "img_" + str(new_number).zfill(5) + ".jpg"
os.rename(
os.path.join(output_path, filename),
os.path.join(output_path, new_filename),
)

logger.info(
"Frame extraction successful. Returning output_path=" + str(output_path)
)
Expand Down
2 changes: 1 addition & 1 deletion lecture2notes/end_to_end/summarization_approaches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def structured_joined_sum(

final_dict[title] = {"transcript": coresponding_transcript_text.strip()}
final_dict[title]["slide_content"] = all_slide_content
final_dict[title]["frame_number"] = slide["frame_number"]
final_dict[title]["frame_number"] = slide["frame_number"] * frame_every_x
if "figure_paths" in slide.keys():
final_dict[title]["figure_paths"] = slide["figure_paths"]

Expand Down

0 comments on commit f12a315

Please sign in to comment.