Skip to content

Sample a single video stream by interval, as by distance - #854

Open
caglarpir wants to merge 1 commit into
mapillary:mainfrom
caglarpir:sample-one-video-stream-by-interval
Open

caglarpir wants to merge 1 commit into
mapillary:mainfrom
caglarpir:sample-one-video-stream-by-interval

Conversation

@caglarpir

@caglarpir caglarpir commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Interval sampling maps every video stream to one output (-map 0:v), and ffmpeg numbers the frames of all of them in one sequence. A GoPro MAX .360 video has two video streams, so frame i, taken at ⌊(i-1)/2⌋ intervals, is stamped at (i-1) intervals. On a 5-minute normal-speed .360 sampled every second, video_process gives 588 samples. 298 of them fail, and the other 290 are placed a median of 73 m (max 190 m) from where they were taken, with --geotag_source gpx and with --geotag_source gopro alike.

Changes

Interval sampling samples the video stream with the highest resolution, as distance sampling does. A video with a single video stream, which is nearly every video, is sampled as before, and its samples keep their _v_ names. A video with several streams gets the index of the sampled stream in the names, as distance samples do.

Verification

  • The 5-minute .360: 294 samples, 290 geotagged with gpx at a median of 2 m (the GPX's own error), 293 with gopro at 0 m.
  • Normal single-stream videos (GoPro HERO7 and HERO8, BlackVue, Insta360 Pro), interval sampling with gpx and with their own source: output identical to main.
  • Unit: 914 passed, 18 skipped, 1 xfailed. Integration: 69 passed. mypy, ruff check, ruff format --check and usort diff are clean.

With #852: one hunk in _sample_single_video_by_interval: probe once, then #852's telemetry and rate.

Interval sampling mapped every video stream of a video to one output, and
ffmpeg numbers the frames of all of them in one sequence. A GoPro MAX .360
video has two video streams, so its frames came out interleaved, and frame
i, taken at (i - 1) // 2 intervals, was stamped (i - 1) intervals into the
video. Half of them were stamped past its end. On a 5-minute .360 video
sampled every second, the frames that could be geotagged were placed a
median of 73 m from where they were taken, and the other half failed.

Interval sampling now samples the video stream with the highest resolution,
as distance sampling does. A video with a single video stream, which is
nearly every video, is sampled as before and its samples keep their names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant