Jiecong Lin
commited on
Commit
·
7016698
1
Parent(s):
e697160
FIX ffmpeg codec err
Browse files
app.py
CHANGED
@@ -309,16 +309,16 @@ def tracking_objects(Seg_Tracker, frame_num, input_video):
|
|
309 |
# output_frames = int(total_frames * scale_slider)
|
310 |
output_frames = len([name for name in os.listdir(output_combined_dir) if os.path.isfile(os.path.join(output_combined_dir, name)) and name.endswith('.png')])
|
311 |
out_fps = fps * output_frames / total_frames
|
312 |
-
ffmpeg.input(os.path.join(output_combined_dir, '%07d.png'), framerate=out_fps).output(output_video_path, vcodec='h264_nvenc', pix_fmt='yuv420p').run()
|
313 |
-
|
314 |
-
|
315 |
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
|
321 |
-
|
322 |
|
323 |
zip_folder(output_masks_dir, output_zip_path)
|
324 |
print("done")
|
|
|
309 |
# output_frames = int(total_frames * scale_slider)
|
310 |
output_frames = len([name for name in os.listdir(output_combined_dir) if os.path.isfile(os.path.join(output_combined_dir, name)) and name.endswith('.png')])
|
311 |
out_fps = fps * output_frames / total_frames
|
312 |
+
# ffmpeg.input(os.path.join(output_combined_dir, '%07d.png'), framerate=out_fps).output(output_video_path, vcodec='h264_nvenc', pix_fmt='yuv420p').run()
|
313 |
+
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
|
314 |
+
out = cv2.VideoWriter(output_video_path, fourcc, out_fps, (frame_width, frame_height))
|
315 |
|
316 |
+
for i in range(output_frames):
|
317 |
+
frame_path = os.path.join(output_combined_dir, f'{i:07d}.png')
|
318 |
+
frame = cv2.imread(frame_path)
|
319 |
+
out.write(frame)
|
320 |
|
321 |
+
out.release()
|
322 |
|
323 |
zip_folder(output_masks_dir, output_zip_path)
|
324 |
print("done")
|