forked from ZoneMinder/zoneminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzm_ffmpeg_input.h
56 lines (48 loc) · 1.31 KB
/
zm_ffmpeg_input.h
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
#ifndef ZM_FFMPEG_INPUT_H
#define ZM_FFMPEG_INPUT_H
#include "zm_define.h"
extern "C" {
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavcodec/avcodec.h>
}
class FFmpeg_Input {
public:
FFmpeg_Input();
~FFmpeg_Input();
int Open(const char *filename );
int Open(
const AVStream *,
const AVCodecContext *,
const AVStream *,
const AVCodecContext *);
int Close();
AVFrame *get_frame(int stream_id=-1);
AVFrame *get_frame(int stream_id, double at);
int get_video_stream_id() const {
return video_stream_id;
}
int get_audio_stream_id() const {
return audio_stream_id;
}
AVStream *get_video_stream() {
return ( video_stream_id >= 0 ) ? input_format_context->streams[video_stream_id] : nullptr;
}
AVStream *get_audio_stream() {
return ( audio_stream_id >= 0 ) ? input_format_context->streams[audio_stream_id] : nullptr;
}
AVFormatContext *get_format_context() { return input_format_context; };
private:
typedef struct {
AVCodecContext *context;
AVCodec *codec;
int frame_count;
} stream;
stream *streams;
int video_stream_id;
int audio_stream_id;
AVFormatContext *input_format_context;
AVFrame *frame;
int64_t last_seek_request;
};
#endif