def extract_and_parse_bin()

in mapillary_tools/geotag/geotag_from_gopro.py [0:0]


def extract_and_parse_bin(path: str) -> T.List:
    info = ffmpeg.probe_video_format_and_streams(path)

    format_name = info["format"]["format_name"].lower()
    if "mp4" not in format_name:
        raise IOError("File must be an mp4")

    stream_id = None
    for stream in info["streams"]:
        if (
            "codec_tag_string" in stream
            and "gpmd" in stream["codec_tag_string"].lower()
        ):
            stream_id = stream["index"]

    if stream_id is None:
        raise IOError("No GoPro metadata track found - was GPS turned on?")

    with tempfile.NamedTemporaryFile() as tmp:
        LOG.debug("Extracting GoPro stream %s to %s", stream_id, tmp.name)
        ffmpeg.extract_stream(path, tmp.name, stream_id)
        LOG.debug("Parsing GoPro GPMF %s", tmp.name)
        return parse_bin(tmp.name)