RAPICAM_3-15-2015
RaspiVid.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sysexits.h>
#include "bcm_host.h"
#include "interface/vcos/vcos.h"
#include "interface/mmal/mmal.h"
#include "interface/mmal/mmal_logging.h"
#include "interface/mmal/mmal_buffer.h"
#include "interface/mmal/util/mmal_util.h"
#include "interface/mmal/util/mmal_util_params.h"
#include "interface/mmal/util/mmal_default_components.h"
#include "interface/mmal/util/mmal_connection.h"
#include "RaspiCamControl.h"
#include "RaspiPreview.h"
#include "RaspiCLI.h"
#include <semaphore.h>

Classes

struct  PORT_USERDATA
 
struct  RASPIVID_STATE_S
 

Macros

#define _GNU_SOURCE
 
#define VERSION_STRING   "v1.3.12"
 
#define MMAL_CAMERA_PREVIEW_PORT   0
 
#define MMAL_CAMERA_VIDEO_PORT   1
 
#define MMAL_CAMERA_CAPTURE_PORT   2
 
#define VIDEO_FRAME_RATE_NUM   30
 
#define VIDEO_FRAME_RATE_DEN   1
 
#define VIDEO_OUTPUT_BUFFERS_NUM   3
 Video render needs at least 2 buffers.
 
#define WAIT_METHOD_NONE   0
 
#define WAIT_METHOD_TIMED   1
 Cycle between capture and pause for times specified.
 
#define WAIT_METHOD_KEYPRESS   2
 Switch between capture and pause on keypress.
 
#define WAIT_METHOD_SIGNAL   3
 Switch between capture and pause on signal.
 
#define WAIT_METHOD_FOREVER   4
 Run/record forever.
 
#define IFRAME_BUFSIZE   (60*1000)
 Valid bytes in buffer.
 
#define CommandHelp   0
 Command ID's and Structure defining our command line options.
 
#define CommandWidth   1
 
#define CommandHeight   2
 
#define CommandBitrate   3
 
#define CommandOutput   4
 
#define CommandVerbose   5
 
#define CommandTimeout   6
 
#define CommandDemoMode   7
 
#define CommandFramerate   8
 
#define CommandPreviewEnc   9
 
#define CommandIntraPeriod   10
 
#define CommandProfile   11
 
#define CommandTimed   12
 
#define CommandSignal   13
 
#define CommandKeypress   14
 
#define CommandInitialState   15
 
#define CommandQP   16
 
#define CommandInlineHeaders   17
 
#define CommandSegmentFile   18
 
#define CommandSegmentWrap   19
 
#define CommandSegmentStart   20
 
#define CommandSplitWait   21
 
#define CommandCircular   22
 
#define CommandIMV   23
 
#define CommandCamSelect   24
 
#define CommandSettings   25
 
#define CommandSensorMode   26
 
#define CommandIntraRefreshType   27
 

Typedefs

typedef struct RASPIVID_STATE_S RASPIVID_STATE
 

Functions

int mmal_status_to_int (MMAL_STATUS_T status)
 
int main (int argc, const char **argv)
 

Variables

const int MAX_BITRATE = 25000000
 
const int ABORT_INTERVAL = 100
 Interval at which we check for an failure abort during capture.
 

Detailed Description

Command line program to capture a camera video stream and encode it to file. Also optionally display a preview/viewfinder of current camera input.

Date
28th Feb 2013 : James Hughes

Description

3 components are created; camera, preview and video encoder. Camera component has three ports, preview, video and stills. This program connects preview and stills to the preview and video encoder. Using mmal we don't need to worry about buffers between these components, but we do need to handle buffers from the encoder, which are simply written straight to the file in the requisite buffer callback.

We use the RaspiCamControl code to handle the specific camera settings. We use the RaspiPreview code to handle the (generic) preview window

Macro Definition Documentation

#define WAIT_METHOD_NONE   0

Capture/Pause switch method Simply capture for time specified

Function Documentation

int main ( int  argc,
const char **  argv 
)

main

int mmal_status_to_int ( MMAL_STATUS_T  status)

Convert a MMAL status return value to a simple boolean of success ALso displays a fault if code is not success

Parameters
statusThe error code to convert
Returns
0 if status is sucess, 1 otherwise