Skip to content

Latest commit

 

History

History
 
 

gen2-container-encoding

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Save encoded video stream into mp4 container

This demo shows how you can stream encoded frames from the device to the host and save them directly into a video container. depthai-python examples like RGB Encoding will save encoded stream into .h264 or .mjpeg file and require that user runs a ffmpeg command to convert raw encoded stream into a video container. Video is encoded on the device itself before it's sent to the host computer.

This demo uses PyAV library, which is just a binding library for the FFmpeg library.

This demo will use H265 codec by default. Note that some video players (eg. Quicktime) might not supprot this codec. We suggest using VLC.

Demo

image

As you can see, the video.mp4 uses the codec of the stream being saved, so there's no decoding/encoding (or converting) happening on the host computer and host CPU/GPU/RAM usage is minimal.

Matroska

Besides ffmpeg and .mp4 video container (which is patent encumbered), you could also use the mkvmerge (see MKVToolNix for GUI usage) and .mkv video container to mux encoded stream into video file that is supported by all major video players (eg. VLC)

mkvmerge -o vid.mkv video.h265

Install requirements

python3 -m pip install -r requirements.txt

Usage

Usage: python3 main.py [codec]
Example: python3 main.py h264

codec can be either 'h264', 'h265', or 'mjpeg'.