You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "servaVideoComposer.h"
  2. #define LOG( X ) m_pLog->Log( "MVC", this, X )
  3. #ifdef DEBUG
  4. #define LOG_ERROR( X ) {\
  5. char _tBfrErrMSG234[256];\
  6. sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
  7. m_pLog->Log( "MVC", this, _LOG_ERROR, _tBfrErrMSG234 );\
  8. }
  9. #else
  10. #define LOG_ERROR( X ) m_pLog->Log( "MVC", this, _LOG_ERROR, X );
  11. #endif
  12. servaVideoComposer::servaVideoComposer( uint64_t session_id ){
  13. m_pLog = basicLogCollection::getInstance();
  14. //Load Module Data
  15. if ( tData ) {
  16. memcpy(m_sComposerSettings, tData, sizeof(DBC_MEDIA_COMPOSER_DATA));
  17. free( tData );
  18. } else {
  19. LOG_ERROR("Settings Load Failure!");
  20. memset(m_sComposerSettings, 0, sizeof(DBC_MEDIA_COMPOSER_DATA));
  21. };
  22. //Load Session Data
  23. // create supplimentary data
  24. m_oNoVideoMat =
  25. };
  26. virtual void servaVideoComposer::m_fThreadProc(void){
  27. uint8_t operc = 0;
  28. #ifdef DEBUG_EXTRA
  29. char tB[1024];
  30. sprintf( tB, "Converting %s to %s", m_sDecoderVS.m_pFileName, m_sEncoderVS.m_pFileName );
  31. LOG( tB );
  32. #endif
  33. cv::VideoCapture cap( m_sDecoderVS.m_pFileName );
  34. if( cap.isOpened() ) {
  35. cv::Mat mat;
  36. cap >> mat;
  37. if( !mat.empty() ){
  38. cap.set( cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, 0.0 );
  39. cv::VideoWriter out( m_sEncoderVS.m_pFileName, cv::VideoWriter::fourcc('a', 'v', 'c', '1'), 15.0, mat.size() );
  40. size_t number_of_frames = 0;
  41. m_bStatus = THREAD_INIT;
  42. m_bThreadStatus = TH_WORKING;
  43. while( cap.isOpened() && out.isOpened() && m_bThreadStatus < TH_ENDED ){
  44. cap >> mat;
  45. m_bStatus = ENCODER_ENCODING;
  46. if( mat.empty() ){
  47. m_bThreadStatus = TH_ENDED;
  48. } else {
  49. number_of_frames ++;
  50. out.write(mat);
  51. };
  52. uint8_t perc = ( 100 * number_of_frames ) / 900;
  53. if ( operc!= perc ) {
  54. if ( perc > 100 ) perc = 100;
  55. operc = perc;
  56. m_pMaster->updateEncodeStatus(m_nRefID, MEDIA_ENCODE_PROGRESS, perc);
  57. };
  58. };
  59. cap.release();
  60. // Does it look reasonable?� If so, then we can go ahead and delete the original file.
  61. if( number_of_frames > 100 ){
  62. unlink( m_sDecoderVS.m_pFileName );
  63. };
  64. };
  65. };
  66. };