File: ffmpeg.h

package info (click to toggle)
motion 3.2.9-7
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,912 kB
  • ctags: 1,533
  • sloc: ansic: 14,340; sh: 724; makefile: 216
file content (75 lines) | stat: -rw-r--r-- 2,061 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
69
70
71
72
73
74
75
#ifndef _INCLUDE_FFMPEG_H_
#define _INCLUDE_FFMPEG_H_

#ifdef HAVE_FFMPEG
#include <avformat.h>
#endif

#include <stdio.h>
#include <stdarg.h>

/* 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 image 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(
	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 ffmpeg *);

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

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

/*Deinterlace the image. */
void ffmpeg_deinterlace(unsigned char *, int, int);

/*Setup an avcodec log handler. */
void ffmpeg_avcodec_log(void *, int, const char *, va_list);

#endif /* _INCLUDE_FFMPEG_H_ */