VideoExtractor.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /// VideoExtractor.h
  2. /// This class provides functionality for extracting the frames of a video.
  3. /// Curently it extracts at a fixed directory within /tmp.
  4. #ifndef __VIDEOEXTRACTOR_H__
  5. #define __VIDEOEXTRACTOR_H__
  6. #include <string>
  7. extern "C"
  8. {
  9. #include <libavformat/avformat.h>
  10. }
  11. using namespace std;
  12. // structure holding video parameters
  13. struct VideoParams
  14. {
  15. string videoname;
  16. int fps_num;
  17. int fps_den;
  18. int width;
  19. int height;
  20. int numOfFrames;
  21. double GetFrameRate()
  22. {
  23. if (fps_den <=0)
  24. return -1.0;
  25. return (double)fps_num/fps_den;
  26. }
  27. };
  28. class VideoExtractor
  29. {
  30. public:
  31. static bool IsVideoExtracted(string videoname);
  32. static bool ExtractFrames(string videoname);
  33. static string GetFramename(int frameNum);
  34. static string GetParamsname();
  35. static bool LoadVideoParams(string filename, VideoParams &rVideoParams);
  36. private:
  37. VideoExtractor();
  38. VideoExtractor(const VideoExtractor &f);
  39. VideoExtractor &operator=(const VideoExtractor &f);
  40. static void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame);
  41. static void SaveVideoParams(VideoParams videoParams, string filename);
  42. static bool CreateBaseDir();
  43. };
  44. #endif /* __VIDEOEXTRACTOR_H__ */