33import sys
44import subprocess
55import tempfile
6- import base64
76import webbrowser
87import argparse
98from pathlib import Path
@@ -25,12 +24,6 @@ def compare_frames(frame1_path, frame2_path):
2524 return result .returncode == 0
2625
2726
28- def frame_to_data_url (frame_path ):
29- with open (frame_path , 'rb' ) as f :
30- data = f .read ()
31- return f"data:image/png;base64,{ base64 .b64encode (data ).decode ()} "
32-
33-
3427def create_diff_video (video1 , video2 , output_path ):
3528 """Create a diff video using ffmpeg blend filter with difference mode."""
3629 print ("Creating diff video..." )
@@ -60,20 +53,16 @@ def find_differences(video1, video2):
6053
6154 print (f"Comparing { len (frames1 )} frames..." )
6255 different_frames = []
63- frame_data = []
6456
6557 for i , (f1 , f2 ) in enumerate (zip (frames1 , frames2 , strict = False )):
6658 is_different = not compare_frames (f1 , f2 )
6759 if is_different :
6860 different_frames .append (i )
6961
70- if i < 10 or i >= len (frames1 ) - 10 or is_different :
71- frame_data .append ({'index' : i , 'different' : is_different , 'frame1_url' : frame_to_data_url (f1 ), 'frame2_url' : frame_to_data_url (f2 )})
72-
73- return different_frames , frame_data , len (frames1 )
62+ return different_frames , len (frames1 )
7463
7564
76- def generate_html_report (video1 , video2 , basedir , different_frames , frame_data , total_frames ):
65+ def generate_html_report (video1 , video2 , basedir , different_frames , total_frames ):
7766 chunks = []
7867 if different_frames :
7968 current_chunk = [different_frames [0 ]]
@@ -177,14 +166,14 @@ def main():
177166 diff_video_path = os .path .join (os .path .dirname (args .output ), DIFF_OUT_DIR / "diff.mp4" )
178167 create_diff_video (args .video1 , args .video2 , diff_video_path )
179168
180- different_frames , frame_data , total_frames = find_differences (args .video1 , args .video2 )
169+ different_frames , total_frames = find_differences (args .video1 , args .video2 )
181170
182171 if different_frames is None :
183172 sys .exit (1 )
184173
185174 print ()
186175 print ("Generating HTML report..." )
187- html = generate_html_report (args .video1 , args .video2 , args .basedir , different_frames , frame_data , total_frames )
176+ html = generate_html_report (args .video1 , args .video2 , args .basedir , different_frames , total_frames )
188177
189178 with open (DIFF_OUT_DIR / args .output , 'w' ) as f :
190179 f .write (html )
0 commit comments