awacke1 commited on
Commit
5d25310
·
1 Parent(s): cf0500a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -16,7 +16,8 @@ def images_to_video(folder_path, output_video):
16
  frame = cv2.imread(os.path.join(folder_path, images[0]))
17
  height, width, layers = frame.shape
18
 
19
- video = cv2.VideoWriter(output_video, cv2.VideoWriter_fourcc(*'mpg2'), 1, (width, height))
 
20
 
21
  for image in images:
22
  video.write(cv2.imread(os.path.join(folder_path, image)))
@@ -48,10 +49,10 @@ if uploaded_file is not None:
48
  extract_zip(file_name, output_folder)
49
 
50
  # Convert to Video
51
- output_video = f"{output_folder}.mpg"
52
  images_to_video(output_folder, output_video)
53
 
54
  # Generate download link
55
  video_file_base64 = get_video_base64(output_video)
56
- href = f'<a href="data:file/mpg;base64,{video_file_base64}" download="{output_video}">Download Video File</a>'
57
- st.markdown(href, unsafe_allow_html=True)
 
16
  frame = cv2.imread(os.path.join(folder_path, images[0]))
17
  height, width, layers = frame.shape
18
 
19
+ # Change to MP4 format
20
+ video = cv2.VideoWriter(output_video, cv2.VideoWriter_fourcc(*'mp4v'), 1, (width, height))
21
 
22
  for image in images:
23
  video.write(cv2.imread(os.path.join(folder_path, image)))
 
49
  extract_zip(file_name, output_folder)
50
 
51
  # Convert to Video
52
+ output_video = f"{output_folder}.mp4"
53
  images_to_video(output_folder, output_video)
54
 
55
  # Generate download link
56
  video_file_base64 = get_video_base64(output_video)
57
+ href = f'<a href="data:file/mp4;base64,{video_file_base64}" download="{output_video}">Download Video File</a>'
58
+ st.markdown(href, unsafe_allow_html=True)