2017-06-23 05:58:32 +08:00
|
|
|
#ifndef ZM_FFMPEG_INPUT_H
|
|
|
|
#define ZM_FFMPEG_INPUT_H
|
|
|
|
|
2021-02-05 02:58:29 +08:00
|
|
|
#include "zm_define.h"
|
|
|
|
|
2017-06-23 05:58:32 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "libavformat/avformat.h"
|
|
|
|
#include "libavformat/avio.h"
|
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class FFmpeg_Input {
|
|
|
|
|
|
|
|
public:
|
|
|
|
FFmpeg_Input();
|
|
|
|
~FFmpeg_Input();
|
|
|
|
|
2021-01-27 07:29:34 +08:00
|
|
|
int Open(const char *filename );
|
|
|
|
int Open(
|
|
|
|
const AVStream *,
|
|
|
|
const AVCodecContext *,
|
|
|
|
const AVStream *,
|
|
|
|
const AVCodecContext *);
|
2017-06-23 05:58:32 +08:00
|
|
|
int Close();
|
2021-01-27 07:29:34 +08:00
|
|
|
AVFrame *get_frame(int stream_id=-1);
|
|
|
|
AVFrame *get_frame(int stream_id, double at);
|
2020-11-02 06:15:17 +08:00
|
|
|
int get_video_stream_id() const {
|
2017-08-24 03:05:44 +08:00
|
|
|
return video_stream_id;
|
|
|
|
}
|
2020-11-02 06:15:17 +08:00
|
|
|
int get_audio_stream_id() const {
|
2017-08-24 03:05:44 +08:00
|
|
|
return audio_stream_id;
|
|
|
|
}
|
2021-03-03 22:52:44 +08:00
|
|
|
AVFormatContext * get_format_context() { return input_format_context; };
|
2017-06-23 05:58:32 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
typedef struct {
|
|
|
|
AVCodecContext *context;
|
|
|
|
AVCodec *codec;
|
2017-08-24 03:05:44 +08:00
|
|
|
int frame_count;
|
2017-06-23 05:58:32 +08:00
|
|
|
} stream;
|
|
|
|
|
2017-11-19 05:00:10 +08:00
|
|
|
stream *streams;
|
2017-06-23 05:58:32 +08:00
|
|
|
int video_stream_id;
|
|
|
|
int audio_stream_id;
|
|
|
|
AVFormatContext *input_format_context;
|
2018-11-20 05:45:56 +08:00
|
|
|
AVFrame *frame;
|
2019-12-14 07:12:33 +08:00
|
|
|
int64_t last_seek_request;
|
2017-06-27 04:55:49 +08:00
|
|
|
};
|
2017-06-23 05:58:32 +08:00
|
|
|
|
|
|
|
#endif
|