7 def convert(filename_in, filename_out, ffmpeg_executable="ffmpeg"):
9 command = [ffmpeg_executable,
"-i", filename_in,
"-c:v",
"libx264",
10 "-preset",
"slow",
"-crf",
"21", filename_out]
11 subprocess.call(command)
15 """ Parse command line arguments. 17 parser = argparse.ArgumentParser(description=
"Siamese Tracking")
19 "--mot_dir", help=
"Path to MOTChallenge directory (train or test)",
22 "--result_dir", help=
"Path to the folder with tracking output.",
25 "--output_dir", help=
"Folder to store the videos in. Will be created " 26 "if it does not exist.",
29 "--convert_h264", help=
"If true, convert videos to libx264 (requires " 30 "FFMPEG", default=
False)
32 "--update_ms", help=
"Time between consecutive frames in milliseconds. " 33 "Defaults to the frame_rate specified in seqinfo.ini, if available.",
35 return parser.parse_args()
38 if __name__ ==
"__main__":
41 os.makedirs(args.output_dir, exist_ok=
True)
42 for sequence_txt
in os.listdir(args.result_dir):
43 sequence = os.path.splitext(sequence_txt)[0]
44 sequence_dir = os.path.join(args.mot_dir, sequence)
45 if not os.path.exists(sequence_dir):
47 result_file = os.path.join(args.result_dir, sequence_txt)
48 update_ms = args.update_ms
49 video_filename = os.path.join(args.output_dir,
"%s.avi" % sequence)
51 print(
"Saving %s to %s." % (sequence_txt, video_filename))
53 sequence_dir, result_file,
False,
None, update_ms, video_filename)
55 if not args.convert_h264:
58 for sequence_txt
in os.listdir(args.result_dir):
59 sequence = os.path.splitext(sequence_txt)[0]
60 sequence_dir = os.path.join(args.mot_dir, sequence)
61 if not os.path.exists(sequence_dir):
63 filename_in = os.path.join(args.output_dir,
"%s.avi" % sequence)
64 filename_out = os.path.join(args.output_dir,
"%s.mp4" % sequence)
65 convert(filename_in, filename_out)
def convert(filename_in, filename_out, ffmpeg_executable="ffmpeg")
def run(sequence_dir, result_file, show_false_alarms=False, detection_file=None, update_ms=None, video_filename=None)