VideoStream.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #define FFMPEG_ENABLED
  3. #ifdef FFMPEG_ENABLED
  4. #ifndef VIDEO_STREAM_H_
  5. #define VIDEO_STREAM_H_
  6. #include <string>
  7. #include "Bitmap.h"
  8. extern "C" {
  9. # include <libavformat/avformat.h>
  10. # include <libavformat/avio.h>
  11. # include <libavcodec/avcodec.h>
  12. # include <libavformat/avformat.h>
  13. # include <libavutil/imgutils.h>
  14. # include <libavutil/opt.h>
  15. # include <libswscale/swscale.h>
  16. }
  17. class VideoStream
  18. {
  19. const AVCodec* codec;
  20. AVCodecContext* codecContext;
  21. AVFormatContext* formatContext;
  22. AVCodecParameters* params;
  23. //FILE* file;
  24. AVFrame* picture;
  25. AVPacket* pkt;
  26. AVStream* stream;
  27. SwsContext* swsContext;
  28. static const uint8_t endcode[];
  29. int width;
  30. int height;
  31. int64_t frameIndex = 0;
  32. public:
  33. VideoStream(int width, int height, const std::string& filename, int bitrate, int fps, const char* preset);
  34. ~VideoStream(void);
  35. void encode(AVFrame* frame);
  36. void addFrame(const Bitmap<RGBColor>& frame);
  37. };
  38. #endif // VIDEO_STREAM_H_
  39. #endif // FFMPEG_ENABLED