forked from mapillary/mapillary_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_mp4_builder.py
More file actions
36 lines (29 loc) · 1.13 KB
/
simple_mp4_builder.py
File metadata and controls
36 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse
from pathlib import Path
from mapillary_tools.camm import camm_builder
from mapillary_tools.geotag import geotag_videos_from_video
from mapillary_tools.mp4 import simple_mp4_builder as builder
def _parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("source_mp4_path", help="where to read the MP4")
parser.add_argument("target_mp4_path", help="where to write the transformed MP4")
return parser.parse_args()
def main():
parsed_args = _parse_args()
video_metadatas = geotag_videos_from_video.GeotagVideosFromVideo(
[Path(parsed_args.source_mp4_path)]
).to_description()
generator = camm_builder.camm_sample_generator2(video_metadatas[0])
with open(parsed_args.source_mp4_path, "rb") as src_fp:
with open(parsed_args.target_mp4_path, "wb") as tar_fp:
reader = builder.transform_mp4(
src_fp,
generator,
)
while True:
data = reader.read(1024 * 1024 * 64)
if not data:
break
tar_fp.write(data)
if __name__ == "__main__":
main()