File: ffmpeg.h

package info (click to toggle)
motion 3.2.3-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,612 kB
  • ctags: 1,330
  • sloc: ansic: 11,669; sh: 2,906; makefile: 198
file content (68 lines) | stat: -rw-r--r-- 1,908 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef _INCLUDE_FFMPEG_H_
#define _INCLUDE_FFMPEG_H_

#ifdef HAVE_FFMPEG
#include "avformat.h"
#endif

/* Define a codec name/identifier for timelapse videos, so that we can
 * differentiate between normal mpeg1 videos and timelapse videos.
 */
#define TIMELAPSE_CODEC "mpeg1_tl"

struct ffmpeg {
#ifdef HAVE_FFMPEG
	AVFormatContext *oc;
	AVStream *video_st;
	AVCodecContext *c;

	AVFrame *picture;       /* contains default imaga pointers */
	uint8_t *video_outbuf;
	int video_outbuf_size;

	void *udata;            /* U & V planes for greyscale images */
	int vbr;                /* variable bitrate setting */
	char codec[20];         /* codec name */
#else
	int dummy;
#endif
};

/* Initialize FFmpeg stuff. Needs to be called before ffmpeg_open. */
void ffmpeg_init(void);

/* Open an mpeg file. This is a generic interface for opening either an mpeg1 or
 * an mpeg4 video. If non-standard mpeg1 isn't supported (FFmpeg build > 4680), 
 * calling this function with "mpeg1" as codec results in an error. To create a
 * timelapse video, use TIMELAPSE_CODEC as codec name.
 */
struct ffmpeg *ffmpeg_open(
	struct context *cnt,
	char *ffmpeg_video_codec, 
	char *filename, 
	unsigned char *y,    /* YUV420 Y plane */
	unsigned char *u,    /* YUV420 U plane */
	unsigned char *v,    /* YUV420 V plane */
	int width,
	int height, 
	int rate,            /* framerate, fps */
	int bps,             /* bitrate; bits per second */
	int vbr              /* variable bitrate */
	);

/* Puts the image pointed to by the picture member of struct ffmpeg. */
void ffmpeg_put_image(struct context *cnt, struct ffmpeg *);

/* Puts the image defined by u, y and v (YUV420 format). */
void ffmpeg_put_other_image(
	struct context *cnt,
	struct ffmpeg *ffmpeg, 
	unsigned char *y, 
	unsigned char *u, 
	unsigned char *v
	);

/* Closes the mpeg file. */
void ffmpeg_close(struct ffmpeg *);

#endif /* _INCLUDE_FFMPEG_H_ */