Software Stack
DepthAI

ON THIS PAGE

  • Video record
  • Setup
  • Pipeline
  • Source code

Video record

This example demonstrates how to record a video stream and showcases how to use the RecordVideo node for capturing and saving frames.

Setup

This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python
C++

Python

Python
GitHub
1import depthai as dai
2import argparse
3import time
4import signal
5from pathlib import Path
6
7parser = argparse.ArgumentParser()
8parser.add_argument("-o", "--output", default="test_video", help="Output file name (without extension)")
9
10args = parser.parse_args()
11
12with dai.Pipeline() as pipeline:
13    def signal_handler(sig, frame):
14        print("Interrupted, stopping the pipeline")
15        pipeline.stop()
16    signal.signal(signal.SIGINT, signal_handler)
17
18    cam = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
19
20    videoEncoder = pipeline.create(dai.node.VideoEncoder).build(cam.requestOutput((1280, 720), dai.ImgFrame.Type.NV12))
21    videoEncoder.setProfile(dai.VideoEncoderProperties.Profile.H264_MAIN)
22
23    record = pipeline.create(dai.node.RecordVideo)
24    record.setRecordVideoFile(Path(f"{args.output}.mp4"))
25
26    videoEncoder.out.link(record.input)
27
28    pipeline.start()
29    print("Recording video. Press Ctrl+C to stop.")
30    while pipeline.isRunning():
31        time.sleep(1)

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.