Check back soon for more detailed insight on this project’s inspiration, process, and lessons! For now, here’s information from the GitHub repo:

Installation

Install gopro-video-sync from PyPI:

1pip install gopro-video-sync

Or from the source on GitHub:

1pip install "gopro-video-sync @ git+https://github.com/evoth/gopro-video-sync"

The package will be installed with the module name gopro_video_sync.

Usage example

Print the required adjustment to sync videos from two jointly mounted GoPros:

 1from gopro_video_sync import gopro_offset
 2
 3video_1 = "GOPR1569.MP4"
 4video_2 = "GOPR0105.MP4"
 5
 6offset, source_1, source_2 = gopro_offset(video_1, video_2)
 7
 8if offset is None:
 9    print("Could not determine offset between the given videos.")
10else:
11    offset = round(offset, 3)
12    if offset > 0:
13        print(f"Trim the first {offset} seconds of {video_1} to sync the videos.")
14    elif offset < 0:
15        print(f"Trim the first {-1 * offset} seconds of {video_2} to sync the videos.")
16    else:
17        print("Videos are already synced.")

How it works

Since I had wanted to sync videos from two GoPros that were mounted together, I realized that the gyroscope and accelerometer information from each should be identical. GoPros store sensor data inside MP4 files in a format called GPMF, developed by GoPro for this very purpose. So, this program extracts the GPMF data from each video file and uses cross-correlation to attempt to line up the videos.

If the individual offsets obtained from the gyroscope and accelerometer data do not agree, then the audio data is used in an attempt to verify one of the sensor offsets. If this does not work, then the offset can not be determined.

2024 © Ethan Voth / GitHub / Resume