video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2020-10-09 d64868c215e35088bfeda67aeb04db0800bf2844
csrc/ffmpeg/format/FormatOut.hpp
@@ -4,7 +4,6 @@
#include <stdlib.h>
#include <memory>
#include <string>
#include <vector>
struct AVFormatContext;
struct AVStream;
@@ -12,11 +11,10 @@
struct AVFrame;
struct AVPacket;
struct AVDictionary;
struct AVBSFContext;
namespace ffwrapper{
   class VideoProp;
   class CodedData;
   class FrameData;
   class FormatOut
   {
@@ -34,28 +32,25 @@
      bool open(const char *filename, const char *format_name);
      bool openCodec(VideoProp &prop);
      
      int encode(AVPacket &pkt, AVFrame *frame);
      int encode(std::shared_ptr<CodedData> &data,
               std::shared_ptr<FrameData> &frame_data);
      int encode(std::shared_ptr<CodedData> &data,AVFrame *frame);
      int encode(AVPacket *pkt, AVFrame *frame);
   public:
      bool copyCodecFromIn(std::vector<AVStream*> in);
      bool addStream(AVStream *s);
      bool copyCodecFromIn(AVStream *v, AVStream *a);
      bool openResource(const char *filename, const int flags);
      bool closeResource();
      bool JustWriter(std::vector<AVStream*> in, const char *filename);
      bool JustWriter(AVStream *v, AVStream *a, const char *filename);
      bool EncodeWriter(const char *filename);
      bool writeFrame(AVPacket &pkt, const int64_t &frame_cnt, bool interleaved = true);
      void adjustPTS(AVPacket &pkt, const int64_t &frame_cnt);
      void adjustVideoPTS(AVPacket &pkt, const int64_t &frame_cnt);
      bool writeFrame(AVPacket *pkt, const int64_t &frame_cnt, bool interleaved = true);
      void adjustPTS(AVPacket *pkt, const int64_t &frame_cnt);
      bool endWriter();
      bool writeHeader(AVDictionary **options = NULL);
      bool writeFrame2(AVPacket &pkt, bool interleaved);
      bool writeFrame2(AVPacket *pkt, bool interleaved);
      bool writeTrailer();
   public:
      AVStream *getStream(){return v_s_;}
      AVStream *getStream();
      const AVCodecContext *getCodecContext() const;
      const double getFPS()const{return fps_;}
@@ -67,7 +62,8 @@
      void configEncoder(VideoProp &prop);
   private:
      AVFormatContext       *ctx_;   
      AVStream             *v_s_;
      int                v_idx_;
      int                a_idx_;
      AVCodecContext          *enc_ctx_;
      int64_t                sync_opts_;
@@ -77,8 +73,10 @@
      double                fps_;
      std::string          format_name_;
        AVBSFContext            *bsf_h264, *bsf_hevc;
      // rec
      std::vector<AVStream*>   streams_;
      AVStream              *in_v_stream_;
      AVStream              *in_a_stream_;
   };
}
#endif