This documentation page is also available as an interactive notebook. You can launch the notebook in
Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
above links.
Transform a single document, video, image, or audio file into multiple
rows for granular processing.
What’s in this recipe:
- Split documents into text chunks for RAG
- Extract frames or segments from videos
- Tile images for high-resolution analysis
- Chunk audio files for transcription
Problem
You have documents, videos, or text that you need to break into smaller
pieces for processing. A PDF needs to be split into chunks for
retrieval-augmented generation. A video needs individual frames for
analysis. Text needs to be divided into sentences or sliding windows.
You need a way to transform one source row into multiple output rows
automatically.
Solution
You create views with iterator functions that split source data into
multiple rows. Pixeltable provides built-in iterators for documents,
videos, images, audio, and strings.
Setup
Split documents into chunks
Use document_splitter to break documents (PDF, HTML, Markdown, TXT)
into text chunks.
Inserted 1 row with 0 errors in 0.13 s (7.68 rows/s)
1 row inserted.
Available separators:
heading — Split on HTML/Markdown headings
sentence — Split on sentence boundaries (requires spacy)
token_limit — Split by token count (requires tiktoken)
char_limit — Split by character count
page — Split by page (PDF only)
SDK Reference:
document_splitter
Use frame_iterator to extract frames at specified intervals.
Inserted 1 row with 0 errors in 1.28 s (0.78 rows/s)
1 row inserted.
frame_iterator options:
fps — Frames per second to extract
num_frames — Extract exact number of frames (evenly spaced)
keyframes_only — Extract only keyframes
SDK Reference:
frame_iterator
Split videos into segments
Use video_splitter to divide videos into smaller clips.
video_splitter options:
duration — Duration of each segment in seconds
overlap — Overlap between segments in seconds
min_segment_duration — Drop last segment if shorter than this
SDK Reference:
video_splitter
Split strings into sentences
Use string_splitter to divide text into sentences.
Inserted 1 row with 0 errors in 0.03 s (38.38 rows/s)
1 row inserted.
SDK Reference:
string_splitter
Tile images for analysis
Use tile_iterator to divide large images into a grid of smaller tiles.
This is useful for processing high-resolution images that are too large
to analyze at once, or for running object detection on different
regions.
Inserted 1 row with 0 errors in 0.09 s (11.69 rows/s)
1 row inserted.
tile_iterator options:
tile_size — Size of each tile as (width, height)
overlap — Overlap between adjacent tiles as (width, height)
SDK Reference:
tile_iterator
Split audio into chunks
Use audio_splitter to divide audio files into time-based segments for
transcription or analysis.
Inserted 1 row with 0 errors in 0.67 s (1.50 rows/s)
1 row inserted.
audio_splitter options:
duration — Duration of each chunk in seconds
overlap — Overlap between chunks in seconds
min_segment_duration — Drop last chunk if shorter than this
SDK Reference:
audio_splitter
See also