Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
robotics
embodied-ai
human-demonstration
egocentric-video
bimanual-manipulation
tactile-sensing
License:
File size: 886 Bytes
9ff4bea | 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 | """Utilities for working with encoded video sample streams."""
from __future__ import annotations
from typing import TYPE_CHECKING
from rerun_bindings import (
video_detect_gop_start,
video_length_prefixed_to_annex_b as length_prefixed_to_annex_b,
)
if TYPE_CHECKING:
from ..components import VideoCodec
__all__ = [
"detect_gop_start",
"is_annex_b",
"length_prefixed_to_annex_b",
]
def is_annex_b(sample: bytes) -> bool:
"""Whether the sample starts with an Annex B start code (`00 00 01` or `00 00 00 01`)."""
return sample.startswith((b"\x00\x00\x00\x01", b"\x00\x00\x01"))
def detect_gop_start(sample: bytes, codec: VideoCodec) -> bool:
"""
Detect whether a video sample starts a group of pictures, i.e. is a keyframe.
H.264/H.265 samples must be in Annex B format.
"""
return video_detect_gop_start(sample, codec.value)
|