video_cutting.h 796 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by xu fulong on 2022/5/13.
  3. //
  4. #ifndef CUT_VIDEO_H
  5. #define CUT_VIDEO_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include "libavformat/avformat.h"
  10. #ifdef __cplusplus
  11. }
  12. #endif
  13. class CutVideo {
  14. private:
  15. int64_t m_startTime = 15;
  16. int64_t m_duration = 10;
  17. int64_t *dts_start_offset;
  18. int64_t *pts_start_offset;
  19. AVFormatContext *ofmt_ctx = nullptr;
  20. AVPacket* copy_packet(AVFormatContext *ifmt_ctx, AVPacket *packet);
  21. int write_internal(AVFormatContext *ifmt_ctx, AVPacket *packet);
  22. public:
  23. int open_output_file(AVFormatContext *ifmt_ctx, const char *filename);
  24. void setParam(int64_t start_time, int64_t duration);
  25. void write_output_file(AVFormatContext *ifmt_ctx, AVPacket *packet);
  26. void close_output_file();
  27. };
  28. #endif //CUT_VIDEO_H