For the complete documentation index, see llms.txt. This page is also available as Markdown.

🗄️Gyroflow protobuf

Gyroflow protobuf format is designed to contain even the most advanced and detailed data about the video capture pipeline, that is useful for post-stabilization.

Download the .proto definition

You can download the latest protobuf definition from telemetry-parser's git repository.

Supported features

  • Camera and lens metadata: Brand, model, focal length, f-number, focus distance etc.

  • Lens distortion model and coefficients

  • Frame readout time for rolling shutter correction

  • Frame capture metadata - ISO, shutter speed, white balance, etc.

  • Raw IMU samples - gyroscope, accelerometer, magnetometer readings

  • Quaternions - final camera orientation after sensor fusion

  • Lens OIS data - detailed information about lens OIS movements, so we can support stabilization when Lens OIS was enabled

  • IBIS data - detailed information about the in-body image stabilization, so we can support stabilization when IBIS was enabled

  • EIS data - if the camera contains any form of electronic stabilization, the protobuf can contain what exactly it did to the image so we can account for it.

  • GPS / GNSS samples - position, altitude, speed and heading, with per-sample fix quality and accuracy estimates


Technical details

This page provides detailed documentation for integrating the Gyroflow Protobuf format natively into camera firmware. By embedding this standardized telemetry directly into video files, cameras can achieve pixel-perfect software stabilization, distortion correction, and rolling shutter compensation in Gyroflow and supported NLEs.

1. Binary Protobuf Embedding in ISO Base Media File Format (MP4/MOV)

Transport format

The Gyroflow Protobuf data should be stored as binary data in a separate MP4 track of the video file. This makes it easy to read and write and it's the standard way to embed additional data in video files.

The data should be stored per-frame so that each video frame should have corresponding metadata in the metadata MP4 track.

Track Setup:

  1. Create a dedicated track with hdlr (Handler Reference Box) set to 'meta' (Metadata).

  2. The stsd (Sample Description Box) should indicate a binary gyroflow format 'gyrf'.

  3. Maintain a 1:1 Sample-to-Frame relationship. For every encoded video frame in the video track, there must be exactly one corresponding sample in the metadata track.

Sample Structure

  • First Sample: The very first metadata sample must contain the Main message initialized with the Header block (camera metadata, clip metadata) AND the first FrameMetadata.

  • Subsequent Samples: All subsequent samples should contain the Main message but omit the Header block, including only the FrameMetadata for that specific frame.

MP4 Track Diagram


2. General overview of the included fields

The Gyroflow Protobuf schema is designed to encapsulate all the necessary metadata required for advanced video stabilization and lens correction.

The Header (Static Metadata)

The Header message acts as the foundational context for the entire video clip. It contains information that generally remains constant throughout the recording and is divided into two sub-messages:

  • CameraMetadata: This defines the physical hardware used to capture the footage.

    • Identification: Fields like camera_brand, camera_model, lens_brand, and lens_model help identify the exact gear setup.

    • Sensor & Optics: Fields like sensor_pixel_width, sensor_pixel_height, pixel_pitch_x_nm and pixel_pitch_y_nm define the physical characteristics of the sensor. The lens_profile field can be used to embed the lens profile, or the lens distortion metadata can be stored directly using fields in the LensData.

    • Orientation: imu_orientation and the optional imu_rotation/quats_rotation quaternions allow you to define base offsets for the sensor data, ensuring the software interprets the XYZ axes correctly.

  • ClipMetadata: This defines the specific parameters of the video file itself.

    • Dimensions & Timing: Standard video properties like frame_width, frame_height, and duration_us.

    • Framerates: It separates record_frame_rate, sensor_frame_rate, and file_frame_rate to accurately handle variable frame rate (VFR) and slow-motion recording scenarios.

FrameMetadata (Dynamic Data)

The FrameMetadata message contains the telemetry and camera settings that change continuously during the recording. Because multiple IMU samples usually occur within the span of a single video frame, this message is built to handle arrays of data.

  • Timing & Synchronization: start_timestamp_us and end_timestamp_us strictly define the capture window of the frame using the camera's internal clock.

  • Per-Frame Camera Settings: Exposure and image properties can fluctuate, especially in auto-exposure modes. Fields like iso, exposure_time_us, and white_balance_kelvin track these shifts.

    • Dynamic cropping (crop_x, crop_width, digital_zoom_ratio) allows the metadata to reflect digital zooms or sensor punches that happen mid-recording.

  • LensData: This field captures dynamic optical changes, such as shifts in focal_length_mm or focus_distance_mm.

    • It also embeds mathematical distortion models and their corresponding distortion_coefficients and camera_intrinsic_matrix to accurately map lens warping at that specific moment in time.

  • Motion Data:

    • IMUData: This is the core raw telemetry. It contains arrays of gyroscope (rotation in degrees/sec) and accelerometer (acceleration in m/s²) readings, alongside precise sample_timestamp_us markers for each sample.

    • QuaternionData: If the camera performs its own sensor fusion, this field provides the calculated orientation as a Hamilton unit quaternion (the w, x, y, z components) mapped to a timestamp.


3. Frame Readout Time and Rolling Shutter Correction

Rolling shutter occurs because CMOS sensors read pixels row-by-row rather than instantly. To correct this, Gyroflow maps every single pixel row to an exact IMU timestamp.

Timestamps & VSync

Gyroflow requires timestamps to be strictly linked to the internal camera clock, down to the microsecond (_us).

  • start_timestamp_us: The readout instant of the first-read row of the crop area - the moment that row finished integrating and was latched out by the readout chain. It is not the moment the row started exposing, and not the midpoint of its exposure. The exposure midpoint is derived by subtracting exposure_time_us / 2.

  • end_timestamp_us: The readout instant of the last-read row of the crop area, under the same convention.

Which row counts as "first-read" follows frame_readout_direction: TopToBottom → the top row, BottomToTop → the bottom row, LeftToRight → the left column, RightToLeft → the right column. Producers whose hardware reports a different physical event (start of integration, or the exposure midpoint) must shift by ±exposure_time_us / 2 before writing these fields.

These two timestamps are authoritative for per-row interpolation. frame_readout_time_us is a float helper while the timestamps are doubles measured directly on the camera clock, so derive per-row time by interpolating between start_timestamp_us and end_timestamp_us rather than from start + frame_readout_time_us.

The frame_readout_time_us in ClipMetadata must represent the readout time of the captured crop (not the whole physical sensor, unless reading the whole sensor).

Readout & IMU Interpolation Diagram

The IMUData array in FrameMetadata may include samples from outside that frame's capture window, and adjacent frames may repeat samples - the reader keys every sample by its timestamp, so overlap is harmless and duplicates collapse. What matters is that the IMU sample timestamps and the sensor readout timestamps come from the same clock: the per-row correction looks up the IMU trajectory at the interpolated row time, so a mismatch shifts the entire correction.

Note that every sample you provide is ingested and used - for orientation integration and for smoothing across the whole clip - not only the ones falling inside a frame's readout window.


4. Lens Data and Distortion Models

To accurately stabilize a video, Gyroflow needs to undistort the image before applying the rotation. The LensData message defines camera intrinsics and lens distortion parameters.

Standard Models

  • OpenCV Fisheye model: Default model used in gyroflow. It also works for non-fisheye lenses. Uses exactly 4 coefficients (k1, k2, k3, k4).

  • OpenCV Standard model: Classic polynomial radial/tangential model. Variable length, following OpenCV's own conventions - 4 (k1,k2,p1,p2), 5 (+k3), 8 (+k4,k5,k6), 12 (+s1..s4, thin prism) or 14 (+tx,ty, tilt) coefficients.

  • Poly3 / Poly5 / PTLens: Lensfun models. 1, 2 and 3 coefficients respectively.

  • NoDistortion: pinhole (rectilinear) projection - the encoded pixels are already linearized so that r=f⋅tan⁡(θ)r = f \cdot \tan(\theta). Producers that fully correct lens distortion in-camera should emit this rather than fitting a polynomial to the result. If the in-camera correction is only partial, refit GenericPolynomial against the post-correction projection instead.

Generic Polynomial

For manufacturers using complex custom glass mapping, the GenericPolynomial model maps the ray angle θ\theta from the optical axis to a dimensionless normalized projected radius:

rnormalized=∑ici⋅θi+1=c0⋅θ+c1⋅θ2+c2⋅θ3+…r_{normalized} = \sum_i c_i \cdot \theta^{i+1} = c_0 \cdot \theta + c_1 \cdot \theta^2 + c_2 \cdot \theta^3 + \dots

coefficients[i] is the coefficient of θi+1\theta^{i+1}, so index 0 is the linear term. Both odd and even powers are allowed - that is the only structural difference from OpenCV Fisheye, which restricts itself to θ3,θ5,θ7,θ9\theta^3, \theta^5, \theta^7, \theta^9 with an implicit leading coefficient of 1.0 (so OpenCV Fisheye is expressible here as [1, 0, k1, 0, k2, 0, k3, 0, k4]). Gyroflow evaluates up to 12 terms; report only as many as your calibration actually fitted, and do not pad with trailing zeros.

Math implementation, for a point (X,Y)(X, Y) in normalized image coordinates:

  1. Radius: r=X2+Y2r = \sqrt{X^2 + Y^2}

  2. Angle: θ=arctan⁡(r)\theta = \arctan(r)

  3. Polynomial evaluation:

    θd=θ⋅c0+θ2⋅c1+θ3⋅c2+⋯+θ12⋅c11\theta_d = \theta \cdot c_0 + \theta^2 \cdot c_1 + \theta^3 \cdot c_2 + \dots + \theta^{12} \cdot c_{11}

  4. Scaling factor: scale=θd/rscale = \theta_d / r (if r=0r=0, scale is 1.01.0)

  5. Apply the scale, then convert to pixels using the per-axis focal lengths and principal point from camera_intrinsic_matrix. Scaling each axis independently is what handles non-square pixels and anamorphic cases where fx≠fyf_x \neq f_y:

    u=X⋅scale⋅fx+cxu = X \cdot scale \cdot f_x + c_x

    v=Y⋅scale⋅fy+cyv = Y \cdot scale \cdot f_y + c_y

There is no separate post-scale coefficient pair - an earlier revision of this model carried one, and it has been removed.

Inverting the model (rnormalized→θr_{normalized} \rightarrow \theta) requires numerical iteration; Newton's method on the polynomial converges in under 10 iterations for any physically reasonable lens.

Normalization requirements. This model uses strict semantics:

  • focal_length_mm MUST be set on the parent LensData entry - the coefficients are normalized assuming a specific physical focal length.

  • The polynomial MUST be normalized so that c0≈1.0c_0 \approx 1.0 for a paraxial ray. If your calibration produces coefficients in meters/radian^n, divide them all by the focal length in meters before writing them here. Consumers may reject a c0c_0 outside roughly [0.8,1.2][0.8, 1.2] as malformed.

  • Reference projections under this normalization: equidistant fisheye r=θr = \theta gives [1, 0, 0, ...]; rectilinear r=tan⁡(θ)r = \tan(\theta) gives [1, 0, 1/3, 0, 2/15, ...]; stereographic r=2tan⁡(θ/2)r = 2\tan(\theta/2) gives [1, 0, 1/12, 0, 1/120, ...].

The coefficients describe the projection of the encoded pixels as they appear in the recorded image, not the raw lens optics. If the camera applies any in-camera correction, geometric crop or desqueeze between sensor readout and encoding, the polynomial must be refit against the resulting projection. If it linearizes fully to pinhole, emit NoDistortion instead.

Intrinsic Matrix:

The protobuf requires a row-major 3x3 intrinsic matrix. Usually defined as:


5. Lens OIS Data (Optical Image Stabilization)

Optical stabilization physically shifts a floating lens element to counteract camera shake. Because the glass moves independently of the camera body, the IMU (which is rigidly attached to the body) records rotation that the sensor didn't actually see.

LensOISData reports the effective displacement of the image content on the sensor surface, in nanometers, at specific timestamps - not the mechanical position of the IS lens group. If your IS group has an image-plane magnification β ≠ 1, multiply the actuator displacement by β before writing it here, so the single pixel-conversion formula below applies regardless of lens design.

Gyroflow does not fold this into the IMU or quaternion data. It converts the shift to pixels:

and applies it as a per-row offset in the image plane while sampling the source frame:

The IMU trajectory is left untouched. The offset simply cancels the movement the lens already performed, so Gyroflow's own digital stabilization doesn't correct it a second time.

Sign convention: the lens group moves the image, so report what the image did. If the image content shifted by +N nm on the sensor, write +N. Axes are sensor-native - +X right, +Y down, origin at the top-left of the sensor active area - and they do not rotate with rotation_degrees.

The sampling rate of OIS data can be much lower than the IMU data, because it's a physical element, it will move slowly. Gyroflow will interpolate any gaps. Typically 4-8 samples per frame is enough, plus a guard sample or two on each side for the spline tangents. The samples should at minimum cover the frame's row-exposure-midpoint span, i.e. [start_timestamp_us - exposure_time_us/2, end_timestamp_us - exposure_time_us/2] - a single sample per frame degenerates to per-frame correction, with no rolling shutter compensation.


6. IBIS Data (In-Body Image Stabilization)

IBIS mechanically shifts and rolls the physical image sensor on its X, Y, and Roll axes.

How it works in the Protobuf:

IBISData carries shift_x_nm, shift_y_nm and roll_angle_degrees, plus sample_timestamp_us - which may be omitted only in the degenerate single-sample-per-frame case, and is required on every sample otherwise.

Sign convention: IBIS moves the sensor, but like LensOISData it reports the displacement of the image content, which is the negative of the sensor's mechanical displacement. If the sensor moved +N nm, write -N. That keeps one consumer formula valid for both stabilizers.

Since the sensor is physically moving inside the camera body during exposure, Gyroflow needs this data for the same reason it needs OIS: the IMU records the camera body moving, but the pixels being recorded are shifting within the body.

The sampling rate of IBIS can be much lower than the IMU data, because it's a physical element, it will move slowly. Gyroflow will interpolate any gaps. Same cadence and coverage requirement as OIS above: typically 4-8 samples per frame plus guards, spanning the frame's row-exposure-midpoint range.

IBIS interaction with IMU

If IBIS is active, Gyroflow maps the mechanical sensor position at the exact row_readout_time.

  • Sensor X/Y Shift: converted from nanometers to pixel offsets using the pixel pitch and the per-frame crop - shift_x_nm * frame_width / (crop_width * pixel_pitch_x_nm), and likewise for Y - then added to the sampling coordinate, exactly like the OIS shift.

  • Sensor Roll: applied as a 2D rotation of the sampling coordinate in the image plane, after the inverse projection - not as a Z rotation folded into the 3x3 orientation matrix. Positive = counterclockwise viewed from the lens toward the sensor, pivoting about the principal point.

The IBIS mechanism has exactly three mechanical degrees of freedom - translation X, translation Y, and roll about the optical axis. The sensor does not pitch or yaw, since physically tilting it would defocus the image. So the X/Y pair captures all linear corrective output, including the correction for camera yaw/pitch shake, which manifests at the sensor as translation by approximately f⋅tan⁡(θ)f \cdot \tan(\theta).

If IBIS completely countered a bump, Gyroflow relies on the IBISData to know that the frame is already stable at that specific timestamp, preventing Gyroflow from digitally correcting a bump that IBIS already fixed (preventing double-correction artifacts).


7. EIS Data (Electronic Image Stabilization)

When the camera applies internal digital stabilization (EIS), the pixels stored in the final MP4 are vastly different from the raw sensor readout. To stabilize this in post, Gyroflow needs to know exactly how the camera deformed the original sensor crop.

There are three options to choose from:

A. QUATERNION

The camera encodes a quaternion representing the internal rotation the camera applied to the frame.

Gyroflow applies the inverse of this quaternion to the frame to "un-stabilize" the footage back to raw sensor data, and then applies its own smoother quaternion path.

This method is used by GoPro (internal Hypersmooth)

B. MESH_WARP

The camera describes its warp as a grid_width x grid_height grid of anchors, uniformly spaced over a region_width x region_height rectangle in sensor-pixel coordinates relative to the per-frame crop_x / crop_y origin - not over the encoded video frame:

For each anchor in row-major order (index k = j * grid_width + i), the pair (warped_xy[2k], warped_xy[2k+1]) gives the absolute position the camera mapped that anchor to - not a displacement. Typically that is the anchor itself plus a sub-pixel to few-pixel correction. Total length is 2 * grid_width * grid_height.

The mesh is the forward direction: it describes what the camera did, mapping sensor-native positions to encoded-frame positions. Gyroflow interpolates between anchors (cubic spline recommended, bilinear acceptable for low-precision use) and numerically inverts the result to map encoded positions back to sensor positions for sampling.

This allows arbitrary internal frame distortions to be encoded, including internal rolling shutter correction, lens distortion correction, and crop movements natively done by the camera.

This method is used by Sony (Active mode)

C. MATRIX_4X4

A standard 16-float row-major matrix representing an affine/perspective 3D transform applied by the camera to the frame. Works similarly to QUATERNION but allows the camera to pass internal scaling and translations directly.


8. JSONL - the text representation

Everything above describes the binary protobuf embedded in an MP4 track. The exact same messages can also be written as JSONL: one Main message per line, each encoded with the protobuf proto3 canonical JSON mapping.

The two representations are interchangeable and carry identical data. JSONL exists because writing an MP4 metadata track requires a muxer, while writing a text file does not - so it's a practical output for camera firmware, converters and test rigs, and it can be inspected in any text editor.

Use the .jsonl file extension.

Format rules

  1. One complete Main message per line. No pretty-printing - a message may not span multiple lines.

  2. The first line carries the Header, either together with the first FrameMetadata (mirroring the binary form) or on a line of its own. All subsequent lines contain only FrameMetadata.

  3. Lines are in playback order, one per video frame.

  4. Blank lines are ignored, and a UTF-8 BOM at the start of the file is tolerated.

Encoding

Any standard protobuf JSON serializer produces the right output - google.protobuf.util.JsonFormat (Java), protojson (Go), protobuf.js, prost-reflect (Rust). The mapping means:

  • Field names are lowerCamelCase: startTimestampUs. The original proto spelling (start_timestamp_us) is also accepted.

  • Enums are their declared name: "frameReadoutDirection": "TopToBottom". Integers are accepted too.

  • oneof variants are flattened into the containing message: the distortion model appears directly in the LensData object as "genericPolynomial": { ... }, not nested under distortion.

  • Fields holding the proto3 default value are omitted entirely. The reader treats a missing field and an explicitly written default identically, so a producer that writes them out instead is fine too. (Gyroflow's own writer drops nulls, empty arrays and empty strings, but keeps numeric zeros and false.)

Timing

There is no MP4 track to supply presentation times, so the reader reconstructs each frame's position on the video timeline from frameNumber and the clip frame rate. Producers should therefore set:

  • frameNumber on every frame, with the first frame of the clip set to 1, and

  • one of fileFrameRate / recordFrameRate / sensorFrameRate in ClipMetadata.

If no frame rate is present the reader falls back to deriving the timeline from startTimestampUs alone, which assumes a constant frame rate. The per-frame difference between startTimestampUs and the reconstructed timeline is preserved either way, so camera-clock jitter is not lost.

Example

The first line of a clip, abbreviated (real files have every IMU sample and one line per frame):

Formatted for reading, the same message looks like this:

Sidecar files

A .jsonl file placed next to the video and named after it is loaded automatically, the same way .gcsv sidecars are:

Gyroflow reads the sidecar when the video itself carries no embedded telemetry. It can also be loaded manually at any time from Motion data → the file picker.

Tools

The telemetry-parser repository contains command-line tools for working with both representations, under bin/:

Tool
Purpose

gyroflow_proto_convert

Converts between the representations: binary ↔ JSONL, and extracts either one out of an MP4's metadata track.

gyroflow_proto_inject

Muxes telemetry, given in either representation, into an MP4 as a metadata track. The video stream is copied as-is, nothing is re-encoded. Note that audio is not carried over - the output holds the video plus the telemetry track only.

These are a practical way to validate a firmware implementation: write JSONL from the camera, inject it into the matching video, and check that Gyroflow stabilizes the result correctly.


9. Other

If your camera has any specific needs, we're open to extend the protobuf to include any additional fields or features.

If you have any questions, feel free to contact us at devteam@gyroflow.xyz or adrian.eddy@gmail.com


Protobuf

Last updated