-
Notifications
You must be signed in to change notification settings - Fork 1
Video Transcoding
Eric Hackathorn edited this page Oct 11, 2025
·
1 revision
This page walks through modern usage patterns for zyra process video-transcode, including SOS legacy workflows, batch processing, and advanced FFmpeg tweaks. Copy or adapt this content into the live wiki once reviewed.
-
Command:
zyra process video-transcode <input> [options] - Purpose: Wrap FFmpeg/ffprobe to convert videos or image sequences into modern containers (MP4/WebM/MOV) or SOS legacy outputs.
-
Key features:
- Single-file, directory, glob, or FFmpeg image-sequence inputs
- Automatic codec defaults per container (
mp4→h264,mpg→mpeg2video, etc.) - SOS preset (
--sos-legacy) for NOAA Science On a Sphere playlists - Batch mirroring that preserves relative directory structure when targeting an output folder
- Metadata capture via ffprobe (
--write-metadata,--metadata-out)
- FFmpeg and ffprobe must be installed and on
PATH(or exported viaZYRA_FFMPEG_PATH/ZYRA_FFPROBE_PATH). - Optional: set
ZYRA_VERBOSITY=debugto surface the constructed FFmpeg command.
Verify binaries:
$ ffmpeg -version
$ ffprobe -versionzyra process video-transcode legacy/input.mpg \
--to mp4 \
--codec h264 \
-o modern/output.mp4- Automatically adds
-y(overwrite) unless--no-overwriteis set. - Defaults to
yuv420ppixel format for broad compatibility.
zyra process video-transcode data/raw_videos \
--to mp4 \
--output data/modern_videos \
--extra-args "-movflags +faststart"- Any subdirectories under
data/raw_videosare mirrored relative todata/modern_videos. - The
--extra-argsflag is repeatable; each value is split withshlex, so quoting works as expected.
zyra process video-transcode "staging/*/*.jpg" \
--fps 30 \
--pix-fmt yuv420p \
--output data/renders- The CLI detects globs or
%0Xdpatterns and places the-framerateflag before-i, matching FFmpeg requirements. - Use
--scale(e.g.,--scale 1920x1080) to resize on the fly.
zyra process video-transcode assets/frames/frame%04d.jpg \
--sos-legacy \
-o legacy/sphere_loop.mp4- Applies defaults:
-framerate 30,-b:v 25M,-c:v libxvid,-pix_fmt yuv420p,--codec libxvid,--audio-codec mp2. - SOS workflows overwhelmingly expect
.mp4filenames even when packed with Xvid, so the CLI keeps.mp4unless you explicitly switch containers.
zyra process video-transcode assets/frames/frame%04d.jpg \
--sos-legacy \
--to mpg \
-o legacy/sphere_loop.mpg- The CLI warns that
.mp4is preferred but auto-switches tompeg2videowhen you request--to mpg. - Provide
--codec libxvidif you truly need Xvid inside the MPEG program stream.
Capture ffprobe output to disk and emit it in the logs:
zyra process video-transcode samples/ocean.mpg \
--to mp4 \
--write-metadata \
--metadata-out data/meta/ocean.json-
metadata_outis written as JSON array (one entry per input) containing duration, codec, resolution, bit rate, etc. - When ffprobe is missing the CLI logs a warning and continues.
| Option | Notes |
|---|---|
--scale HEIGHT or WIDTHxHEIGHT
|
Uses FFmpeg scale filter (--scale 1080 → scale=-2:1080). |
--fps / --framerate
|
Applies both input -framerate (for sequences) and output -r. |
--pix-fmt |
Defaults to yuv420p. Override for 10-bit pipelines (e.g., yuv420p10le). |
--audio-codec / --audio-bitrate
|
Select AAC, Opus, MP2, etc. |
--preset, --crf, --gop
|
Passed straight through to FFmpeg encoders that support them. |
--extra-args |
Repeatable; --extra-args "-movflags +faststart" --extra-args "-max_muxing_queue_size 2048". |
--no-overwrite |
Switches FFmpeg to -n. Useful for incremental reruns. |
-
ffmpeg binary not found– Install FFmpeg and ensure it’s onPATH. On macOS:brew install ffmpeg. On Ubuntu/Debian:sudo apt-get install ffmpeg. -
Directory write errors – Make sure the output directory is within the workspace or export
ZYRA_OUTPUT_DIRvia environment variables if running inside limited sandboxes. -
Codec/container mismatch warnings – The CLI surfaces warnings when combinations are uncommon (e.g.,
--to webm --codec libxvid). Choose one of the supported pairings (mp4-h264,webm-vp9,mpg-mpeg2video, etc.). -
Batch glob doesn’t mirror hierarchy – Ensure the glob includes subdirectories (e.g.,
"frames/*/*.jpg"). The CLI derives the root from the non-glob portion of the pattern.
- Run
poetry run ruff format . && poetry run ruff check .before committing changes. - Execute targeted tests:
poetry run pytest -q tests/processing/test_video_transcode.py. - Manual spot checks:
- Single-file
.mpg→.mp4conversion. - SOS preset from a JPG sequence (confirm
.mp4default and warning when forcing.mpg). - Directory or glob batch to validate relative structure mirroring and extra FFmpeg args.
- Single-file
- Optional hardware acceleration flags (
--hwaccel cuda|vaapi). - Parallel batch execution for large directories.
- Additional presets (e.g., automatic
-movflags +faststart, watermarks, etc.).
- Connectors (docs): https://noaa-gsl.github.io/zyra/api/zyra.connectors.html
- Processing (docs): https://noaa-gsl.github.io/zyra/api/zyra.processing.html
- Visualization (docs): https://noaa-gsl.github.io/zyra/api/zyra.visualization.html
- Transform (docs): https://noaa-gsl.github.io/zyra/api/zyra.transform.html
- Utils (docs): https://noaa-gsl.github.io/zyra/api/zyra.utils.html