Aldebaran documentation What's new in NAOqi 2.4.3?

Video recording

<< return to Python examples

This section contains examples recording video from NAO in different formats.

Recording in avi

Record the video taken by NAO’s camera on the robot in .avi format.

#! /usr/bin/env python
# -*- encoding: UTF-8 -*-

"""Example: Demonstrates how to  to record a video file on the robot"""

import qi
import argparse
import sys
import time

def main(session):
    This example demonstrates how to use the ALVideoRecorder module to record a
    video file on the robot.
    # Get the service ALVideoRecorder.

    vid_recorder_service = session.service("ALVideoRecorder")

    # This records a 320*240 MJPG video at 10 fps.
    # Note MJPG can't be recorded with a framerate lower than 3 fps.
    vid_recorder_service.startRecording("/home/nao/recordings/cameras", "myvideo")


    # Video file is saved on the robot in the
    # /home/nao/recordings/cameras/ folder.
    videoInfo = vid_recorder_service.stopRecording()

    print "Video was saved on the robot: ", videoInfo[1]
    print "Num frames: ", videoInfo[0]

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="",
                        help="Robot IP address. On robot or Local Naoqi: use ''.")
    parser.add_argument("--port", type=int, default=9559,
                        help="Naoqi port number")

    args = parser.parse_args()
    session = qi.Session()
        session.connect("tcp://" + args.ip + ":" + str(args.port))
    except RuntimeError:
        print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
               "Please check your script arguments. Run with -h option for help.")